org.axonframework.commandhandling.distributed
Class AbstractRoutingStrategy

java.lang.Object
  extended by org.axonframework.commandhandling.distributed.AbstractRoutingStrategy
All Implemented Interfaces:
RoutingStrategy
Direct Known Subclasses:
AnnotationRoutingStrategy, MetaDataRoutingStrategy

public abstract class AbstractRoutingStrategy
extends Object
implements RoutingStrategy

Abstract implementation of the RoutingStrategy interface that uses a policy to prescribe what happens when a routing cannot be resolved.

Since:
2.0
Author:
Allard Buijze

Constructor Summary
AbstractRoutingStrategy(UnresolvedRoutingKeyPolicy unresolvedRoutingKeyPolicy)
          Initializes the strategy using given unresolvedRoutingKeyPolicy prescribing what happens when a routing key cannot be resolved.
 
Method Summary
protected abstract  String doResolveRoutingKey(CommandMessage<?> command)
          Resolve the Routing Key for the given command.
 String getRoutingKey(CommandMessage<?> command)
          Generates a routing key for the given command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRoutingStrategy

public AbstractRoutingStrategy(UnresolvedRoutingKeyPolicy unresolvedRoutingKeyPolicy)
Initializes the strategy using given unresolvedRoutingKeyPolicy prescribing what happens when a routing key cannot be resolved.

Parameters:
unresolvedRoutingKeyPolicy - The policy for unresolved routing keys.
Method Detail

getRoutingKey

public String getRoutingKey(CommandMessage<?> command)
Description copied from interface: RoutingStrategy
Generates a routing key for the given command. Commands that should be handled by the same segment, should result in the same routing key.

Specified by:
getRoutingKey in interface RoutingStrategy
Parameters:
command - the command to create a routing key for
Returns:
the routing key for the command

doResolveRoutingKey

protected abstract String doResolveRoutingKey(CommandMessage<?> command)
Resolve the Routing Key for the given command.

Parameters:
command - The command to resolve the routing key for
Returns:
the String representing the Routing Key, or null if unresolved.


Copyright © 2010-2016. All Rights Reserved.