views:

10

answers:

0

I am trying to create a fake MBean server, so when it comes to evoking operations, I am running into problems. I have grabbed all the metadata from the mbean and put it into an xml file. I have the attributes working fine it seems, but having problems with the operations. I have all their metadata (method name, return type,etc) but I need some help transferring this information into my invoke() method to kind of mock it.

The returned type of invoke() is Object (which should be the return type of the operation called I believe).

Object result=null;
Object obj = getOperation(name, "Type");
            String className = (String) obj;
            Class myClass = Class.forName(className);
            Constructor constructor = myClass.getConstructor(new Class[0]);
            result = constructor.newInstance(new Object[0]);

Problem is, I would like some way to create some Method Objects, so when I call myClass.getDeclaredMethod(...) I can get this object. And return an Object of it's return type. Problem is, don't see how to do that in the Java Api (http://download.oracle.com/javase/1.4.2/docs/api/java/lang/reflect/Method.html) all there are are getters.

Thanks