// Cast
assert invocation instanceof MethodInvocation : SessionContainer.class.getName()
+ ".dynamicInoke supports only " + MethodInvocation.class.getSimpleName()
+ ", but has been passed: " + invocation;
MethodInvocation si = (MethodInvocation) invocation;
// Get the method hash
long methodHash = si.getMethodHash();
log.debug("Received dynamic invocation for method with hash: " + methodHash);
// Get the Method via MethodInfo from the Advisor
Advisor advisor = this.getAdvisor();
MethodInfo info = advisor.getMethodInfo(methodHash);
Method unadvisedMethod = info.getMethod();
SerializableMethod unadvisedMethodSerializable = new SerializableMethod(unadvisedMethod);
try
{
invokeStats.callIn();
/*
* Set the invoked method
*/
//TODO Remove when CurrentInvocation is ironed out
// Get the invoked method from invocation metadata
Object objInvokedMethod = si.getMetaData(SessionSpecRemotingMetadata.TAG_SESSION_INVOCATION,SessionSpecRemotingMetadata.KEY_INVOKED_METHOD);
assert objInvokedMethod !=null : "Invoked Method must be set on invocation metadata";
assert objInvokedMethod instanceof SerializableMethod : "Invoked Method set on invocation metadata is not of type " + SerializableMethod.class.getName() + ", instead: " + objInvokedMethod;
SerializableMethod invokedMethod = (SerializableMethod)objInvokedMethod;
Class<?> invokedBusinessInterface = Class.forName(invokedMethod.getActualClassName(), false, this
.getClassloader());
if (!this.getBusinessInterfaces().contains(invokedBusinessInterface))
{
// Required because SerializableMethod will automatically set the actual class name to the declaring class name
invokedBusinessInterface = null;
}
Map responseContext = null;
Object rtn = null;
if (unadvisedMethod != null && isHomeMethod(unadvisedMethodSerializable))
{
rtn = invokeHomeMethod(info, si);
}
else if (info != null && unadvisedMethod != null && isEjbObjectMethod(unadvisedMethodSerializable))
{
rtn = invokeEJBObjectMethod(info, si);
}
else
{
newSi = new SessionContainerInvocation<StatelessContainer, StatelessBeanContext>(
invokedBusinessInterface, info, this.getAsynchronousExecutor());
newSi.setArguments(si.getArguments());
newSi.setMetaData(si.getMetaData());
//newSi.setAdvisor(getAdvisor());
try
{
rtn = newSi.invokeNext();