public class SmartLifecycleRoleController extends Object implements ApplicationListener<AbstractLeaderEvent>, ApplicationContextAware
SmartLifecycle in a particular role in phase order.| Constructor and Description |
|---|
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.
|
| 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,
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) |
boolean |
removeLifecycle(SmartLifecycle lifecycle)
Remove the provided SmartLifecycle from all the roles,
for example when a SmartLifecycle bean is destroyed.
|
void |
setApplicationContext(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<SmartLifecycle> lifecycles)
roles - the roles.lifecycles - the lifecycles corresponding to the roles.public SmartLifecycleRoleController(MultiValueMap<String,SmartLifecycle> lifecycles)
lifecycles - the MultiValueMap of beans in roles.public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
setApplicationContext in interface ApplicationContextAwareBeansExceptionpublic final void addLifecycleToRole(String role, SmartLifecycle lifecycle)
SmartLifecycle to the role.role - the role.lifecycle - the SmartLifecycle.public final 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 ApplicationListener<AbstractLeaderEvent>public boolean removeLifecycle(SmartLifecycle lifecycle)
lifecycle - the SmartLifecycle to remove.