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> 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,
SmartLifecycle lifecycle)
Add a
SmartLifecycle to the role. |
void |
addLifecycleToRole(String role,
String lifecycleBeanName)
Add a
SmartLifecycle bean to the role using its name. |
void |
onApplicationEvent(AbstractLeaderEvent event) |
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> lifcycles)
lifcycles - the MultiValueMap of beans in roles.public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
setApplicationContext in interface ApplicationContextAwareBeansExceptionpublic void addLifecycleToRole(String role, 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 void onApplicationEvent(AbstractLeaderEvent event)
onApplicationEvent in interface ApplicationListener<AbstractLeaderEvent>