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 -
- The method's declaring class must be annotated with ContainsTransformerMethods
- The annotation must appear on a concrete method, not on an abstract or interface method
- The method must be public
- The method must have a non-void return type
- 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. |
String |
resultMimeType
The result MIME type describes the MIME type of this transformer output. |
String |
sourceMimeType
Source mime type describes the acceptable MIME type of this transformer input. |
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
sourceMimeType
public abstract String sourceMimeType
- Source mime type describes the acceptable MIME type of this transformer input.
- Returns:
- The supported MIME type for input.
- Since:
- 3.3.0
- Default:
- "*/*"
resultMimeType
public abstract String resultMimeType
- The result MIME type describes the MIME type of this transformer output.
- Returns:
- The MIME type for the output of this transformer.
- Since:
- 3.3.0
- Default:
- "*/*"
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:
- {}
Copyright © 2003-2014 MuleSoft, Inc.. All Rights Reserved.