org.axonframework.commandhandling.annotation
Class ConstructorCommandMessageHandler<T extends AggregateRoot>

java.lang.Object
  extended by org.axonframework.common.annotation.AbstractMessageHandler
      extended by org.axonframework.commandhandling.annotation.ConstructorCommandMessageHandler<T>
Type Parameters:
T - the type of aggregate this handler handles commands for
All Implemented Interfaces:
Comparable<AbstractMessageHandler>

public final class ConstructorCommandMessageHandler<T extends AggregateRoot>
extends AbstractMessageHandler

Command Handler that creates a new aggregate instance by invoking that aggregate's constructor.

Since:
1.2
Author:
Allard Buijze

Method Summary
static
<T extends AggregateRoot>
ConstructorCommandMessageHandler<T>
forConstructor(Constructor<T> constructor, ParameterResolverFactory parameterResolverFactory)
          Creates a ConstructorCommandMessageHandler for the given constructor.
<A extends Annotation>
A
getAnnotation(Class<A> annotationType)
          Returns the member-level annotation of given annotationType, or null if no such annotation is present.
 T invoke(Object target, Message message)
          Invokes this handler for the given target instance, using the given message as source object to provide parameter values.
 
Methods inherited from class org.axonframework.common.annotation.AbstractMessageHandler
compareTo, equals, findResolvers, getParameterValueResolvers, getPayloadType, hashCode, matches
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

forConstructor

public static <T extends AggregateRoot> ConstructorCommandMessageHandler<T> forConstructor(Constructor<T> constructor,
                                                                                           ParameterResolverFactory parameterResolverFactory)
Creates a ConstructorCommandMessageHandler for the given constructor.

Type Parameters:
T - The type of Aggregate created by the constructor
Parameters:
constructor - The constructor to wrap as a Handler
parameterResolverFactory - The strategy for resolving parameter values of handler methods
Returns:
ConstructorCommandMessageHandler
Throws:
UnsupportedHandlerException - when the given constructor is not suitable as a Handler

invoke

public T invoke(Object target,
                Message message)
                               throws InvocationTargetException,
                                      IllegalAccessException
Description copied from class: AbstractMessageHandler
Invokes this handler for the given target instance, using the given message as source object to provide parameter values.

Specified by:
invoke in class AbstractMessageHandler
Parameters:
target - The target instance to invoke the Handler on.
message - The message providing parameter values
Returns:
The result of the handler invocation
Throws:
InvocationTargetException - when the handler throws a checked exception
IllegalAccessException - if the SecurityManager refuses the handler invocation

getAnnotation

public <A extends Annotation> A getAnnotation(Class<A> annotationType)
Description copied from class: AbstractMessageHandler
Returns the member-level annotation of given annotationType, or null if no such annotation is present.

Specified by:
getAnnotation in class AbstractMessageHandler
Type Parameters:
A - The type of annotation to retrieve
Parameters:
annotationType - The type of annotation to retrieve
Returns:
the annotation instance, or null if no such annotation is present.


Copyright © 2010-2016. All Rights Reserved.