Skip to content

Commit 8a7adb8

Browse files
artembilangaryrussell
authored andcommitted
INT-4528: Docs for SmartLifecycleRoleController
JIRA: https://jira.spring.io/browse/INT-4528
1 parent 262e624 commit 8a7adb8

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/reference/asciidoc/endpoint.adoc

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,17 @@ See the http://docs.spring.io/spring-framework/docs/current/spring-framework-ref
664664
Starting with version 4.2, endpoints can be assigned to roles.
665665
Roles let endpoints be started and stopped as a group.
666666
This is particularly useful when using leadership election, where a set of endpoints can be started or stopped when leadership is granted or revoked, respectively.
667+
For this purpose the framework registers a `SmartLifecycleRoleController` bean in the application context with the name `IntegrationContextUtils.INTEGRATION_LIFECYCLE_ROLE_CONTROLLER`.
668+
Whenever it is necessary to control lifecycles, this bean can be injected or `@Autowired`:
669+
670+
====
671+
[source, xml]
672+
----
673+
<bean class="com.some.project.SomeLifecycleControl">
674+
<property name="roleController" ref="integrationLifecycleRoleController"/>
675+
</bean>
676+
----
677+
====
667678

668679
You can assign endpoints to roles using XML, Java configuration, or programmatically.
669680
The following example shows how to configure endpoint roles with XML:
@@ -734,11 +745,9 @@ Invoking `roleController.startLifecyclesInRole("cluster")` and the corresponding
734745

735746
NOTE: Any object that implements `SmartLifecycle` can be programmatically added -- not just endpoints.
736747

737-
The `SmartLifecycleRoleController` implements `ApplicationListener<AbstractLeaderEvent>` and it automatically
738-
starts and stops its configured `SmartLifecycle` objects when leadership is granted or revoked (when some bean publishes
739-
`OnGrantedEvent` or `OnRevokedEvent`, respectively).
748+
The `SmartLifecycleRoleController` implements `ApplicationListener<AbstractLeaderEvent>` and it automatically starts and stops its configured `SmartLifecycle` objects when leadership is granted or revoked (when some bean publishes `OnGrantedEvent` or `OnRevokedEvent`, respectively).
740749

741-
IMPORTANT: When using leadership election to start and stop components, it is important to set the `auto-startup` XML attribute (`autoStartup` bean property) to `false` so taht the application context does not start the components during context initialization.
750+
IMPORTANT: When using leadership election to start and stop components, it is important to set the `auto-startup` XML attribute (`autoStartup` bean property) to `false` so that the application context does not start the components during context initialization.
742751

743752
Starting with version 4.3.8, the `SmartLifecycleRoleController` provides several status methods:
744753

0 commit comments

Comments
 (0)