Class InitDelayingTopologyEventListener
- All Implemented Interfaces:
org.apache.sling.discovery.TopologyEventListener
What happens aFter the startup time depends on what was received during the delay:
- if no events were received then this is a no-op
- if the last event received was a CHANGING then this facade waits until it receives the next non-CHANGING event (which should be the very next), to then simulate an INIT event (as the discovery API says the first event received is an INIT event).
- if the last event received was not a CHANGING event (ie it was an INIT, CHANGED or PROPERTIES), then as soon as the startup time passes this facade will simulate an INIT event (again, as the discovery API says the first event received is an INIT event)
- Since:
- 1.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionInitDelayingTopologyEventListener
(long startupDelay, org.apache.sling.discovery.TopologyEventListener delegate) Creates a new init-delaying listener with the given delay, delegate and scheduler.InitDelayingTopologyEventListener
(long startupDelay, org.apache.sling.discovery.TopologyEventListener delegate, org.apache.sling.commons.scheduler.Scheduler scheduler) Deprecated.InitDelayingTopologyEventListener
(long startupDelay, org.apache.sling.discovery.TopologyEventListener delegate, org.apache.sling.commons.scheduler.Scheduler scheduler, org.slf4j.Logger loggerOrNull) InitDelayingTopologyEventListener
(long startupDelay, org.apache.sling.discovery.TopologyEventListener delegate, org.slf4j.Logger loggerOrNull) Creates a new init-delaying listener with the given delay, delegate, scheduler and optinoal logger. -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Marks this listener as no longer active - ensures that it doesn't call the delegate via any potentially pending scheduler callback.void
handleTopologyEvent
(org.apache.sling.discovery.TopologyEvent event)
-
Constructor Details
-
InitDelayingTopologyEventListener
public InitDelayingTopologyEventListener(long startupDelay, org.apache.sling.discovery.TopologyEventListener delegate) Creates a new init-delaying listener with the given delay, delegate and scheduler.For properly disposing the caller should use the dispose method!
- Parameters:
startupDelay
- The startup delay in secondsdelegate
- The topology event listener- See Also:
-
InitDelayingTopologyEventListener
public InitDelayingTopologyEventListener(long startupDelay, org.apache.sling.discovery.TopologyEventListener delegate, org.slf4j.Logger loggerOrNull) Creates a new init-delaying listener with the given delay, delegate, scheduler and optinoal logger.For properly disposing the caller should use the dispose method!
- Parameters:
startupDelay
- The startup delay in secondsdelegate
- The topology event listenerloggerOrNull
- Optional logger instance- See Also:
-
InitDelayingTopologyEventListener
@Deprecated public InitDelayingTopologyEventListener(long startupDelay, org.apache.sling.discovery.TopologyEventListener delegate, org.apache.sling.commons.scheduler.Scheduler scheduler) Deprecated.Creates a new init-delaying listener with the given delay, delegate and scheduler.For properly disposing the caller should use the dispose method!
- Parameters:
startupDelay
- The startup delay in secondsdelegate
- The topology event listenerscheduler
- Scheduler to schedule the delay (not used)- See Also:
-
InitDelayingTopologyEventListener
@Deprecated public InitDelayingTopologyEventListener(long startupDelay, org.apache.sling.discovery.TopologyEventListener delegate, org.apache.sling.commons.scheduler.Scheduler scheduler, org.slf4j.Logger loggerOrNull) Creates a new init-delaying listener with the given delay, delegate, scheduler and optinoal logger.For properly disposing the caller should use the dispose method!
- Parameters:
startupDelay
- The startup delay in secondsdelegate
- The topology event listenerscheduler
- Scheduler to schedule the delay (not used)loggerOrNull
- Optional logger instance- See Also:
-
-
Method Details
-
handleTopologyEvent
public void handleTopologyEvent(org.apache.sling.discovery.TopologyEvent event) - Specified by:
handleTopologyEvent
in interfaceorg.apache.sling.discovery.TopologyEventListener
-
dispose
public void dispose()Marks this listener as no longer active - ensures that it doesn't call the delegate via any potentially pending scheduler callback.Note that after dispose you can *still* call handleTopologyEvent and the events are passed to the delegate - but those are expected to be 'late' events and not really part of the normal game. Hence, the caller must also ensure that the handleTopologyEvent method isn't called anymore (which typically is automatically guaranteed since the caller is typically an osgi service that gets unregistered anyway)
-
InitDelayingTopologyEventListener(long, TopologyEventListener)