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
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct 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 Summary
Modifier 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.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecution
-
Constructor Details
-
SmartLifecycleRoleController
public SmartLifecycleRoleController()Construct an instance without any lifecycle initially: can be added later on viaaddLifecycleToRole(String, SmartLifecycle).- Since:
- 5.5
-
SmartLifecycleRoleController
Construct 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.
-
SmartLifecycleRoleController
Construct an instance with the provided map of roles/instances.- Parameters:
lifecycles- theMultiValueMapof beans in roles.
-
-
Method Details
-
setApplicationContext
- Specified by:
setApplicationContextin interfaceApplicationContextAware- Throws:
BeansException
-
addLifecycleToRole
Add aSmartLifecycleto the role.- Parameters:
role- the role.lifecycle- theSmartLifecycle.
-
addLifecycleToRole
Add aSmartLifecyclebean to the role using its name.- Parameters:
role- the role.lifecycleBeanName- the bean name of theSmartLifecycle.
-
addLifecyclesToRole
Add aSmartLifecyclebeans to the role using their names.- Parameters:
role- the role.lifecycleBeanNames- the bean names of theSmartLifecycles.
-
startLifecyclesInRole
Start all registeredSmartLifecycles in the role.- Parameters:
role- the role.
-
stopLifecyclesInRole
Stop all registeredSmartLifecycles in the role.- Parameters:
role- the role.
-
getRoles
Return a collection of the roles currently managed by this controller.- Returns:
- the roles.
- Since:
- 4.3.8
-
allEndpointsRunning
Return 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
-
noEndpointsRunning
Return 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
Return the running status of each endpoint in the role.- Parameters:
role- the role.- Returns:
- A map of component names : running status
- Since:
- 4.3.8
-
onApplicationEvent
- Specified by:
onApplicationEventin interfaceApplicationListener<AbstractLeaderEvent>
-
removeLifecycle
Remove 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
-