This is marginally off-topic, apologies.
We are trying to write a test harness to exercise EJBs, driven by test scripts, which determine amongst other things which EJB to call, the method to call etc.
Typical client code is:
Object o = context.lookup("someJNDIname");
XxxHome xxxHome = (XxxHome) PortableRemoteObject.narrow(o,
Xxx xxx = xxxHome.create();
Our problem is that we don't know what Xxx represents till runtime, so there is potentially lots of complex reflection type code. Being lazy, I wondered if anyone could point me at some documentation of how this might be done.
OK, the penalty for being lazy is having to write up the answer when it is found. The following seems to work:
Object o = _context.lookup(jndiName);
Object o2 = PortableRemoteObject.narrow(o,
Method m = o2.getClass().getMethod("create",new Class);
Object o3 = method.invoke(o2,new Object);
Object paramArray = new Object;
paramArray = new String(scriptInput);
Class classArray = new Class;
classArray = String.class;
method = o3.getClass().getMethod(targetMethod,classArray);
String returnString = (String) method.invoke(o3,paramArray);
where jndiName,targetBean,scriptInput and targetMethod are derived from our script and our target methods always expect to receive and return Strings (if you had to determine the paarmeter and return types you'd probably need to examine the list of methods).