TOPIC - the type of the event topics.PAYLOAD - the type of the event payload.public class GCUBEProducer<TOPIC extends GCUBETopic,PAYLOAD> extends Object
GCUBEConsumers
which have previously subscribed with it of the occurrence of GCUBEEvents about given GCUBETopics
and carrying given payloads.
Through type instantiation, producers may be constrained to handle only GCUBEEvents about given topics and/or
carrying given payloads. For example:
a GCUBEProducer<MyTopic,Object> handles only events
about MyTopics but carrying any payload.
a GCUBEProducer<GCUBETopic,MyPayload> handles events about any GCUBETopic as long
as they carry MyPayloads.
a GCUBEProducer<MyTopic,MyPayload> handles only events about MyTopics which
carry MyPayloads.
Type constraints may be specified when the producer is created, e.g.:
GCUBEProducer<MyTopic,MyPayload> myProducer = new GCUBEProducer<MyTopic,MyPayload>();
or else by subclassing, e.g.
public class MyProducer extends GCUBEProducer<MyTopic,MyPayload> {...}
...
MyProducer myProducer = new MyProducer();
GCUBEEvent,
GCUBETopic,
GCUBEConsumer| Modifier and Type | Field and Description |
|---|---|
protected static List<GCUBEProducer<?,?>> |
classExtent
The class extent.
|
protected Map<TOPIC,List<GCUBEConsumer<TOPIC,PAYLOAD>>> |
consumers
Subscribed consumers, indexed by topic.
|
protected Map<TOPIC,List<GCUBEEvent<? extends TOPIC,? extends PAYLOAD>>> |
events
Notified events, indexed by topic.
|
protected GCUBELog |
logger
Object logger.
|
protected static org.gcube.common.core.utils.events.GCUBEProducer.EventSweeper |
sweeper
The sweeper scheduler
|
| Constructor and Description |
|---|
GCUBEProducer()
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected List<GCUBEConsumer<TOPIC,PAYLOAD>> |
getConsumers(TOPIC topic)
Used internally to return all the consumers subscribed for a given topic.
|
protected List<GCUBEEvent<? extends TOPIC,? extends PAYLOAD>> |
getEvents(TOPIC topic)
Used internally to return all the events recorded for a given topic.
|
<T1 extends TOPIC,P1 extends PAYLOAD> |
notify(T1 topic,
GCUBEEvent<T1,P1>... events)
Notifies consumers of the occurrence of one or more events about a topic for which they subscribed.
|
protected <T1 extends TOPIC,P1 extends PAYLOAD> |
notifyConsumer(GCUBEConsumer<TOPIC,PAYLOAD> consumer,
GCUBEEvent<T1,P1>... events)
Notifies asynchronously a given consumer of the occurrence of one or more events.
|
void |
subscribe(GCUBEConsumer<TOPIC,PAYLOAD> consumer,
TOPIC... topics)
Subscribes a consumer to events about one or more topics.
|
void |
unsubscribe(GCUBEConsumer<TOPIC,PAYLOAD> consumer,
TOPIC... topics)
Unsubscribes a consumer from events about one or more topics.
|
protected GCUBELog logger
protected Map<TOPIC extends GCUBETopic,List<GCUBEConsumer<TOPIC extends GCUBETopic,PAYLOAD>>> consumers
protected Map<TOPIC extends GCUBETopic,List<GCUBEEvent<? extends TOPIC extends GCUBETopic,? extends PAYLOAD>>> events
protected static List<GCUBEProducer<?,?>> classExtent
protected static org.gcube.common.core.utils.events.GCUBEProducer.EventSweeper sweeper
protected List<GCUBEConsumer<TOPIC,PAYLOAD>> getConsumers(TOPIC topic)
topic - the topic.protected List<GCUBEEvent<? extends TOPIC,? extends PAYLOAD>> getEvents(TOPIC topic)
topic - the topic.public void subscribe(GCUBEConsumer<TOPIC,PAYLOAD> consumer, TOPIC... topics) throws IllegalArgumentException
TOPIC - the topic type.PAYLOAD - the event payload type.consumer - the consumer.topics - the topics.IllegalArgumentException - if invoked with no topics.public void unsubscribe(GCUBEConsumer<TOPIC,PAYLOAD> consumer, TOPIC... topics) throws IllegalArgumentException
TOPIC - the topic type.PAYLOAD - the event payload type.consumer - the consumer.topics - the topics.IllegalArgumentException - if invoked with null or empty inputs.protected <T1 extends TOPIC,P1 extends PAYLOAD> void notifyConsumer(GCUBEConsumer<TOPIC,PAYLOAD> consumer, GCUBEEvent<T1,P1>... events)
TOPIC - the topic type.PAYLOAD - the event payload type.consumer - the consumer.events - the events.public <T1 extends TOPIC,P1 extends PAYLOAD> void notify(T1 topic, GCUBEEvent<T1,P1>... events) throws IllegalArgumentException
T1 - the topic type.P1 - the payload type.topic - the topic.events - the events.IllegalArgumentException - if invoked with null or empty inputs.Copyright © 2015. All Rights Reserved.