Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT

## org.mule.api.annotations
Annotation Type Transformer

    @Target(value=METHOD)
    @Retention(value=RUNTIME)
    @Documented
    public @interface Transformer

Used to mark a that a class contains methods which are Mule Transformer, which means it will be made available in the Mule container. Transformers are used to convert one object type to another. Mule uses them to provide automatic conversion of Java types and now support Mime type conversion too. The parameters passed into the method define the source object(s) to transform, the return type of the method defines the return object type. Transformers can define additional source types, that when received will be automatically converted to the parameter type accepted by the annotated method. There are some rules to follow when writing a transformer method -

1. The method's declaring class must be annotated with ContainsTransformerMethods
2. The annotation must appear on a concrete method, not on an abstract or interface method
3. The method must be public
4. The method must have a non-void return type
5. The method must have at least one parameter argument

It is good practice to define any custom transformers in their own class (a class can have more than one transformer method). A transformer class should be thread-safe and not have any transitive state, meaning that it should not maintain state as a result of a transformation. It is fine for transformers to have configuration state, such as in an XSLT or XQuery template file (note that Mule already provides transformers for XSLT and XQuery).

Optional Element Summary
`int` | `priorityWeighting` The 'priorityWeighting property is used to resolve conflicts where there is more than one transformers that match the selection criteria.
`Class[]` | `sourceTypes` SourceTypes define additional types that this transformer will accepts as a sourceType (beyond the method parameter).

### priorityWeighting

    public abstract int priorityWeighting

  The 'priorityWeighting property is used to resolve conflicts where there is more than one transformers that match the selection criteria. 10 is the highest priority and 1 is the lowest.

  Returns:
    the priority weighting for this transformer. If the class defines more than one transform method, every transform method will have the same weighting.
  Default:
    5

### sourceTypes

    public abstract Class[] sourceTypes

  SourceTypes define additional types that this transformer will accepts as a sourceType (beyond the method parameter). At run time if the current message matches one of these source types, Mule will attempt to transform from the source type to the method parameter type. This means that transformations can be chained. The user can create other transformers to be a part of this chain.

  Returns:
    an array of class types which allow the transformer to be matched on
  Default:
    {}

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT

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