org.mule.config.spring.SpringLifecycleCallback Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mule-module-spring-config Show documentation
Show all versions of mule-module-spring-config Show documentation
Mule Builder for use with Spring 2.X Namespace based XML
configuration.
The newest version!
/*
* Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
* The software in this package is published under the terms of the CPAL v1.0
* license, a copy of which has been included with this distribution in the
* LICENSE.txt file.
*/
package org.mule.config.spring;
import org.mule.api.lifecycle.Lifecycle;
import org.mule.lifecycle.LifecycleObject;
import org.mule.lifecycle.RegistryLifecycleCallback;
import org.mule.lifecycle.RegistryLifecycleManager;
import com.google.common.collect.TreeTraverser;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* A {@link RegistryLifecycleCallback} to be used with instances
* of {@link SpringRegistry}. For each object in which a {@link Lifecycle} phase
* is going to be applied, it detects all the dependencies for that object
* and applies the same phase on those dependencies first (recursively).
*
* This guarantees that if object A depends on object B and C, necessary lifecycle phases will have
* been applied on B and C before it is applied to A
*
* @since 3.7.0
*/
class SpringLifecycleCallback extends RegistryLifecycleCallback
{
public SpringLifecycleCallback(RegistryLifecycleManager registryLifecycleManager)
{
super(registryLifecycleManager);
}
@Override
protected Collection> lookupObjectsForLifecycle(LifecycleObject lo)
{
Map objects = getSpringRegistry().lookupEntriesForLifecycle(lo.getType());
final DependencyNode root = new DependencyNode(null);
for (Map.Entry entry : objects.entrySet())
{
addDependency(root, entry.getKey(), entry.getValue());
}
Iterable orderedNodes = new TreeTraverser()
{
@Override
public Iterable children(DependencyNode node)
{
return node.getChilds();
}
}.postOrderTraversal(root);
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy