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, String associationPropertyName, Property 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.
 String getName()
          Returns the name of the handler.
 int hashCode()
           
 void invoke(Object target, EventMessage message)
          Invoke a handler on given target for given message.
 boolean isEndingHandler()
          Indicates whether this handler is one that ends the Saga lifecycle
 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,
                                   String associationPropertyName,
                                   Property 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.

isEndingHandler

public boolean isEndingHandler()
Indicates whether this handler is one that ends the Saga lifecycle

Returns:
true if the Saga lifecycle ends unconditionally after this call, 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

invoke

public void invoke(Object target,
                   EventMessage message)
Invoke a handler on given target for given message.

Parameters:
target - The instance to invoke a method on
message - The message to use to resolve the parameters of the handler to invoke

getName

public String getName()
Returns the name of the handler.

Returns:
the name of the handler


Copyright © 2010-2016. All Rights Reserved.