org.axonframework.eventhandling
Class AbstractCluster

java.lang.Object
  extended by org.axonframework.eventhandling.AbstractCluster
All Implemented Interfaces:
Cluster
Direct Known Subclasses:
AsynchronousCluster, SimpleCluster

public abstract class AbstractCluster
extends Object
implements Cluster

Abstract Cluster implementation that keeps track of Cluster members (EventListeners). This implementation is thread-safe. The getMembers() method returns a read-only runtime view of the members in the cluster.

Since:
1.2
Author:
Allard Buijze

Constructor Summary
protected AbstractCluster(String name)
          Initializes the cluster with given name.
 
Method Summary
 Set<EventListener> getMembers()
          Returns a read-only view on the members in the cluster.
 ClusterMetaData getMetaData()
          Returns the MetaData of this Cluster.
 String getName()
          Returns the name of this cluster.
 void subscribe(EventListener eventListener)
          Subscribe the given eventListener to this cluster.
 void unsubscribe(EventListener eventListener)
          Unsubscribes the given eventListener from this cluster.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.axonframework.eventhandling.Cluster
publish
 

Constructor Detail

AbstractCluster

protected AbstractCluster(String name)
Initializes the cluster with given name.

Parameters:
name - The name of this cluster
Method Detail

getName

public String getName()
Description copied from interface: Cluster
Returns the name of this cluster. This name is used to detect distributed instances of the same cluster. Multiple instances referring to the same logical cluster (on different JVM's) must have the same name.

Specified by:
getName in interface Cluster
Returns:
the name of this cluster

subscribe

public void subscribe(EventListener eventListener)
Description copied from interface: Cluster
Subscribe the given eventListener to this cluster. If the listener is already subscribed, nothing happens.

While the Event Listeners is subscribed, it will receive all messages published to the cluster.

Specified by:
subscribe in interface Cluster
Parameters:
eventListener - the Event Listener instance to subscribe

unsubscribe

public void unsubscribe(EventListener eventListener)
Description copied from interface: Cluster
Unsubscribes the given eventListener from this cluster. If the listener is already unsubscribed, or was never subscribed, nothing happens.

Specified by:
unsubscribe in interface Cluster
Parameters:
eventListener - the Event Listener instance to unsubscribe

getMetaData

public ClusterMetaData getMetaData()
Description copied from interface: Cluster
Returns the MetaData of this Cluster.

Specified by:
getMetaData in interface Cluster
Returns:
the MetaData of this Cluster

getMembers

public Set<EventListener> getMembers()
Returns a read-only view on the members in the cluster. This view may be updated by the Cluster when members subscribe or unsubscribe. Cluster implementations may also return the view representing the state at the moment this method is invoked.

This implementation returns a real-time view on the actual members, which changes when members join or leave the cluster. Iterators created from the returned set are thread-safe and iterate over the members available at the time the iterator was created. The iterator does not allow the Iterator.remove() method to be invoked.

Specified by:
getMembers in interface Cluster
Returns:
a view of the members of this cluster


Copyright © 2010-2012. All Rights Reserved.