org.axonframework.saga.annotation
Class SagaMethodMessageHandler

java.lang.Object
  extended by org.axonframework.saga.annotation.SagaMethodMessageHandler
All Implemented Interfaces:
Comparable<SagaMethodMessageHandler>

public class SagaMethodMessageHandler
extends Object
implements Comparable<SagaMethodMessageHandler>

A data holder containing information of SagaEventHandler annotated methods.

Since:
2.0
Author:
Allard Buijze

Constructor Summary
protected SagaMethodMessageHandler(SagaCreationPolicy creationPolicy, MethodMessageHandler handler, String associationKey, Method associationProperty)
          Creates a SagaMethodMessageHandler.
 
Method Summary
 int compareTo(SagaMethodMessageHandler o)
           
 boolean equals(Object o)
           
 AssociationValue getAssociationValue(EventMessage eventMessage)
          The AssociationValue to find the saga instance with, or null if no AssociationValue can be found on the given eventMessage.
 SagaCreationPolicy getCreationPolicy()
          Returns the creation policy of the inspected method.
static SagaMethodMessageHandler getInstance(MethodMessageHandler methodHandler)
          Create a SagaMethodMessageHandler for the given methodHandler.
 int hashCode()
           
 boolean isHandlerAvailable()
          Indicates whether the inspected method is an Event Handler.
 boolean matches(EventMessage message)
          Indicates whether this Handler is suitable for the given message.
static SagaMethodMessageHandler noHandler()
          Returns a SagaMethodMessageHandler indicating that a inspected method is *not* a SagaEventHandler.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SagaMethodMessageHandler

protected SagaMethodMessageHandler(SagaCreationPolicy creationPolicy,
                                   MethodMessageHandler handler,
                                   String associationKey,
                                   Method associationProperty)
Creates a SagaMethodMessageHandler.

Parameters:
creationPolicy - The creation policy for the handlerMethod
handler - The handler for the event
associationKey - The association key configured for this handler
associationProperty - The association property configured for this handler
Method Detail

noHandler

public static SagaMethodMessageHandler noHandler()
Returns a SagaMethodMessageHandler indicating that a inspected method is *not* a SagaEventHandler.

Returns:
a SagaMethodMessageHandler indicating that a inspected method is *not* a SagaEventHandler

getInstance

public static SagaMethodMessageHandler getInstance(MethodMessageHandler methodHandler)
Create a SagaMethodMessageHandler for the given methodHandler. The SagaMethodMessageHandler add information specific to the behavior of Sagas, such as the association value and creation policy.

Parameters:
methodHandler - The handler for incoming events
Returns:
a SagaMethodMessageHandler for the handler

isHandlerAvailable

public boolean isHandlerAvailable()
Indicates whether the inspected method is an Event Handler.

Returns:
true if the saga has a handler

getAssociationValue

public AssociationValue getAssociationValue(EventMessage eventMessage)
The AssociationValue to find the saga instance with, or null if no AssociationValue can be found on the given eventMessage.

Parameters:
eventMessage - The event message containing the value of the association
Returns:
the AssociationValue to find the saga instance with, or null if none found

getCreationPolicy

public SagaCreationPolicy getCreationPolicy()
Returns the creation policy of the inspected method.

Returns:
the creation policy of the inspected method

matches

public boolean matches(EventMessage message)
Indicates whether this Handler is suitable for the given message.

Parameters:
message - The message to inspect
Returns:
true if this handler can handle the message, otherwise false.

compareTo

public int compareTo(SagaMethodMessageHandler o)
Specified by:
compareTo in interface Comparable<SagaMethodMessageHandler>

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2010-2012. All Rights Reserved.