org.axonframework.eventhandling
Class AnnotationClusterSelector

java.lang.Object
  extended by org.axonframework.eventhandling.AbstractClusterSelector
      extended by org.axonframework.eventhandling.AnnotationClusterSelector
All Implemented Interfaces:
ClusterSelector

public class AnnotationClusterSelector
extends AbstractClusterSelector

Cluster Selector implementation that selects a cluster if an Annotation is present on the Event Listener class.

Since:
2.0
Author:
Allard Buijze

Constructor Summary
AnnotationClusterSelector(Class<? extends Annotation> annotationType, Cluster cluster)
          Initializes a ClusterSelector instance that selects the given cluster for Event Listeners that are annotated with the given annotationType.
AnnotationClusterSelector(Class<? extends Annotation> annotationType, Cluster cluster, boolean inspectSuperClasses)
          Initializes a ClusterSelector instance that selects the given cluster for Event Listeners that are annotated with the given annotationType.
 
Method Summary
protected  Cluster doSelectCluster(EventListener eventListener, Class<?> listenerType)
          Select a cluster for the given eventListener, which has the actual class listenerType.
 
Methods inherited from class org.axonframework.eventhandling.AbstractClusterSelector
selectCluster
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationClusterSelector

public AnnotationClusterSelector(Class<? extends Annotation> annotationType,
                                 Cluster cluster)
Initializes a ClusterSelector instance that selects the given cluster for Event Listeners that are annotated with the given annotationType.

Note that this instance will not search superclasses for annotations by default. If annotation on classes should also reflect on their subclasses, make sure to use the @Inherited Meta-Annotation, or use AnnotationClusterSelector(Class, Cluster, boolean).

Parameters:
annotationType - The type of annotation to find on the Event Listeners
cluster - The cluster to select if the annotation was found

AnnotationClusterSelector

public AnnotationClusterSelector(Class<? extends Annotation> annotationType,
                                 Cluster cluster,
                                 boolean inspectSuperClasses)
Initializes a ClusterSelector instance that selects the given cluster for Event Listeners that are annotated with the given annotationType. If inspectSuperClasses is true, super classes will be searched for the annotation, regardless if the annotation is marked as @Inherited

Parameters:
annotationType - The type of annotation to find on the Event Listeners
cluster - The cluster to select if the annotation was found
inspectSuperClasses - Whether or not to inspect super classes as well
Method Detail

doSelectCluster

protected Cluster doSelectCluster(EventListener eventListener,
                                  Class<?> listenerType)
Description copied from class: AbstractClusterSelector
Select a cluster for the given eventListener, which has the actual class listenerType. Note that the given listenerType does not have to be assignable to EventListener, as it is possible that the eventListener acts as a proxy to an instance of listenerType.

Specified by:
doSelectCluster in class AbstractClusterSelector
Parameters:
eventListener - The listener instance handling the events, possibly a proxy
listenerType - The actual type of the Event Listener
Returns:
the cluster to assign the Event Listener to


Copyright © 2010-2016. All Rights Reserved.