1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package net.sf.tacos.annotations;
16
17 import java.lang.reflect.Method;
18
19 import org.apache.hivemind.Location;
20 import org.apache.tapestry.annotations.AnnotationUtils;
21 import org.apache.tapestry.annotations.MethodAnnotationEnhancementWorker;
22 import org.apache.tapestry.enhance.EnhancementOperation;
23 import org.apache.tapestry.spec.IComponentSpecification;
24 import org.apache.tapestry.spec.InjectSpecification;
25 import org.apache.tapestry.spec.InjectSpecificationImpl;
26
27
28
29
30
31 public class InjectParameterFlagAnnotationWorker implements MethodAnnotationEnhancementWorker
32 {
33 private static final String BOUND = "Bound";
34
35 public void performEnhancement(EnhancementOperation op, IComponentSpecification spec,
36 Method method, Location location)
37 {
38 String propertyName = AnnotationUtils.getPropertyName(method);
39 InjectParameterFlag ipv = method.getAnnotation(InjectParameterFlag.class);
40
41 String watchedParameterName = ipv.value();
42
43 if (watchedParameterName.equals(""))
44 {
45 watchedParameterName = propertyName;
46 if (watchedParameterName.endsWith(BOUND))
47 {
48 int length = watchedParameterName.length();
49 watchedParameterName = watchedParameterName.substring(0, length - BOUND.length());
50 }
51 }
52
53 InjectSpecification inject = new InjectSpecificationImpl();
54
55 inject.setType("parameter-flag");
56 inject.setProperty(propertyName);
57 inject.setObject(watchedParameterName);
58 inject.setLocation(location);
59
60 spec.addInjectSpecification(inject);
61 }
62
63 }
64