|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
TOPIC - the type of the topics associated with the events managed by the producer.PAYLOAD - the type of the payload of the events managed by the producer.public interface GCUBEConsumer<TOPIC extends GCUBETopic,PAYLOAD>
Interface for consumers of notification of GCUBEEvents about GCUBETopic
A consumer receives notifications from a GCUBEProducers with which it has previously subscribed.
Through type instantiation, consumers may be constrained to handle only GCUBEEvents about given topics and/or
carrying given payloads. For example:
a GCUBEConsumer<MyTopic,Object> consumes only events
about MyTopics but carrying any payload.
a GCUBEConsumer<GCUBETopic,MyPayload> consumer events about any GCUBETopic as long
as they carry MyPayloads.
a GCUBEConsumer<MyTopic,MyPayload> consumer only events about MyTopics which
carry MyPayloads.
Type constraints may be specified when the consumer interface is implemented, either explicitly:
public class MyConsumer implements GCUBEConsumer<MyTopic,MyPayload> {...}
...
MyConsumer myConsumer = new MyConsumer();
or else implicitly, using anonymous inner classes, e.g.
GCUBEConsumer<MyTopic,MyPayload> myConsumer = new GCUBEConsumer<MyTopic,MyPayload>(){...};
A consumer which consumes events associated with different topics and/or payloads performs
a type-based analysis on the events in input to onEvent(GCUBEEvent[]). For example,
a consumer MyConsumer which implements the GCUBEConsumer<MyTopic,MyPayload>
interface would implement onEvent(GCUBEEvent[]) along the following lines:
public For convenience, the type-based analysis of public public void onEvent(MyEvent event){...}
This approach suits complex type-based analyses, or else circumstances in which a concrete implementations
of the consumers is best delegated to subclasses. In the latter case, the event-specific methods
(and thus
for (GCUBEEvent
if (event instanceof MyEvent) {...}
else if (event instanceof MyOtherEvent) {...}
...
}
}
MyConsumer may dispatch to
event-specific methods, e.g.:
for (GCUBEEvent
if (event instanceof MyEvent) {this.onEvent((MyEvent) event);}
else if (event instanceof MyOtherEvent) {this.onEvent((MyOtherEvent) event);}
...
public void onEvent(MyOtherEvent event){...}
}
}
MyProducer) may be declared as abstract method.
GCUBEEvent,
GCUBETopic,
GCUBEProducer
Method Summary
<T1 extends TOPIC,P1 extends PAYLOAD>
voidonEvent(GCUBEEvent<T1,P1>... event)
Notifies the consumer of one of more events about topics for which the consumer
has previously subscribed with a GCUBEProducer
Method Detail
onEvent
<T1 extends TOPIC,P1 extends PAYLOAD> void onEvent(GCUBEEvent<T1,P1>... event)
GCUBEProducer
T1 - the topic type.P1 - the payload type.event - the events.
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
Copyright © 2012. All Rights Reserved.