org.axonframework.saga.annotation
Class AbstractAnnotatedSaga

java.lang.Object
  extended by org.axonframework.saga.annotation.AbstractAnnotatedSaga
All Implemented Interfaces:
Serializable, Saga
Direct Known Subclasses:
ToDoSaga

public abstract class AbstractAnnotatedSaga
extends Object
implements Saga, Serializable

Implementation of the interface that delegates incoming events to @SagaEventHandler annotated methods.

Since:
0.7
Author:
Allard Buijze
See Also:
Serialized Form

Constructor Summary
protected AbstractAnnotatedSaga()
          Initialize the saga with a random identifier.
protected AbstractAnnotatedSaga(String identifier)
          Initialize the saga with the given identifier.
 
Method Summary
protected  void associateWith(AssociationValue property)
          Registers a AssociationValue with the given saga.
protected  void associateWith(String key, Number value)
          Registers a AssociationValue with the given saga.
protected  void associateWith(String key, String value)
          Registers a AssociationValue with the given saga.
protected  void end()
          Marks the saga as ended.
 AssociationValues getAssociationValues()
          Returns a view on the Association Values for this saga instance.
 String getSagaIdentifier()
          Returns the unique identifier of this saga.
 void handle(EventMessage event)
          Handle the given event.
 boolean isActive()
          Indicates whether or not this saga is active.
protected  void registerParameterResolverFactory(ParameterResolverFactory parameterResolverFactory)
          Sets the ParameterResolverFactory for this instance to use.
protected  void removeAssociationWith(AssociationValue property)
          Removes the given association from this Saga.
protected  void removeAssociationWith(String key, Number value)
          Removes the given association from this Saga.
protected  void removeAssociationWith(String key, String value)
          Removes the given association from this Saga.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractAnnotatedSaga

protected AbstractAnnotatedSaga()
Initialize the saga with a random identifier. The identifier used is provided by IdentifierFactory.generateIdentifier(), which defaults to a randomly generated UUID.


AbstractAnnotatedSaga

protected AbstractAnnotatedSaga(String identifier)
Initialize the saga with the given identifier.

Parameters:
identifier - the identifier to initialize the saga with.
Method Detail

getSagaIdentifier

public String getSagaIdentifier()
Description copied from interface: Saga
Returns the unique identifier of this saga.

Specified by:
getSagaIdentifier in interface Saga
Returns:
the unique identifier of this saga

getAssociationValues

public AssociationValues getAssociationValues()
Description copied from interface: Saga
Returns a view on the Association Values for this saga instance. The returned instance is mutable.

Specified by:
getAssociationValues in interface Saga
Returns:
a view on the Association Values for this saga instance

handle

public final void handle(EventMessage event)
Description copied from interface: Saga
Handle the given event. The actual result of processing depends on the implementation of the saga.

Implementations are highly discouraged from throwing exceptions.

Specified by:
handle in interface Saga
Parameters:
event - the event to handle

registerParameterResolverFactory

protected void registerParameterResolverFactory(ParameterResolverFactory parameterResolverFactory)
Sets the ParameterResolverFactory for this instance to use. This is typically set by the SagaManager that will manage the lifecycle of this instance.

Parameters:
parameterResolverFactory - The parameterResolverFactory for this instance to use

isActive

public boolean isActive()
Description copied from interface: Saga
Indicates whether or not this saga is active. A Saga is active when its life cycle has not been ended.

Specified by:
isActive in interface Saga
Returns:
true if this saga is active, false otherwise.

end

protected void end()
Marks the saga as ended. Ended saga's may be cleaned up by the repository when they are committed.


associateWith

protected void associateWith(AssociationValue property)
Registers a AssociationValue with the given saga. When the saga is committed, it can be found using the registered property.

Parameters:
property - The value to associate this saga with.

associateWith

protected void associateWith(String key,
                             String value)
Registers a AssociationValue with the given saga. When the saga is committed, it can be found using the registered property.

Parameters:
key - The key of the association value to associate this saga with.
value - The value of the association value to associate this saga with.

associateWith

protected void associateWith(String key,
                             Number value)
Registers a AssociationValue with the given saga. When the saga is committed, it can be found using the registered property.

Parameters:
key - The key of the association value to associate this saga with.
value - The value of the association value to associate this saga with.

removeAssociationWith

protected void removeAssociationWith(AssociationValue property)
Removes the given association from this Saga. When the saga is committed, it can no longer be found using the given association. If the given property wasn't registered with the saga, nothing happens.

Parameters:
property - the association value to remove from the saga.

removeAssociationWith

protected void removeAssociationWith(String key,
                                     String value)
Removes the given association from this Saga. When the saga is committed, it can no longer be found using the given association value. If the given saga wasn't associated with given values, nothing happens.

Parameters:
key - The key of the association value to remove from this saga.
value - The value of the association value to remove from this saga.

removeAssociationWith

protected void removeAssociationWith(String key,
                                     Number value)
Removes the given association from this Saga. When the saga is committed, it can no longer be found using the given association value. If the given saga wasn't associated with given values, nothing happens.

Parameters:
key - The key of the association value to remove from this saga.
value - The value of the association value to remove from this saga.


Copyright © 2010-2016. All Rights Reserved.