1 10 11 package org.mule.model; 12 13 import org.apache.commons.logging.Log; 14 import org.apache.commons.logging.LogFactory; 15 16 import java.lang.reflect.InvocationTargetException ; 17 import java.lang.reflect.Method ; 18 19 23 public class EntryPoint 24 { 25 28 protected static final Log logger = LogFactory.getLog(EntryPoint.class); 29 30 33 private Method method; 34 35 40 public EntryPoint(Method method) 41 { 42 this.method = method; 43 } 44 45 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 78 public boolean isVoid() 79 { 80 return method.getReturnType().getName().equals("void"); 81 } 82 83 88 public String getName() 89 { 90 if (method == null) 91 { 92 return null; 93 } 94 return method.getName(); 95 } 96 97 102 public Class getParameterType() 103 { 104 return method.getParameterTypes()[0]; 105 } 106 107 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 } 134 | Popular Tags |