Class SmartLifecycleRoleController
java.lang.Object
org.springframework.integration.support.SmartLifecycleRoleController
- All Implemented Interfaces:
- EventListener,- Aware,- ApplicationContextAware,- ApplicationListener<AbstractLeaderEvent>
public class SmartLifecycleRoleController
extends Object
implements ApplicationListener<AbstractLeaderEvent>, ApplicationContextAware
Bulk start/stop 
SmartLifecycle in a particular role in phase order.- Since:
- 4.2
- Author:
- Gary Russell, Artem Bilan, Christian Tzolov, Ngoc Nhan
- 
Constructor SummaryConstructorsConstructorDescriptionConstruct an instance without any lifecycle initially: can be added later on viaaddLifecycleToRole(String, SmartLifecycle).SmartLifecycleRoleController(List<String> roles, List<SmartLifecycle> lifecycles) Construct an instance with the provided lists of roles and lifecycles, which must be of equal length.SmartLifecycleRoleController(MultiValueMap<String, SmartLifecycle> lifecycles) Construct an instance with the provided map of roles/instances.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddLifecyclesToRole(String role, List<String> lifecycleBeanNames) Add aSmartLifecyclebeans to the role using their names.final voidaddLifecycleToRole(String role, String lifecycleBeanName) Add aSmartLifecyclebean to the role using its name.final voidaddLifecycleToRole(String role, SmartLifecycle lifecycle) Add aSmartLifecycleto the role.booleanallEndpointsRunning(String role) Return true if all endpoints in the role are running.Return the running status of each endpoint in the role.getRoles()Return a collection of the roles currently managed by this controller.booleannoEndpointsRunning(String role) Return true if none of the endpoints in the role are running or if there are no endpoints in the role.voidbooleanremoveLifecycle(SmartLifecycle lifecycle) Remove the provided SmartLifecycle from all the roles, for example when a SmartLifecycle bean is destroyed.voidsetApplicationContext(ApplicationContext applicationContext) voidstartLifecyclesInRole(String role) Start all registeredSmartLifecycles in the role.voidstopLifecyclesInRole(String role) Stop all registeredSmartLifecycles in the role.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationListenersupportsAsyncExecution
- 
Constructor Details- 
SmartLifecycleRoleControllerpublic SmartLifecycleRoleController()Construct an instance without any lifecycle initially: can be added later on viaaddLifecycleToRole(String, SmartLifecycle).- Since:
- 5.5
 
- 
SmartLifecycleRoleControllerConstruct an instance with the provided lists of roles and lifecycles, which must be of equal length.- Parameters:
- roles- the roles.
- lifecycles- the lifecycles corresponding to the roles.
 
- 
SmartLifecycleRoleControllerConstruct an instance with the provided map of roles/instances.- Parameters:
- lifecycles- the- MultiValueMapof beans in roles.
 
 
- 
- 
Method Details- 
setApplicationContext- Specified by:
- setApplicationContextin interface- ApplicationContextAware
- Throws:
- BeansException
 
- 
addLifecycleToRoleAdd aSmartLifecycleto the role.- Parameters:
- role- the role.
- lifecycle- the- SmartLifecycle.
 
- 
addLifecycleToRoleAdd aSmartLifecyclebean to the role using its name.- Parameters:
- role- the role.
- lifecycleBeanName- the bean name of the- SmartLifecycle.
 
- 
addLifecyclesToRoleAdd aSmartLifecyclebeans to the role using their names.- Parameters:
- role- the role.
- lifecycleBeanNames- the bean names of the- SmartLifecycles.
 
- 
startLifecyclesInRoleStart all registeredSmartLifecycles in the role.- Parameters:
- role- the role.
 
- 
stopLifecyclesInRoleStop all registeredSmartLifecycles in the role.- Parameters:
- role- the role.
 
- 
getRolesReturn a collection of the roles currently managed by this controller.- Returns:
- the roles.
- Since:
- 4.3.8
 
- 
allEndpointsRunningReturn true if all endpoints in the role are running.- Parameters:
- role- the role.
- Returns:
- true if at least one endpoint in the role, and all are running.
- Since:
- 4.3.8
 
- 
noEndpointsRunningReturn true if none of the endpoints in the role are running or if there are no endpoints in the role.- Parameters:
- role- the role.
- Returns:
- true if there are no endpoints or none are running.
- Since:
- 4.3.8
 
- 
getEndpointsRunningStatus
- 
onApplicationEvent- Specified by:
- onApplicationEventin interface- ApplicationListener<AbstractLeaderEvent>
 
- 
removeLifecycleRemove the provided SmartLifecycle from all the roles, for example when a SmartLifecycle bean is destroyed. The role entry in the lifecycles map is cleared as well if its value list is empty after SmartLifecycle removal.- Parameters:
- lifecycle- the SmartLifecycle to remove.
- Returns:
- the removal status
- Since:
- 5.0
 
 
-