MethodInfo info = this.getAdvisor().getMethodInfo(hash);
Method unadvisedMethod = info.getUnadvisedMethod();
if (unadvisedMethod.getName().equals("getHandle"))
{
EJBObject proxy;
if(CurrentRemoteProxyFactory.isSet())
{
proxy = CurrentRemoteProxyFactory.get(EJB2RemoteProxyFactory.class).create((Serializable) statefulInvocation.getId());
}
else
{
StatefulContainerInvocation newStatefulInvocation = buildInvocation(info, statefulInvocation);
// Get JNDI Registrar
JndiSessionRegistrarBase sfsbJndiRegistrar = this.getJndiRegistrar();
// Determine if local/remote
boolean isLocal = EJBLocalObject.class.isAssignableFrom(unadvisedMethod.getDeclaringClass());
// Get the metadata
JBossSessionBeanMetaData smd = this.getMetaData();
// Get the appropriate JNDI Name
String jndiName = isLocal ? smd.getLocalJndiName() : smd.getJndiName();
// Find the Proxy Factory Key for this SFSB
String proxyFactoryKey = sfsbJndiRegistrar.getProxyFactoryRegistryKey(jndiName, smd, isLocal);
// Lookup the Proxy Factory in the Object Store
StatefulSessionProxyFactory proxyFactory = Ejb3RegistrarLocator.locateRegistrar().lookup(proxyFactoryKey,
StatefulSessionProxyFactory.class);
// Create a new EJB2.x Proxy
proxy = (EJBObject) proxyFactory.createProxyEjb2x((Serializable) newStatefulInvocation.getId());
}
StatefulHandleRemoteImpl handle = new StatefulHandleRemoteImpl(proxy);
InvocationResponse response = marshallResponse(statefulInvocation, handle, null);
return response;
}
// SFSB remove()
else if (unadvisedMethod.getName().equals(Ejb2xMethodNames.METHOD_NAME_HOME_REMOVE))
{
try
{
// Attempt to remove the bean
destroySession(statefulInvocation.getId());
}
catch (NoSuchEJBException e)
{
String invokingClassName = method.getActualClassName();
Throwable newException = this.constructProperNoSuchEjbException(e, invokingClassName);
throw newException;
}
InvocationResponse response = new InvocationResponse(null);
return response;
}
else if (unadvisedMethod.getName().equals("getEJBHome"))
{
EJBHome ejbHome;
if(CurrentRemoteProxyFactory.isSet())
{
ejbHome = CurrentRemoteProxyFactory.get(EJB2RemoteProxyFactory.class).createHome();
}
else
{
HomeHandleImpl homeHandle = null;
RemoteBinding remoteBindingAnnotation = this.getAnnotation(RemoteBinding.class);
if (remoteBindingAnnotation != null)
homeHandle = new HomeHandleImpl(ProxyFactoryHelper.getHomeJndiName(this));
ejbHome = homeHandle.getEJBHome();
}
InvocationResponse response = marshallResponse(statefulInvocation, ejbHome, null);
return response;
}
else if (unadvisedMethod.getName().equals("getPrimaryKey"))
{
Object id = statefulInvocation.getId();
InvocationResponse response = marshallResponse(statefulInvocation, id, null);
return response;
}
else if (unadvisedMethod.getName().equals("isIdentical"))
{
Object id = statefulInvocation.getId();
EJBObject bean = (EJBObject) statefulInvocation.getArguments()[0];
Object primaryKey = bean.getPrimaryKey();
boolean isIdentical = id.equals(primaryKey);
InvocationResponse response = marshallResponse(statefulInvocation, isIdentical, null);
return response;