1 18 package org.apache.tools.ant.util; 19 20 import java.lang.reflect.Constructor ; 21 22 28 29 public class ReflectWrapper { 30 private Object obj; 31 36 public ReflectWrapper(ClassLoader loader, String name) { 37 try { 38 Class clazz; 39 clazz = Class.forName(name, true, loader); 40 Constructor constructor; 41 constructor = clazz.getConstructor((Class []) null); 42 obj = constructor.newInstance((Object []) null); 43 } catch (Exception t) { 44 ReflectUtil.throwBuildException(t); 45 } 46 } 47 48 52 public ReflectWrapper(Object obj) { 53 this.obj = obj; 54 } 55 56 59 public Object getObject() { 60 return obj; 61 } 62 63 68 public Object invoke(String methodName) { 69 return ReflectUtil.invoke(obj, methodName); 70 } 71 72 79 public Object invoke( 80 String methodName, Class argType, Object arg) { 81 return ReflectUtil.invoke(obj, methodName, argType, arg); 82 } 83 84 93 public Object invoke( 94 String methodName, Class argType1, Object arg1, 95 Class argType2, Object arg2) { 96 return ReflectUtil.invoke( 97 obj, methodName, argType1, arg1, argType2, arg2); 98 } 99 } 100 | Popular Tags |