You should read Reflection in Java.
The following example calls the method
myObjectThatContainsMethod # methodNameAsString (Integer arg1, Integer arg2)
Integer[] params = {new Integer(123),new Integer(567)};
Class cl=Class.forName("stringParsedFromYourXML");
Class[] par=new Class[2];
par[0]=Integer.TYPE;
par[1]=Integer.TYPE;
Method mthd=cl.getMethod("methodNameAsString", parameterTypes);
mthd.invoke(new myObjectThatContainsMethod(), params);
hope this helps ..
Stephan
source
share