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