Package org.gcube.common.events.impl
Class DefaultHub
java.lang.Object
org.gcube.common.events.impl.DefaultHub
- All Implemented Interfaces:
Hub
Default
Hub implementation.- Author:
- Fabio Simeoni, Luca Frosini (ISTI-CNR)
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new DefaultHub with a cached thread pool executor service.DefaultHub(ExecutorService service) Creates a new DefaultHub with the specified executor service. -
Method Summary
Modifier and TypeMethodDescriptionvoidFires an event to all observers which have subscribed for them, blocking the client until all the critical observers have executed.voidstop()Signals that this hub is no longer needed and can release its resources.voidSubscribes an observer for notification of events of a given type.booleanunsubscribe(Object observer) Unsubscribes an observer.voidBlocks the caller until an event of a given type occurs.voidBlocks the caller until an event of a given type occurs or a given length of time elapses.
-
Constructor Details
-
DefaultHub
public DefaultHub()Creates a new DefaultHub with a cached thread pool executor service. -
DefaultHub
Creates a new DefaultHub with the specified executor service.- Parameters:
service- the executor service to use for asynchronous event processing- Throws:
IllegalArgumentException- if the service is null
-
-
Method Details
-
subscribe
Description copied from interface:HubSubscribes an observer for notification of events of a given type.The single parameter of any method of the observer annotated with
Observesidentifies the type of the events observed by the observer. -
unsubscribe
Description copied from interface:HubUnsubscribes an observer.- Specified by:
unsubscribein interfaceHub- Parameters:
observer- the observer- Returns:
trueif the observer is found and unsubscribed.
-
fire
Description copied from interface:HubFires an event to all observers which have subscribed for them, blocking the client until all the critical observers have executed. -
waitFor
Description copied from interface:HubBlocks the caller until an event of a given type occurs. -
waitFor
Description copied from interface:HubBlocks the caller until an event of a given type occurs or a given length of time elapses. -
stop
public void stop()Description copied from interface:HubSignals that this hub is no longer needed and can release its resources.
-