public class SingleThreadEventReceivingStrategy extends AbstractActivatable implements EventReceivingStrategy
EventReceivingStrategy
that uses a single thread for all handlers.Activatable.State
Constructor and Description |
---|
SingleThreadEventReceivingStrategy() |
Modifier and Type | Method and Description |
---|---|
void |
activate()
Activates all resources that belong to a specific object.
|
void |
addFilter(Filter filter)
Adds a filter that is applied for all registered handlers some time after
this method call.
|
void |
addHandler(Handler handler,
boolean wait)
Registers a handler that will be informed in case of received events.
|
void |
deactivate()
Deactivate all resources that are owned by a specific object in order to
correctly tear down.
|
void |
handle(Event event)
The callback method.
|
boolean |
isActive()
Tells whether this class is currently active or not.
|
void |
removeFilter(Filter filter)
Removes a filter that is remove for all registered handlers some time
after this method call.
|
void |
removeHandler(Handler handler,
boolean wait)
Removes a handler from the event dispatching.
|
close
public void handle(Event event)
EventHandler
handle
in interface EventHandler
event
- the event to handlepublic void addFilter(Filter filter)
EventReceivingStrategy
addFilter
in interface EventReceivingStrategy
filter
- filter to add, not null
public void removeFilter(Filter filter)
EventReceivingStrategy
removeFilter
in interface EventReceivingStrategy
filter
- filter to remove, not null
public void addHandler(Handler handler, boolean wait)
EventReceivingStrategy
addHandler
in interface EventReceivingStrategy
handler
- the handler to add, not null
wait
- if true
, wait with returning from this method
until the handler is fully functional and will receive the
next issued eventpublic void removeHandler(Handler handler, boolean wait) throws InterruptedException
EventReceivingStrategy
removeHandler
in interface EventReceivingStrategy
handler
- the handler to removewait
- if true
, wait with returning from this method
until the handler cannot receive any more eventsInterruptedException
- interrupted while waiting for the handler to be removedpublic void activate()
Activatable
activate
in interface Activatable
public void deactivate() throws InterruptedException
Activatable
deactivate
in interface Activatable
InterruptedException
- interrupted while waiting for proper deactivation. Object
might be in an undefined state nowpublic boolean isActive()
Activatable
isActive
in interface Activatable
true
if activeCopyright © 2018 CoR-Lab. All rights reserved.