org.axonframework.test
Class FixtureResourceParameterResolverFactory

java.lang.Object
  extended by org.axonframework.test.FixtureResourceParameterResolverFactory
All Implemented Interfaces:
ParameterResolverFactory

public final class FixtureResourceParameterResolverFactory
extends Object
implements ParameterResolverFactory

ParameterResolverFactory implementation that is aware of test-specific use cases. It uses a ThreadLocal to keep track of injectable resources.

Although all access to this fixture should be done using the static accessor methods, creation of an instance is still possible to comply with the ServiceLoader specification.

Furthermore, this factory creates lazy parameter resolver, which mean that unsupported parameters are only detected when a specific handler is invoked. This ensures that only the resources that are actually used inside a test need to be configured.

Since:
2.1
Author:
Allard Buijze

Constructor Summary
FixtureResourceParameterResolverFactory()
           
 
Method Summary
static void clear()
          Clears the injectable resources registered to the current thread.
 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 void registerResource(Object injectableResource)
          Registers an additional resource for injection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixtureResourceParameterResolverFactory

public FixtureResourceParameterResolverFactory()
Method Detail

createInstance

public ParameterResolver createInstance(Annotation[] memberAnnotations,
                                        Class<?> parameterType,
                                        Annotation[] parameterAnnotations)
Description copied from interface: ParameterResolverFactory
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.

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

registerResource

public static void registerResource(Object injectableResource)
Registers an additional resource for injection

Parameters:
injectableResource - the resource to inject into handler methods

clear

public static void clear()
Clears the injectable resources registered to the current thread.



Copyright © 2010-2016. All Rights Reserved.