1
2
3
4
5
6
7
8
9
10
11 package org.mule.impl.model.resolvers;
12
13 import java.lang.reflect.InvocationTargetException;
14 import java.lang.reflect.Method;
15
16 import org.apache.commons.logging.Log;
17 import org.apache.commons.logging.LogFactory;
18
19
20
21
22
23 public class EntryPoint
24 {
25
26
27
28 protected static final Log logger = LogFactory.getLog(EntryPoint.class);
29
30
31
32
33 private Method method;
34
35
36
37
38
39
40 public EntryPoint(Method method)
41 {
42 this.method = method;
43 }
44
45
46
47
48
49
50
51
52
53
54 public Object invoke(Object component, Object arg)
55 throws InvocationTargetException, IllegalAccessException
56 {
57 String methodCall = null;
58 if (logger.isDebugEnabled())
59 {
60 methodCall = component.getClass().getName() + "." + method.getName() + "("
61 + arg.getClass().getName() + ")";
62 logger.debug("Invoking " + methodCall);
63 }
64
65 Object result = method.invoke(component, new Object[]{arg});
66 if (logger.isDebugEnabled())
67 {
68 logger.debug("Result of call " + methodCall + " is " + result);
69 }
70 return result;
71 }
72
73
74
75
76
77
78 public boolean isVoid()
79 {
80 return method.getReturnType().getName().equals("void");
81 }
82
83
84
85
86
87
88 public String getName()
89 {
90 if (method == null)
91 {
92 return null;
93 }
94 return method.getName();
95 }
96
97
98
99
100
101
102 public Class getParameterType()
103 {
104 return method.getParameterTypes()[0];
105 }
106
107
108
109
110
111
112 public Class getReturnType()
113 {
114 if (isVoid())
115 {
116 return null;
117 }
118 else
119 {
120 return method.getReturnType();
121 }
122 }
123
124 protected void setMethod(Method method)
125 {
126 this.method = method;
127 }
128
129 protected Method getMethod()
130 {
131 return method;
132 }
133 }