1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
package org.mule.config.expression; |
11 | |
|
12 | |
import org.mule.api.annotations.expressions.Lookup; |
13 | |
import org.mule.api.annotations.meta.Evaluator; |
14 | |
import org.mule.api.expression.ExpressionAnnotationParser; |
15 | |
import org.mule.expression.ExpressionConfig; |
16 | |
import org.mule.expression.transformers.ExpressionArgument; |
17 | |
import org.mule.util.StringUtils; |
18 | |
|
19 | |
import java.lang.annotation.Annotation; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | 0 | public class LookupAnnotationParser implements ExpressionAnnotationParser |
30 | |
{ |
31 | |
public ExpressionArgument parse(Annotation annotation, Class<?> parameterType) |
32 | |
{ |
33 | 0 | Evaluator evaluator = annotation.annotationType().getAnnotation(Evaluator.class); |
34 | 0 | if (evaluator != null) |
35 | |
{ |
36 | 0 | String expression = ((Lookup) annotation).value(); |
37 | 0 | if(StringUtils.isEmpty(expression)) |
38 | |
{ |
39 | 0 | expression = "type:" + parameterType.getName(); |
40 | |
} |
41 | 0 | return new ExpressionArgument(null, new ExpressionConfig(expression, |
42 | |
evaluator.value(), null), ((Lookup) annotation).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 Lookup; |
54 | |
} |
55 | |
} |