자바·JSP
String으로 자바 메소드를 호출하고 싶을 때..
미랭군
2011. 4. 18. 20:29
public String callService(DflCallServiceParam param)
throws InstantiationException, IllegalAccessException, ClassNotFoundException, InvocationTargetException, RemoteException, NoSuchMethodException {
UiServiceImpl obj = new UiServiceImpl();
String result = "";
int mc;
Class oClass = obj.getClass();
Method[] methods = oClass.getDeclaredMethods();
for(int i=0; i < methods.length; i++)
{
if(param.getMid().equals(methods[i].getName()));
{
mc = i;
}
}
Method method = oClass.getDeclaredMethod(param.getMid(), new Class[]{new String().getClass()});
Ret ret = (Ret)method.invoke(obj, new Object[]{new String("aaa")});
return result;
}