*/
protected transient final Log logger = LogFactory.getLog(RegistryLifecycleCallback.class);
public void onTransition(String phaseName, Object object) throws MuleException
{
LifecyclePhase phase = phases.get(phaseName);
if (logger.isDebugEnabled())
{
logger.debug("Applying lifecycle phase: " + phase + " for registry: " + object.getClass().getSimpleName());
}
if (phase instanceof ContainerManagedLifecyclePhase)
{
phase.applyLifecycle(object);
return;
}
// overlapping interfaces can cause duplicates
Set<Object> duplicates = new HashSet<Object>();
for (LifecycleObject lo : phase.getOrderedLifecycleObjects())
{
// TODO Collection -> List API refactoring
Collection<?> targetsObj = getLifecycleObject().lookupObjectsForLifecycle(lo.getType());
List<Object> targets = new LinkedList<Object>(targetsObj);
if (targets.size() == 0)
{
continue;
}
lo.firePreNotification(muleContext);
for (Iterator<Object> target = targets.iterator(); target.hasNext();)
{
Object o = target.next();
if (duplicates.contains(o))
{
target.remove();
}
else
{
if (logger.isDebugEnabled())
{
logger.debug("lifecycle phase: " + phase.getName() + " for object: " + o);
}
phase.applyLifecycle(o);
target.remove();
duplicates.add(o);
}
}