I have done and tested this. Kind of solved what i need. so i would like to share it just in case you need to do something like it. enjoy...
public class Demo implements DemoInterface {
public void execute(String methodName){
try{
java.lang.reflect.Method m = this.getClass().getMethod(methodName, null);
m.invoke(this,new Object[]{});
}catch(Exception e){
System.out.println("Demo::execute("+methodName+")-"+e.getMessage());
}
}
public void execute(String methodName,Map params){
try{
Class[] paramType = {Map.class};
java.lang.reflect.Method m = this.getClass().getMethod(methodName, paramType);
Object[] paramData = new Object[1];
paramData[0] = params;
m.invoke(this,paramData);
}catch(Exception e){
System.out.println("Demo::execute("+methodName+")-"+e.getMessage());
e.printStackTrace(System.err);
}
}
public void sampleMethod(){
System.out.println("Demo::sampleMethod() was called.");
}
public void sampleMethod2(Map params){
System.out.println("Demo::sampleMethod2() was called.");
Collection c = params.values();
int mapsize = params.size();
Iterator keyValuePairs1 = params.entrySet().iterator();
for (int i = 0; i < mapsize; i++)
{
Map.Entry entry = (Map.Entry) keyValuePairs1.next();
String key = (String) entry.getKey();
String value = (String) entry.getValue();
System.out.println(key+":"+value);
}
}
public static void main(String[] args){
DemoInterface demo = new Demo();
demo.execute("sampleMethod");
Map sample = new HashMap();
sample.put("param1","this is param1");
sample.put("param2","this is param2");
sample.put("param3","this is param3");
demo.execute("sampleMethod2",sample);
}
}
[ May 02, 2005: Message edited by: Jay Richards ]