1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.config.expression; |
8 | |
|
9 | |
import org.mule.api.annotations.expressions.Mule; |
10 | |
import org.mule.api.annotations.meta.Evaluator; |
11 | |
import org.mule.api.expression.ExpressionAnnotationParser; |
12 | |
import org.mule.expression.ExpressionConfig; |
13 | |
import org.mule.expression.transformers.ExpressionArgument; |
14 | |
|
15 | |
import java.lang.annotation.Annotation; |
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | 0 | public class MuleAnnotationParser implements ExpressionAnnotationParser |
26 | |
{ |
27 | |
public ExpressionArgument parse(Annotation annotation, Class parameterType) |
28 | |
{ |
29 | 0 | Evaluator evaluator = annotation.annotationType().getAnnotation(Evaluator.class); |
30 | 0 | if (evaluator != null) |
31 | |
{ |
32 | 0 | Mule muleAnnotation = (Mule)annotation; |
33 | 0 | String val = muleAnnotation.value(); |
34 | |
|
35 | 0 | if ("message.payload".equals(val)) |
36 | |
{ |
37 | |
|
38 | 0 | val += "(" + parameterType.getName() + ")"; |
39 | |
} |
40 | |
|
41 | 0 | return new ExpressionArgument(null, new ExpressionConfig(val, evaluator.value(), null), |
42 | |
muleAnnotation.optional(), parameterType); |
43 | |
} |
44 | |
else |
45 | |
{ |
46 | 0 | throw new IllegalArgumentException("The @Evaluator annotation must be set on an Expression Annotation"); |
47 | |
} |
48 | |
|
49 | |
} |
50 | |
|
51 | |
public boolean supports(Annotation annotation) |
52 | |
{ |
53 | 0 | return annotation instanceof Mule; |
54 | |
} |
55 | |
} |