1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.jelly.tags.define;
18
19 import java.lang.reflect.Method;
20
21 import org.apache.commons.beanutils.MethodUtils;
22
23 import org.apache.commons.logging.Log;
24 import org.apache.commons.logging.LogFactory;
25
26
27 /***
28 * Binds a Java bean to the given named Jelly tag so that the attributes of
29 * the tag set the bean properties. After the body of this tag is invoked
30 * then the beans invoke() method will be called, if the bean has one.
31 *
32 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
33 * @version $Revision: 155420 $
34 */
35 public class JellyBeanTag extends BeanTag {
36
37 /*** The Log to which logging calls will be made. */
38 private static final Log log = LogFactory.getLog(JellyBeanTag.class);
39
40 /*** Empty parameter types for Method lookup */
41 private static final Class[] emptyParamTypes = {};
42
43 /*** the name of the method to invoke on the bean */
44 private String method;
45
46
47
48
49 /***
50 * @return the method name to use, which defaults to 'run' for Runnable
51 * objects
52 */
53 public String getMethod() {
54 if ( method == null ) {
55 return "run";
56 }
57 return method;
58 }
59
60 /***
61 * Sets the name of the method to invoke on the bean.
62 * This defaults to "run" so that Runnable objects can be
63 * invoked, but this property can be set to whatever is required,
64 * such as "execute" or "invoke"
65 */
66 public void setMethod(String method) {
67 this.method = method;
68 }
69
70
71
72
73
74 protected Method getInvokeMethod( Class theClass ) {
75 Method invokeMethod =
76 MethodUtils.getAccessibleMethod(
77 theClass,
78 getMethod(),
79 emptyParamTypes);
80
81 if ( invokeMethod == null ) {
82 }
83 return invokeMethod;
84 }
85 }