1
2
3
4
5
6
7
8
9
10 package org.mule.module.ognl.config;
11
12 import org.mule.api.annotations.expression.Ognl;
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
18 import java.lang.annotation.Annotation;
19
20
21
22
23 public class OgnlAnnotationParser implements ExpressionAnnotationParser
24 {
25 public ExpressionArgument parse(Annotation annotation, Class<?> parameterType)
26 {
27 Evaluator evaluator = annotation.annotationType().getAnnotation(Evaluator.class);
28 if (evaluator != null)
29 {
30 return new ExpressionArgument(null, new ExpressionConfig(((Ognl) annotation).value(),
31 evaluator.value(), null), ((Ognl) annotation).optional(), parameterType);
32 }
33 else
34 {
35 throw new IllegalArgumentException("The @Evaluator annotation must be set on an Expression Annotation");
36 }
37 }
38
39 public boolean supports(Annotation annotation)
40 {
41 return annotation instanceof Ognl;
42 }
43 }