Package org.atmosphere.cpr
Class BroadcasterLifecycle
java.lang.Object
org.atmosphere.cpr.BroadcasterLifecycle
Encapsulates the lifecycle management concern for a
DefaultBroadcaster.
Manages lifecycle policy, lifecycle policy listeners, the lifecycle handler,
and the scheduled lifecycle task reference. Extracted from DefaultBroadcaster
to separate lifecycle management from the message dispatch hot path.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidClear all lifecycle listeners.Future<?> Return the current scheduled lifecycle task.voidcurrentLifecycleTask(Future<?> task) Set the current scheduled lifecycle task.Return the currentLifecycleHandler.voidlifecycleHandler(LifecycleHandler handler) Set theLifecycleHandler.Return the lifecycle policy listeners.policy()Return the currentBroadcasterLifeCyclePolicy.Return theAtomicBooleantracking recent activity.voidRemove aBroadcasterLifeCyclePolicyListener.voidsetPolicy(BroadcasterLifeCyclePolicy policy, DefaultBroadcaster broadcaster) Set theBroadcasterLifeCyclePolicyand activate the lifecycle handler if one is set.
-
Constructor Details
-
BroadcasterLifecycle
public BroadcasterLifecycle()
-
-
Method Details
-
policy
Return the currentBroadcasterLifeCyclePolicy.- Returns:
- the lifecycle policy
-
setPolicy
Set theBroadcasterLifeCyclePolicyand activate the lifecycle handler if one is set.- Parameters:
policy- the new lifecycle policybroadcaster- the broadcaster to apply the policy on
-
addLifeCycleListener
- Parameters:
listener- the listener to add
-
removeLifeCycleListener
Remove aBroadcasterLifeCyclePolicyListener.- Parameters:
listener- the listener to remove
-
lifeCycleListeners
Return the lifecycle policy listeners.- Returns:
- the concurrent queue of lifecycle listeners
-
recentActivity
Return theAtomicBooleantracking recent activity.- Returns:
- the recent activity flag
-
lifecycleHandler
Return the currentLifecycleHandler.- Returns:
- the lifecycle handler, may be null
-
lifecycleHandler
Set theLifecycleHandler.- Parameters:
handler- the lifecycle handler
-
currentLifecycleTask
Return the current scheduled lifecycle task.- Returns:
- the lifecycle task future, may be null
-
currentLifecycleTask
Set the current scheduled lifecycle task.- Parameters:
task- the lifecycle task future
-
clearListeners
public void clearListeners()Clear all lifecycle listeners. Called during broadcaster destruction.
-