public InvocationResponse dynamicInvoke(Object target, Invocation invocation) throws Throwable
{
long start = System.currentTimeMillis();
ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
EJBContainerInvocation newSi = null;
pushEnc();
try
{
Thread.currentThread().setContextClassLoader(classloader);
StatefulRemoteInvocation si = (StatefulRemoteInvocation) invocation;
MethodInfo info = getAdvisor().getMethodInfo(si.getMethodHash());
if (info == null)
{
throw new RuntimeException("Could not resolve beanClass method from proxy call " + invocation);
}
InvocationResponse response = null;
Method unadvisedMethod = info.getUnadvisedMethod();
Object newId = null;
try
{
invokeStats.callIn();
if (info != null && unadvisedMethod != null && isHomeMethod(unadvisedMethod))
{
response = invokeHomeMethod(info, si);
}
else if (info != null && unadvisedMethod != null && isEJBObjectMethod(unadvisedMethod))
{
response = invokeEJBObjectMethod(info, si);
}
else
{
if (unadvisedMethod.isBridge())
{
unadvisedMethod = this.getNonBridgeMethod(unadvisedMethod);
info = super.getMethodInfo(unadvisedMethod);
}
if (si.getId() == null)
{
StatefulBeanContext ctx = getCache().create(null, null);
newId = ctx.getId();
}
else
{
newId = si.getId();
}
newSi = new StatefulContainerInvocation(info, newId);
newSi.setArguments(si.getArguments());
newSi.setMetaData(si.getMetaData());
newSi.setAdvisor(getAdvisor());
Object rtn = null;
invokedMethod.push(new InvokedMethod(false, unadvisedMethod));
rtn = newSi.invokeNext();
response = marshallResponse(invocation, rtn, newSi.getResponseContextInfo());
if (newId != null) response.addAttachment(StatefulConstants.NEW_ID, newId);
}
}
catch (Throwable throwable)
{
Throwable exception = throwable;
if (newId != null)
{
exception = new ForwardId(throwable, newId);
}
Map responseContext = null;
if (newSi != null) newSi.getResponseContextInfo();
response = marshallException(invocation, exception, responseContext);
return response;
}
finally
{