public class SmartLifecycleRoleController extends Object implements org.springframework.context.ApplicationListener<AbstractLeaderEvent>, org.springframework.context.ApplicationContextAware
SmartLifecycle in a particular role in phase order.| Constructor and Description |
|---|
SmartLifecycleRoleController(List<String> roles,
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<String,org.springframework.context.SmartLifecycle> lifcycles)
Construct an instance with the provided map of roles/instances.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLifecyclesToRole(String role,
List<String> lifecycleBeanNames)
Add a
SmartLifecycle beans to the role using their names. |
void |
addLifecycleToRole(String role,
org.springframework.context.SmartLifecycle lifecycle)
Add a
SmartLifecycle to the role. |
void |
addLifecycleToRole(String role,
String lifecycleBeanName)
Add a
SmartLifecycle bean to the role using its name. |
boolean |
allEndpointsRunning(String role)
Return true if all endpoints in the role are running.
|
Map<String,Boolean> |
getEndpointsRunningStatus(String role)
Return the running status of each endpoint in the role.
|
Collection<String> |
getRoles()
Return a collection of the roles currently managed by this controller.
|
boolean |
noEndpointsRunning(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) |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
startLifecyclesInRole(String role)
Start all registered
SmartLifecycles in the role. |
void |
stopLifecyclesInRole(String role)
Stop all registered
SmartLifecycles in the role. |
public SmartLifecycleRoleController(List<String> roles, List<org.springframework.context.SmartLifecycle> lifecycles)
roles - the roles.lifecycles - the lifecycles corresponding to the roles.public SmartLifecycleRoleController(org.springframework.util.MultiValueMap<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(String role, org.springframework.context.SmartLifecycle lifecycle)
SmartLifecycle to the role.role - the role.lifecycle - the SmartLifecycle.public void addLifecycleToRole(String role, String lifecycleBeanName)
SmartLifecycle bean to the role using its name.role - the role.lifecycleBeanName - the bean name of the SmartLifecycle.public void addLifecyclesToRole(String role, List<String> lifecycleBeanNames)
SmartLifecycle beans to the role using their names.role - the role.lifecycleBeanNames - the bean names of the SmartLifecycles.public void startLifecyclesInRole(String role)
SmartLifecycles in the role.role - the role.public void stopLifecyclesInRole(String role)
SmartLifecycles in the role.role - the role.public Collection<String> getRoles()
public boolean allEndpointsRunning(String role)
role - the role.public boolean noEndpointsRunning(String role)
role - the role.public Map<String,Boolean> getEndpointsRunningStatus(String role)
role - the role.public void onApplicationEvent(AbstractLeaderEvent event)
onApplicationEvent in interface org.springframework.context.ApplicationListener<AbstractLeaderEvent>