|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.axonframework.eventhandling.AbstractClusterSelector org.axonframework.eventhandling.ClassNamePrefixClusterSelector
public class ClassNamePrefixClusterSelector
ClusterSelector implementation that chooses a Cluster based on a mapping of the Listener's Class Name. It maps a prefix to a Cluster. When two prefixes match the same class, the Cluster mapped to the longest prefix is chosen.
For example, consider the following mappings:org.axonframework -> cluster1 com. -> cluster2 com.somecompany -> cluster3A class named
com.somecompany.SomeListener
will map to cluster3
as it is mapped to a more
specific prefix. This implementation uses String.startsWith(String)
to evaluate a match.
Note that the name of the class used is the name of the class implementing the EventListener
interface.
If a listener implements the EventListenerProxy
interface, the value of the EventListenerProxy.getTargetType()
is used. Annotated Event Listeners will always
have the actual annotated class name used.
Constructor Summary | |
---|---|
ClassNamePrefixClusterSelector(Map<String,Cluster> mappings)
Initializes the ClassNamePrefixClusterSelector using the given mappings . |
|
ClassNamePrefixClusterSelector(Map<String,Cluster> mappings,
Cluster defaultCluster)
Initializes the ClassNamePrefixClusterSelector using the given mappings . |
|
ClassNamePrefixClusterSelector(String prefix,
Cluster cluster)
Initializes the ClassNamePrefixClusterSelector where classes starting with the given prefix will be
mapped to the given cluster . |
Method Summary | |
---|---|
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 |
---|
public ClassNamePrefixClusterSelector(String prefix, Cluster cluster)
prefix
will be
mapped to the given cluster
.
This method is identical to ClassNamePrefixClusterSelector(java.util.Map)
with only a single mapping.
prefix
- The prefix of the fully qualified classname to match againstcluster
- The cluster to choose if a match is foundpublic ClassNamePrefixClusterSelector(Map<String,Cluster> mappings)
mappings
. If a name does not have a
prefix defined, the Cluster Selector returns null
.
mappings
- the mappings defining a cluster for each Class Name prefixpublic ClassNamePrefixClusterSelector(Map<String,Cluster> mappings, Cluster defaultCluster)
mappings
. If a name does not have a
prefix defined, the Cluster Selector returns the given defaultCluster
.
mappings
- the mappings defining a cluster for each Class Name prefixdefaultCluster
- The cluster to use when no mapping is presentMethod Detail |
---|
public Cluster doSelectCluster(EventListener eventListener, Class<?> listenerType)
AbstractClusterSelector
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
.
doSelectCluster
in class AbstractClusterSelector
eventListener
- The listener instance handling the events, possibly a proxylistenerType
- The actual type of the Event Listener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |