org.mule.config.transformer
Class AbstractAnnotatedTransformerArgumentResolver

java.lang.Object
  extended by org.mule.config.transformer.AbstractAnnotatedTransformerArgumentResolver
All Implemented Interfaces:
Disposable, TransformerArgumentResolver
Direct Known Subclasses:
JAXBContextResolver, JsonMapperResolver

public abstract class AbstractAnnotatedTransformerArgumentResolver
extends Object
implements TransformerArgumentResolver, Disposable

An abstract resolver that can be extend to resolve/create an object based on Annotated classes. These classes can be scanned and used to create the context. Typically this class will be used to create resolvers for binding frameworks where the data type classes are annotated with binding information.


Field Summary
static String[] ignoredPackages
           
protected  Log logger
          logger used by this class
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Constructor Summary
AbstractAnnotatedTransformerArgumentResolver()
           
 
Method Summary
protected abstract  Object createArgument(Class<?> annotatedType, MuleContext muleContext)
          If the resolver cannot locate the required object of type getArgumentClass() this method will be invoked an instance of the object.
 void dispose()
          A lifecycle method where implementor should free up any resources.
protected  boolean findAnnotation(Class annotatedType)
           
protected abstract  String getAnnotationsPackageName()
          This resolver scans a class for annotations in this package.
protected abstract  Class<?> getArgumentClass()
          The object type that this resolver will discover or create
 Set<Class> getMatchingClasses()
           
 Set<Class> getNonMatchingClasses()
           
protected  boolean isNonMatching(DataType source, DataType result)
           
<T> T
resolve(Class<T> type, DataType source, DataType result, MuleContext context)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ignoredPackages

public static final String[] ignoredPackages

logger

protected final transient Log logger
logger used by this class

Constructor Detail

AbstractAnnotatedTransformerArgumentResolver

public AbstractAnnotatedTransformerArgumentResolver()
Method Detail

resolve

public <T> T resolve(Class<T> type,
                     DataType source,
                     DataType result,
                     MuleContext context)
          throws Exception
Specified by:
resolve in interface TransformerArgumentResolver
Throws:
Exception

findAnnotation

protected boolean findAnnotation(Class annotatedType)
                          throws IOException
Throws:
IOException

isNonMatching

protected boolean isNonMatching(DataType source,
                                DataType result)

dispose

public void dispose()
Description copied from interface: Disposable
A lifecycle method where implementor should free up any resources. If an exception is thrown it should just be logged and processing should continue. This method should not throw Runtime exceptions.

Specified by:
dispose in interface Disposable

getMatchingClasses

public Set<Class> getMatchingClasses()

getNonMatchingClasses

public Set<Class> getNonMatchingClasses()

getArgumentClass

protected abstract Class<?> getArgumentClass()
The object type that this resolver will discover or create

Returns:
The object type that this resolver will discover or create

createArgument

protected abstract Object createArgument(Class<?> annotatedType,
                                         MuleContext muleContext)
                                  throws Exception
If the resolver cannot locate the required object of type getArgumentClass() this method will be invoked an instance of the object.

Parameters:
annotatedType - the annotated object that was matched
muleContext - the current Mule context.
Returns:
a new instance of the object being resolved. This method may also retain a shared instance and possible add configuration to the instance based on this invocation
Throws:
Exception - if the object cannot be created

getAnnotationsPackageName

protected abstract String getAnnotationsPackageName()
This resolver scans a class for annotations in this package. Note this behaviour can be changed by overloading the findAnnotation(Class) method and search based on your own criteria

Returns:
the package of the annotation(s) to scan for


Copyright © 2003-2012 MuleSoft, Inc.. All Rights Reserved.