1 package org.apache.velocity.runtime.parser.node; 2 17 18 import org.apache.velocity.context.InternalContextAdapter; 19 import org.apache.velocity.util.introspection.Introspector; 20 21 import java.lang.reflect.InvocationTargetException ; 22 import org.apache.velocity.exception.MethodInvocationException; 23 24 import org.apache.velocity.runtime.RuntimeLogger; 25 26 27 37 public class GetExecutor extends AbstractExecutor 38 { 39 43 private Object [] args = new Object [1]; 44 45 48 public GetExecutor(RuntimeLogger r, Introspector ispect, Class c, String key) 49 throws Exception 50 { 51 rlog = r; 52 args[0] = key; 53 method = ispect.getMethod(c, "get", args); 54 } 55 56 59 public Object execute(Object o) 60 throws IllegalAccessException , InvocationTargetException 61 { 62 if (method == null) 63 return null; 64 65 return method.invoke(o, args); 66 } 67 68 71 public Object OLDexecute(Object o, InternalContextAdapter context) 72 throws IllegalAccessException , MethodInvocationException 73 { 74 if (method == null) 75 return null; 76 77 try 78 { 79 return method.invoke(o, args); 80 } 81 catch(InvocationTargetException ite) 82 { 83 87 88 throw new MethodInvocationException( 89 "Invocation of method 'get(\"" + args[0] + "\")'" 90 + " in " + o.getClass() 91 + " threw exception " 92 + ite.getTargetException().getClass(), 93 ite.getTargetException(), "get"); 94 } 95 catch(IllegalArgumentException iae) 96 { 97 return null; 98 } 99 } 100 } 101 102 103 104 105 106 107 108 109 110 | Popular Tags |