org.axonframework.common.annotation
Class ParameterResolverFactory

java.lang.Object
  extended by org.axonframework.common.annotation.ParameterResolverFactory
Direct Known Subclasses:
CurrentUnitOfWorkParameterResolverFactory, DefaultParameterResolverFactory, SimpleResourceParameterResolverFactory, SpringBeanParameterResolverFactory, TimestampParameterResolverFactory

public abstract class ParameterResolverFactory
extends Object

Abstract Factory that provides access to all ParameterResolverFactory implementations.

Application developers may provide custom ParameterResolverFactory implementations using the ServiceLoader mechanism. To do so, place a file called org.axonframework.common.annotation.ParameterResolverFactory in the META-INF/services folder. In this file, place the fully qualified class names of all available implementations.

The factory implementations must be public, non-abstract, have a default public constructor and extend the ParameterResolverFactory class.

Since:
2.0
Author:
Allard Buijze
See Also:
ServiceLoader, ServiceLoader.load(Class)

Constructor Summary
ParameterResolverFactory()
           
 
Method Summary
protected abstract  ParameterResolver createInstance(Annotation[] memberAnnotations, Class<?> parameterType, Annotation[] parameterAnnotations)
          If available, creates a ParameterResolver instance that can provide a parameter of type parameterType for a given message.
static ParameterResolver createPayloadResolver(Class<?> parameterType)
          Creates a ParameterResolver that resolves the payload of a given message when it is assignable to the given parameterType.
static ParameterResolver findParameterResolver(Annotation[] memberAnnotations, Class<?> parameterType, Annotation[] parameterAnnotations, boolean isPayloadParameter)
          Iterates over all known ParameterResolverFactory implementations to create a ParameterResolver instance for the given parameters.
static void registerFactory(ParameterResolverFactory factory)
          Registers a ParameterResolverFactory at runtime.
abstract  boolean supportsPayloadResolution()
          Indicates whether this resolver may be used to resolve the payload parameter of an annotated handler method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParameterResolverFactory

public ParameterResolverFactory()
Method Detail

registerFactory

public static void registerFactory(ParameterResolverFactory factory)
Registers a ParameterResolverFactory at runtime. Annotated handlers that have already been inspected will not be able to use the newly added factory.

Parameters:
factory - The factory to register

findParameterResolver

public static ParameterResolver findParameterResolver(Annotation[] memberAnnotations,
                                                      Class<?> parameterType,
                                                      Annotation[] parameterAnnotations,
                                                      boolean isPayloadParameter)
Iterates over all known ParameterResolverFactory implementations to create a ParameterResolver instance for the given parameters. The ParameterResolverFactories invoked in the order they are found on the classpath. The first to provide a suitable resolver will be used. The DefaultParameterResolverFactory is always the last one to be inspected.

Parameters:
memberAnnotations - annotations placed on the member (e.g. method)
parameterType - the parameter type to find a resolver for
parameterAnnotations - annotations places on the parameter
isPayloadParameter - whether the parameter to resolve represents a payload parameter
Returns:
a suitable ParameterResolver, or null if none is found

createPayloadResolver

public static ParameterResolver createPayloadResolver(Class<?> parameterType)
Creates a ParameterResolver that resolves the payload of a given message when it is assignable to the given parameterType.

Parameters:
parameterType - The type of parameter to create a resolver for
Returns:
a ParameterResolver that resolves the payload of a given message

supportsPayloadResolution

public abstract boolean supportsPayloadResolution()
Indicates whether this resolver may be used to resolve the payload parameter of an annotated handler method.

Returns:
whether this factory provides Parameter Resolvers that support payload parameters

createInstance

protected abstract ParameterResolver createInstance(Annotation[] memberAnnotations,
                                                    Class<?> parameterType,
                                                    Annotation[] parameterAnnotations)
If available, creates a ParameterResolver instance that can provide a parameter of type parameterType for a given message.

If the ParameterResolverFactory cannot provide a suitable ParameterResolver, returns null.

Parameters:
memberAnnotations - annotations placed on the member (e.g. method)
parameterType - the parameter type to find a resolver for
parameterAnnotations - annotations places on the parameter
Returns:
a suitable ParameterResolver, or null if none is found


Copyright © 2010-2012. All Rights Reserved.