1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.config.parsers; |
8 | |
|
9 | |
import org.mule.api.annotations.meta.Evaluator; |
10 | |
import org.mule.api.annotations.param.OutboundHeaders; |
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 | |
import java.util.Map; |
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | 0 | public class OutboundHeadersAnnotationParser implements ExpressionAnnotationParser |
23 | |
{ |
24 | |
public ExpressionArgument parse(Annotation annotation, Class<?> parameterType) |
25 | |
{ |
26 | 0 | if(!Map.class.isAssignableFrom(parameterType)) |
27 | |
{ |
28 | 0 | throw new IllegalArgumentException("The @OutboundHeaders annotation can only be set on a java.util.Map parameter"); |
29 | |
} |
30 | 0 | Evaluator evaluator = annotation.annotationType().getAnnotation(Evaluator.class); |
31 | 0 | if (evaluator != null) |
32 | |
{ |
33 | 0 | return new ExpressionArgument(null, new ExpressionConfig("", evaluator.value(), null), false); |
34 | |
} |
35 | |
else |
36 | |
{ |
37 | 0 | throw new IllegalArgumentException("The @Evaluator annotation must be set on an Expression Annotation"); |
38 | |
} |
39 | |
} |
40 | |
|
41 | |
public boolean supports(Annotation annotation) |
42 | |
{ |
43 | 0 | return annotation instanceof OutboundHeaders; |
44 | |
} |
45 | |
} |