public class ApplicationContextMembershipListener extends MembershipListenerAdapter<ApplicationContextMembershipListener>
ApplicationContextMembershipListener
class is an extension of MembershipListenerAdapter
used to
adapt the ConfigurableApplicationContext
to handle and process membership events
,
and specifically MemberDepartedEvent
and MemberJoinedEvent
, by
closing
and refreshing
the ConfigurableApplicationContext
when the peer member
departs and joins the
cluster
.DistributedMember
,
DistributedSystem
,
ConfigurableApplicationContext
,
MemberDepartedEvent
,
MemberJoinedEvent
Constructor and Description |
---|
ApplicationContextMembershipListener(org.springframework.context.ConfigurableApplicationContext applicationContext)
Constructs a new instance of
ConfigurableApplicationContext initialized with
the given ConfigurableApplicationContext . |
Modifier and Type | Method and Description |
---|---|
protected org.springframework.context.ConfigurableApplicationContext |
getApplicationContext()
Returns a reference to the configured
ConfigurableApplicationContext . |
void |
handleMemberDeparted(MemberDepartedEvent event)
Handles the
membership event when a peer member
departs from the cluster by calling ConfigurableApplicationContext.close() . |
void |
handleMemberJoined(MemberJoinedEvent event)
Handles the
membership event when a peer member
joins the cluster by calling ConfigurableApplicationContext.refresh() . |
handleMemberSuspect, handleQuorumLost, memberDeparted, memberJoined, memberSuspect, quorumLost, register
public ApplicationContextMembershipListener(@NonNull org.springframework.context.ConfigurableApplicationContext applicationContext)
ConfigurableApplicationContext
initialized with
the given ConfigurableApplicationContext
.applicationContext
- configured ConfigurableApplicationContext
; must not be null.java.lang.IllegalArgumentException
- if ConfigurableApplicationContext
is null.ConfigurableApplicationContext
@NonNull protected org.springframework.context.ConfigurableApplicationContext getApplicationContext()
ConfigurableApplicationContext
.ConfigurableApplicationContext
.ConfigurableApplicationContext
public void handleMemberDeparted(MemberDepartedEvent event)
membership event
when a peer member
departs from the cluster
by calling ConfigurableApplicationContext.close()
.handleMemberDeparted
in class MembershipListenerAdapter<ApplicationContextMembershipListener>
event
- MemberDepartedEvent
to handle.MemberDepartedEvent
,
ConfigurableApplicationContext.close()
public void handleMemberJoined(MemberJoinedEvent event)
membership event
when a peer member
joins the cluster
by calling ConfigurableApplicationContext.refresh()
.handleMemberJoined
in class MembershipListenerAdapter<ApplicationContextMembershipListener>
event
- MemberJoinedEvent
to handle.MemberJoinedEvent
,
ConfigurableApplicationContext.refresh()