Package com.citic.util; Import the java.lang.reflect *. ; Import the java.util.HashMap; Import . com.citic.util.comm * ; / ** * This method to perform the method according to the name of an object and * @author db2admin * * / public class ReflectUtil { public static String methodName = "Execute" ; public static int debuglevel =. 8 ; public static the HashMap <String, String []> PreExecute (String className, xmlOder String, String msgid) { / / return there are two general preset code, message return execute(className,"pre"+methodName,xmlOder,msgid); } public static HashMap<String,String[]> execute(String className,String xmlOder,String msgid){ return execute(className,methodName,xmlOder,msgid); } @SuppressWarnings("unchecked") public static HashMap<String,String[]> execute(String className,String methodName,String xmlOder,String msgid) { HashMap<String,String[]> hm=new HashMap<String,String[]>(); Method m1; Class<?> clazz; Object obj; String tb = ConfigFileUtil.getValue("SCHEMAPREFIX1") + ConfigFileUtil.getValue("T" + xmlOder); CommFun.log(debuglevel, "调用类:" + className + ",方法:" + methodName + ",参数:" + msgid+",表名:"+tb+",xmlOrder:"+xmlOder); try { if("".equals(tb)||tb==null){ throw new Exception(xmlOder+"对应表名为空"); } clazz=Class.forName(className); obj=clazz.newInstance(); //解决父类调用问题 while(true){ try{ m1=obj.getClass().getDeclaredMethod(methodName, String.class,String.class,String.class); CommFun.log(clazz.toString()+","+obj.toString()+","+m1.toString()); }catch(NoSuchMethodException ne){ clazz=clazz.getSuperclass(); obj=clazz.newInstance(); CommFun.log(clazz.toString()+","+obj.toString()); continue; } break; } hm=(HashMap<String, String[]>) m1.invoke(obj,xmlOder,msgid,tb); } catch (Exception e) { CommFun.log("---------"); e.printStackTrace(); CommFun.log("["+e.toString()+"]"); } return hm; } }