org.gcube.common.core.utils.events
Class GCUBEEvent<T extends GCUBETopic,P>

java.lang.Object
  extended by org.gcube.common.core.utils.events.GCUBEEvent<T,P>
Type Parameters:
T - the type of the event topic.
P - the type of the event payload.
Direct Known Subclasses:
Event, Events.GHNEvent, Events.SecurityEvent, GCUBEPluginManager.PluginEvent, GCUBEResource.ResourceEvent, GCUBEServiceContext.RILifetimeEvent, GCUBEServiceSecurityManager.LifetimeEvent, ISLocalPublisher.LocalProfileEvent, ISNotifier.NotificationEvent

public class GCUBEEvent<T extends GCUBETopic,P>
extends Object

A base implementation for events handled by GCUBEProducers and consumed by GCUBEConsumers. An event is about a GCUBETopic, carries a payload, has a creation timestamp, and is handled by a producer.

Through type instantiation, events may be constrained to be about GCUBETopics and/or carry given payloads. For example:

a GCUBEEvent<MyTopic,Object> is about a MyTopic but can carry any payload.
a GCUBEEvent<GCUBETopic,MyPayload> is about any GCUBETopic but carries a MyPayload.
a GCUBEEvent<MyTopic,MyPayload> is about a MyTopic and carries a MyPayload.

Type constraints may be specified when the event is created, e.g.:

GCUBEEvent<MyTopic,MyPayload> myEvent = new GCUBEEvent<MyTopic,MyPayload>();

or else by subclassing, e.g.

public class MyEvent extends GCUBEEvent<MyTopic,MyPayload> {...}
...
MyEvent myEvent = new MyEvent();

Author:
Fabio Simeoni (University of Strathclyde)
See Also:
GCUBETopic, GCUBEProducer, GCUBEConsumer

Field Summary
protected  P payload
          The payload of the event.
protected  GCUBEProducer<? super T,? super P> producer
          The producer of the event.
protected  Calendar timeStamp
          The creation timestamp of the event.
protected  T topic
          The topic of the event.
 
Constructor Summary
GCUBEEvent()
           
 
Method Summary
 P getPayload()
          Returns the payload of the event.
 GCUBEProducer<? super T,? super P> getProducer()
          Returns the producer which handled the event.
 Calendar getTimeStamp()
          Returns the timestamp of the event.
 T getTopic()
          Returns the topic of the event.
 boolean isExpired(Calendar time)
          Indicates whether the event has expired at a given time (typically the current time).
 void setPayload(P payload)
          Sets the payload of the event.
protected  void setProducer(GCUBEProducer<? super T,? super P> producer)
          Sets the producer which handles the event.
protected  void setTopic(T topic)
          Sets the topic of the event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timeStamp

protected final Calendar timeStamp
The creation timestamp of the event.


topic

protected T extends GCUBETopic topic
The topic of the event.


payload

protected P payload
The payload of the event.


producer

protected GCUBEProducer<? super T extends GCUBETopic,? super P> producer
The producer of the event.

Constructor Detail

GCUBEEvent

public GCUBEEvent()
Method Detail

setTopic

protected void setTopic(T topic)
Sets the topic of the event.

Parameters:
topic - the topic.

getTopic

public T getTopic()
Returns the topic of the event.

Returns:
the topic.

getPayload

public P getPayload()
Returns the payload of the event.

Returns:
the payload.

setPayload

public void setPayload(P payload)
Sets the payload of the event.

Parameters:
payload -

getProducer

public GCUBEProducer<? super T,? super P> getProducer()
Returns the producer which handled the event.

Returns:
the producer.

setProducer

protected void setProducer(GCUBEProducer<? super T,? super P> producer)
Sets the producer which handles the event.

Parameters:
producer - the producer.

getTimeStamp

public Calendar getTimeStamp()
Returns the timestamp of the event.

Returns:
the timestamp.

isExpired

public boolean isExpired(Calendar time)
Indicates whether the event has expired at a given time (typically the current time).

Parameters:
time - the time.
Returns:
true if it has, false otherwise.


Copyright © 2013. All Rights Reserved.