public class SmartLifecycleRoleController extends java.lang.Object implements org.springframework.context.ApplicationListener<AbstractLeaderEvent>, org.springframework.context.ApplicationContextAware
SmartLifecycle in a particular role in phase order.| Constructor and Description |
|---|
SmartLifecycleRoleController(java.util.List<java.lang.String> roles,
java.util.List<org.springframework.context.SmartLifecycle> lifecycles)
Construct an instance with the provided lists of roles and lifecycles, which must be of equal length.
|
SmartLifecycleRoleController(org.springframework.util.MultiValueMap<java.lang.String,org.springframework.context.SmartLifecycle> lifcycles)
Construct an instance with the provided map of roles/instances.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLifecyclesToRole(java.lang.String role,
java.util.List<java.lang.String> lifecycleBeanNames)
Add a
SmartLifecycle beans to the role using their names. |
void |
addLifecycleToRole(java.lang.String role,
org.springframework.context.SmartLifecycle lifecycle)
Add a
SmartLifecycle to the role. |
void |
addLifecycleToRole(java.lang.String role,
java.lang.String lifecycleBeanName)
Add a
SmartLifecycle bean to the role using its name. |
boolean |
allEndpointsRunning(java.lang.String role)
Return true if all endpoints in the role are running.
|
java.util.Map<java.lang.String,java.lang.Boolean> |
getEndpointsRunningStatus(java.lang.String role)
Return the running status of each endpoint in the role.
|
java.util.Collection<java.lang.String> |
getRoles()
Return a collection of the roles currently managed by this controller.
|
boolean |
noEndpointsRunning(java.lang.String role)
Return true if none of the endpoints in the role are running or if
there are no endpoints in the role.
|
void |
onApplicationEvent(AbstractLeaderEvent event) |
boolean |
removeLifecycle(org.springframework.context.SmartLifecycle lifecycle)
Remove the provided SmartLifecycle from all the roles,
for example when a SmartLifecycle bean is destroyed.
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
startLifecyclesInRole(java.lang.String role)
Start all registered
SmartLifecycles in the role. |
void |
stopLifecyclesInRole(java.lang.String role)
Stop all registered
SmartLifecycles in the role. |
public SmartLifecycleRoleController(java.util.List<java.lang.String> roles,
java.util.List<org.springframework.context.SmartLifecycle> lifecycles)
roles - the roles.lifecycles - the lifecycles corresponding to the roles.public SmartLifecycleRoleController(org.springframework.util.MultiValueMap<java.lang.String,org.springframework.context.SmartLifecycle> lifcycles)
lifcycles - the MultiValueMap of beans in roles.public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwareorg.springframework.beans.BeansExceptionpublic final void addLifecycleToRole(java.lang.String role,
org.springframework.context.SmartLifecycle lifecycle)
SmartLifecycle to the role.role - the role.lifecycle - the SmartLifecycle.public void addLifecycleToRole(java.lang.String role,
java.lang.String lifecycleBeanName)
SmartLifecycle bean to the role using its name.role - the role.lifecycleBeanName - the bean name of the SmartLifecycle.public void addLifecyclesToRole(java.lang.String role,
java.util.List<java.lang.String> lifecycleBeanNames)
SmartLifecycle beans to the role using their names.role - the role.lifecycleBeanNames - the bean names of the SmartLifecycles.public void startLifecyclesInRole(java.lang.String role)
SmartLifecycles in the role.role - the role.public void stopLifecyclesInRole(java.lang.String role)
SmartLifecycles in the role.role - the role.public java.util.Collection<java.lang.String> getRoles()
public boolean allEndpointsRunning(java.lang.String role)
role - the role.public boolean noEndpointsRunning(java.lang.String role)
role - the role.public java.util.Map<java.lang.String,java.lang.Boolean> getEndpointsRunningStatus(java.lang.String role)
role - the role.public void onApplicationEvent(AbstractLeaderEvent event)
onApplicationEvent in interface org.springframework.context.ApplicationListener<AbstractLeaderEvent>public boolean removeLifecycle(org.springframework.context.SmartLifecycle lifecycle)
lifecycle - the SmartLifecycle to remove.