Class TypeBasedTransformerResolver

  extended by org.mule.registry.TypeBasedTransformerResolver
All Implemented Interfaces:
MuleContextAware, Disposable, Initialisable, TransformerResolver

public class TypeBasedTransformerResolver
extends Object
implements TransformerResolver, MuleContextAware, Disposable, Initialisable

Will discover transformers based on type information only. It looks for transformers that support the source and result types passed into the method. This resolver only resolves on the first source type, which is the way transformer resolution working in Mule 2.x.

Nested Class Summary
Nested classes/interfaces inherited from interface org.mule.api.registry.TransformerResolver
Field Summary
protected  Map<String,Transformer> exactTransformerCache
protected  TransformerResolver graphTransformerResolver
protected  Log logger
          logger used by this class
Fields inherited from interface org.mule.api.lifecycle.Disposable
Fields inherited from interface org.mule.api.lifecycle.Initialisable
Constructor Summary
Method Summary
 void dispose()
          A lifecycle method where implementor should free up any resources.
protected  Transformer getNearestTransformerMatch(List<Transformer> trans, Class input, Class output)
 void initialise()
          Method used to perform any initialisation work.
 Transformer resolve(DataType source, DataType result)
          Responsible for finding a transformer with the given criteria.
 void setMuleContext(MuleContext context)
 void transformerChange(Transformer transformer, TransformerResolver.RegistryAction registryAction)
          A callback that is called when a transformer is registered or unregistered from the registry.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


protected final transient Log logger
logger used by this class


protected Map<String,Transformer> exactTransformerCache


protected TransformerResolver graphTransformerResolver
Constructor Detail


public TypeBasedTransformerResolver()
Method Detail


public void setMuleContext(MuleContext context)
Specified by:
setMuleContext in interface MuleContextAware


public void initialise()
                throws InitialisationException
Description copied from interface: Initialisable
Method used to perform any initialisation work. If a fatal error occurs during initialisation an InitialisationException should be thrown, causing the Mule instance to shutdown. If the error is recoverable, say by retrying to connect, a RecoverableException should be thrown. There is no guarantee that by throwing a Recoverable exception that the Mule instance will not shut down.

Specified by:
initialise in interface Initialisable
InitialisationException - if a fatal error occurs causing the Mule instance to shutdown
RecoverableException - if an error occurs that can be recovered from


public Transformer resolve(DataType source,
                           DataType result)
                    throws ResolverException
Description copied from interface: TransformerResolver
Responsible for finding a transformer with the given criteria. Note that if a transformer is not found null should be return, an exception must NOT be thrown.

Specified by:
resolve in interface TransformerResolver
source - information about the source object including the object iself
result - information about the result object to transform to
a transformer from the registry that matches the criteria or null if a transformer was not found
ResolverException - Only thrown if an exception is thrown during the search, this exception will just be a wrapper


protected Transformer getNearestTransformerMatch(List<Transformer> trans,
                                                 Class input,
                                                 Class output)
                                          throws ResolverException


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


public void transformerChange(Transformer transformer,
                              TransformerResolver.RegistryAction registryAction)
Description copied from interface: TransformerResolver
A callback that is called when a transformer is registered or unregistered from the registry. This is used in situations where the resolver caches transformers and the cache needs to be updated.

Specified by:
transformerChange in interface TransformerResolver
transformer - the transformer that has changed
registryAction - whether the transformer was added or removed

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