org.gcube.common.core.utils.events
Interface GCUBETopic

All Known Implementing Classes:
Events.GHNTopic, Events.SecurityTopic, GCUBEPluginManager.PluginTopic, GCUBEResource.ResourceTopic, GCUBEServiceContext.RILifetimeTopic, GCUBEServiceSecurityManager.LifetimeTopic, ISLocalPublisher.LocalProfileTopic, ISNotifier.NotificationTopic, Topic, Topic.LifetimeTopic

public interface GCUBETopic

A tagging interface for topics of GCUBEEvents handled by GCUBEProducers and consumed by GCUBEConsumers.

The interface may be implemented in different ways, two of which are worth illustrating. The simplest one is with a Java enum:

enum MyTopic implements GCUBETopic{TOPIC1,TOPIC2;...};

With an enum-based model, GCUBEProducers and GCUBEEvents cannot be constrained to, respectively, handle or be about only individual topics. Furthermore, the model does not support the dynamic definition of topics (though the lack of a static documentation for dynamic topics restricts their applicability).

A more general model maps instead different topics onto different and potentially empty classes, all derived from an abstract base class,e.g:

abstract class MyTopic implements GCUBETopic{};
class Topic1 extends MyTopic{}
class Topic2 extends MyTopic{}
...

The abstract root of this typically shallow hierarchy may then be used to constrain GCUBEProducers to operate against all the derived classes/topics. Equally, GCUBEProducers may operate over individual topics. New topics can be created dynamically through anonymous inner classes (but see note above). In this class-based model of topics, however, any two objects of any given class of the hierarchy model the same topic and thus GCUBEProducers expect them to be equated with suitable implementations of Object.equals(java.lang.Object) and Object.hashCode(), e.g.:

abstract class MyTopic implements GCUBETopic{
  public int hashCode() {
    return this.getClass().hashCode();
   }
  public boolean equals(Object obj) {
    return (obj.getClass() == this.getClass());
  }
};

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



Copyright © 2013. All Rights Reserved.