public Object invoke(Object proxy,
Method method,
Object[] args) throws FinderException {
// todo find a better workaround
// CMP/CMR field bridges are mapped to its abstract method names because of the bug
// in reflection introduced in Sun's 1.4 JVM, i.e. when an abstract class C1 extends a super class C2
// and implements interface I and C2 and I both declare method with the same signature M,
// C1.getMethods() will contain M twice.
// ejbSelect methods are mapped to Method objects instead. Because ejbSelect methods having the same name
// might have different signatures. Hopefully, the probability of an ejbSelect method to appear in an interface
// is lower.
String methodName = method.getName();
BridgeInvoker invoker = (BridgeInvoker) fieldMap.get(methodName);
if(invoker == null)
{
//invoker = (BridgeInvoker) selectorMap.get(methodName);
invoker = (BridgeInvoker) selectorMap.get(method);
if(invoker == null)
{
throw new EJBException("Method is not a known CMP field " +
"accessor, CMR field accessor, or ejbSelect method: " +
"methodName=" + methodName);
}
}
try
{
return invoker.invoke(ctx, method, args);
}
catch(RuntimeException e)
{
throw e;
}
catch(FinderException e)
{
throw e;
}
catch(Exception e)
{
throw new EJBException("Internal error", e);
}
}
|