}
private void updateComponentIfNecessary(final ComponentSpec c, final Collection<AbstractComponent> cachedComponents) {
Collection<AbstractComponent> delegateComponets = new ArrayList<AbstractComponent>();
for (final AbstractComponent ac : cachedComponents) {
Updatable updatable = ac.getCapability(Updatable.class);
updatable.setStaleByVersion(c.getComponentId(), c.getObjVersion());
cleanCacheIfNecessary(c.getComponentId(), c.getObjVersion());
if (ac.getWorkUnitDelegate() != null) {
ac.getWorkUnitDelegate().getCapability(Updatable.class).setStaleByVersion(c.getComponentId(), c.getObjVersion());
delegateComponets.add(ac.getWorkUnitDelegate());
}
}
cachedComponents.addAll(delegateComponets);
for (final AbstractComponent ac: cachedComponents) {
if (ac.isStale()) {
ac.resetComponentProperties(new AbstractComponent.ResetPropertiesTransaction() {
@Override
public void perform() {
Updatable updatable = ac.getCapability(Updatable.class);
updatable.notifyStale();
}
});
LOGGER.debug("{} updated", c.getComponentName());
}
}