|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object fulmine.demo.Subscriber
public class Subscriber
A simple subscriber that opens a random TcpConnectionBroker
port and
subscribes to a IConnectionBroker
identity "Publisher" for an
IContainer
called "time" and prints each event to the console.
Pressing any key terminates the subscriber.
Constructor Summary | |
---|---|
Subscriber()
|
Method Summary | |
---|---|
void |
addedAsListenerFor(IEventSource source)
The listener receives this when it has been added as a listener to an event source via IEventSource.addListener(IEventListener) . |
void |
destroy()
|
Class<? extends IEvent>[] |
getEventTypeFilter()
Get the classes of IEvent instances this listener can process. |
static void |
main(String[] args)
|
void |
removedAsListenerFrom(IEventSource source)
The listener receives this when it has been removed as a listener from an event source via IEventSource.removeListener(IEventListener) . |
void |
update(IEvent event)
An update has occurred that this listener is interested in. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Subscriber()
Method Detail |
---|
public static void main(String[] args) throws IOException, InterruptedException
args
-
IOException
InterruptedException
public void addedAsListenerFor(IEventSource source)
IEventListener
IEventSource.addListener(IEventListener)
.
addedAsListenerFor
in interface IEventListener
source
- the source that this listener will receive events from.public void removedAsListenerFrom(IEventSource source)
IEventListener
IEventSource.removeListener(IEventListener)
.
removedAsListenerFrom
in interface IEventListener
source
- the source that this listener will no longer receive events
from.public void update(IEvent event)
IEventListener
IEventSource
instances are bound to EventProcessor
instances so the same thread will execute this method for events
originating from the same event source. This does not mean that this
method is thread safe; this method may be run by multiple
EventProcessor
instances and so should be thread aware as
appropriate.
This method can throw any Exception
and processing will not be
interrupted. The EventProcessor
will handle the exception.
update
in interface IEventListener
event
- the event encapsulating the update.public void destroy()
public Class<? extends IEvent>[] getEventTypeFilter()
IEventListener
IEvent
instances this listener can process.
The IEventListener.update(IEvent)
method will only be called with
IEvent
instances whose Class
is assignment
compatible with any contained in this array.
This is an event filtering mechanism. An IEventSource
may
generate many types of IEvent
instances but a listener may only
be interested in one type. By specifying the types of events the listener
is interested in using this method, the listener effectively filters out
unwanted events.
If the filter is dynamic then this method must be thread aware.
getEventTypeFilter
in interface IEventListener
Class
objects that determine the types of
IEvent
instances this listener can process
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |