[jboss-cvs] JBossAS SVN: r85729 - in projects/ejb3/trunk: core/src/main/java/org/jboss/ejb3/session and 13 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 11 06:01:10 EDT 2009
Author: ALRubinger
Date: 2009-03-11 06:01:09 -0400 (Wed, 11 Mar 2009)
New Revision: 85729
Modified:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java
projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/unit/PassivationDoesNotPreventNewActivityUnitTestCase.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/container/InvokableContext.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionProxyFactoryBase.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandlerBase.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionProxyInvocationHandlerBase.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecProxyInvocationHandlerBase.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/service/ServiceProxyInvocationHandlerBase.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulLocalProxyInvocationHandler.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulProxyInvocationHandlerBase.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulRemoteProxyInvocationHandler.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessProxyInvocationHandlerBase.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/ServiceProxy.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/SessionProxy.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/StatefulSessionProxy.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/invocation/InvokableContextStatefulRemoteProxyInvocationHack.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/remoting/ProxyRemotingUtils.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/SessionContainer.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/unit/SfsbProxyEqualityTestCase.java
Log:
[EJBTHREE-1764] InvokableContext.invoke should accept a SessionProxy from which we may get a target/SessionID
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -64,6 +64,7 @@
import org.jboss.ejb3.common.lang.SerializableMethod;
import org.jboss.ejb3.proxy.clustered.objectstore.ClusteredObjectStoreBindings;
import org.jboss.ejb3.proxy.container.InvokableContext;
+import org.jboss.ejb3.proxy.intf.SessionProxy;
import org.jboss.ejb3.proxy.objectstore.ObjectStoreBindings;
import org.jboss.ejb3.session.SessionContainer;
import org.jboss.ejb3.stateful.StatefulContainerInvocation;
@@ -597,7 +598,7 @@
/**
* @see InvokableContext
*/
- public Object invoke(Object proxy, SerializableMethod method, Object[] args) throws Throwable
+ public Object invoke(SessionProxy proxy, SerializableMethod method, Object[] args) throws Throwable
{
return this.localInvoke(method.toMethod(), args);
}
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -21,7 +21,7 @@
import org.jboss.ejb3.proxy.container.InvokableContext;
import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
import org.jboss.ejb3.proxy.factory.session.SessionSpecProxyFactory;
-import org.jboss.ejb3.proxy.intf.StatefulSessionProxy;
+import org.jboss.ejb3.proxy.intf.SessionProxy;
import org.jboss.ejb3.proxy.remoting.SessionSpecRemotingMetadata;
import org.jboss.ejb3.stateful.StatefulContainer;
import org.jboss.ejb3.stateful.StatefulContainerInvocation;
@@ -76,7 +76,7 @@
* @throws Throwable A possible exception thrown by the invocation
* @return
*/
- public Object invoke(Object proxy, SerializableMethod method, Object[] args) throws Throwable
+ public Object invoke(SessionProxy proxy, SerializableMethod method, Object[] args) throws Throwable
{
/*
* Replace the TCL with the CL for this Container
@@ -106,13 +106,7 @@
SerializableMethod unadvisedSerializableMethod = new SerializableMethod(unadvisedMethod);
// Obtain Session ID
- //TODO Ugly, use polymorphism and get Session ID for SFSB only
- Serializable sessionId = null;
- if(proxy instanceof StatefulSessionProxy)
- {
- StatefulSessionProxy statefulProxy = (StatefulSessionProxy)proxy;
- sessionId = statefulProxy.getSessionId();
- }
+ Serializable sessionId = (Serializable) proxy.getTarget();
/*
* Invoke directly if this is an EJB2.x Method
Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/unit/PassivationDoesNotPreventNewActivityUnitTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/unit/PassivationDoesNotPreventNewActivityUnitTestCase.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1549/unit/PassivationDoesNotPreventNewActivityUnitTestCase.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -202,7 +202,7 @@
// Get our bean's Session ID
StatefulLocalProxyInvocationHandler handler = (StatefulLocalProxyInvocationHandler) Proxy
.getInvocationHandler(bean);
- Serializable sessionId = handler.getSessionId();
+ Serializable sessionId = (Serializable) handler.getTarget();
// Invoke upon our bean
int next = bean.getNextCounter();
@@ -284,7 +284,7 @@
// Get our bean's Session ID
StatefulLocalProxyInvocationHandler handler = (StatefulLocalProxyInvocationHandler) Proxy
.getInvocationHandler(bean);
- Serializable sessionId = handler.getSessionId();
+ Serializable sessionId = (Serializable) handler.getTarget();
// Invoke upon our bean
int next = bean.getNextCounter();
@@ -641,7 +641,7 @@
// Get our bean's Session ID
StatefulLocalProxyInvocationHandler handler = (StatefulLocalProxyInvocationHandler) Proxy
.getInvocationHandler(bean);
- Serializable sessionId = handler.getSessionId();
+ Serializable sessionId = (Serializable) handler.getTarget();
return sessionId;
}
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/container/InvokableContext.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/container/InvokableContext.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/container/InvokableContext.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -24,6 +24,7 @@
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.InvocationResponse;
import org.jboss.ejb3.common.lang.SerializableMethod;
+import org.jboss.ejb3.proxy.intf.SessionProxy;
/**
* InvokableContext
@@ -47,7 +48,7 @@
* @throws Throwable A possible exception thrown by the invocation
* @return
*/
- Object invoke(Object proxy, SerializableMethod method, Object[] args) throws Throwable;
+ Object invoke(SessionProxy proxy, SerializableMethod method, Object[] args) throws Throwable;
/**
* Invocation point of entry for Remoting
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionProxyFactoryBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionProxyFactoryBase.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionProxyFactoryBase.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -275,7 +275,7 @@
StatefulProxyInvocationHandlerBase sHandler = (StatefulProxyInvocationHandlerBase) handler;
// Set the Session ID on the Proxy
- sHandler.setSessionId(sessionId);
+ sHandler.setTarget(sessionId);
}
/**
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandlerBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandlerBase.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandlerBase.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -32,6 +32,7 @@
import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
import org.jboss.ejb3.proxy.container.InvokableContext;
+import org.jboss.ejb3.proxy.intf.SessionProxy;
import org.jboss.logging.Logger;
/**
@@ -228,7 +229,7 @@
* @return
* @throws Throwable
*/
- public Object invoke(Object proxy, SerializableMethod method, Object[] args) throws Throwable
+ public Object invoke(SessionProxy proxy, SerializableMethod method, Object[] args) throws Throwable
{
// Attempt to handle directly
try
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionProxyInvocationHandlerBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionProxyInvocationHandlerBase.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionProxyInvocationHandlerBase.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -22,9 +22,13 @@
package org.jboss.ejb3.proxy.handler.session;
import java.io.Serializable;
+import java.lang.reflect.Method;
import org.jboss.aop.advice.Interceptor;
+import org.jboss.ejb3.common.lang.SerializableMethod;
+import org.jboss.ejb3.proxy.handler.NotEligibleForDirectInvocationException;
import org.jboss.ejb3.proxy.handler.ProxyInvocationHandlerBase;
+import org.jboss.ejb3.proxy.intf.SessionProxy;
import org.jboss.logging.Logger;
/**
@@ -49,7 +53,40 @@
private static final Logger log = Logger.getLogger(SessionProxyInvocationHandlerBase.class);
+ private static final String METHOD_NAME_GET_TARGET = "getTarget";
+
+ private static final String METHOD_NAME_SET_TARGET = "setTarget";
+
+ private static final SerializableMethod METHOD_GET_TARGET;
+
+ private static final SerializableMethod METHOD_SET_TARGET;
+
+ static
+ {
+ try
+ {
+ METHOD_GET_TARGET = new SerializableMethod(SessionProxy.class.getDeclaredMethod(METHOD_NAME_GET_TARGET));
+ METHOD_SET_TARGET = new SerializableMethod(SessionProxy.class.getDeclaredMethod(METHOD_NAME_SET_TARGET,
+ Object.class));
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ throw new RuntimeException(
+ "Methods for handling directly by the InvocationHandler were not initialized correctly", nsme);
+ }
+
+ }
+
// ------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------||
+ // ------------------------------------------------------------------------------||
+
+ /**
+ * The target for this Invocation (for instance, Session ID)
+ */
+ private Object target;
+
+ // ------------------------------------------------------------------------------||
// Constructor ------------------------------------------------------------------||
// ------------------------------------------------------------------------------||
@@ -61,8 +98,66 @@
* @param interceptors The interceptors to apply to invocations upon this handler
*/
protected SessionProxyInvocationHandlerBase(final String containerName, final String containerGuid,
- final Interceptor[] interceptors)
+ final Interceptor[] interceptors, final Object target)
{
super(containerName, containerGuid, interceptors);
+ this.setTarget(target);
}
+
+ // ------------------------------------------------------------------------------||
+ // Overridden Implementations ---------------------------------------------------||
+ // ------------------------------------------------------------------------------||
+
+ /**
+ * Handles the current invocation directly in this invocation handler. Only
+ * a subset of method invocations are eligible for this treatment, else
+ * a NotEligibleForDirectInvocationException will be thrown
+ *
+ * @param proxy
+ * @param args Arguments of the current invocation
+ * @param invokedMethod The method invoked
+ * @return
+ * @throws NotEligibleForDirectInvocationException
+ */
+ @Override
+ protected Object handleInvocationDirectly(Object proxy, Object[] args, Method invokedMethod)
+ throws NotEligibleForDirectInvocationException
+ {
+ // Obtain the invoked method
+ assert invokedMethod != null : "Invoked Method was not set upon invocation of " + this.getClass().getName();
+
+ // getTarget
+ if (invokedMethod.equals(METHOD_GET_TARGET.toMethod()))
+ {
+ return this.getTarget();
+ }
+ // setTarget
+ if (invokedMethod.equals(METHOD_SET_TARGET.toMethod()))
+ {
+ assert args.length == 1 : "Expecting exactly one argument for invocation of " + METHOD_SET_TARGET;
+ Object arg = args[0];
+ assert arg instanceof Serializable : "Argument must be instance of " + Serializable.class.getName();
+ Serializable id = (Serializable) arg;
+ this.setTarget(id);
+ return null;
+ }
+
+ // Call to super
+ return super.handleInvocationDirectly(proxy, args, invokedMethod);
+ }
+
+ // ------------------------------------------------------------------------------||
+ // Accessors / Mutators ---------------------------------------------------------||
+ // ------------------------------------------------------------------------------||
+
+ public Object getTarget()
+ {
+ return target;
+ }
+
+ public void setTarget(Object target)
+ {
+ this.target = target;
+ }
+
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecProxyInvocationHandlerBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecProxyInvocationHandlerBase.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecProxyInvocationHandlerBase.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -26,6 +26,7 @@
import org.jboss.aop.advice.Interceptor;
import org.jboss.ejb3.common.lang.SerializableMethod;
+import org.jboss.ejb3.proxy.intf.SessionProxy;
import org.jboss.logging.Logger;
/**
@@ -45,7 +46,7 @@
// ------------------------------------------------------------------------------||
// Class Members ----------------------------------------------------------------||
// ------------------------------------------------------------------------------||
-
+
private static final long serialVersionUID = 1L;
private static final Logger log = Logger.getLogger(SessionSpecProxyInvocationHandlerBase.class);
@@ -74,11 +75,12 @@
* marking this invocation hander as specific to a given
* EJB3 Business Interface
* @param interceptors The interceptors to apply to invocations upon this handler
+ * @param target
*/
protected SessionSpecProxyInvocationHandlerBase(final String containerName, final String containerGuid,
- final Interceptor[] interceptors, final String businessInterfaceType)
+ final Interceptor[] interceptors, final String businessInterfaceType, final Object target)
{
- super(containerName, containerGuid, interceptors);
+ super(containerName, containerGuid, interceptors, target);
this.setBusinessInterfaceType(businessInterfaceType);
}
@@ -91,6 +93,11 @@
*/
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
+ // Precondition check
+ assert proxy instanceof SessionProxy : this + " is eligible for handling " + SessionProxy.class.getName()
+ + " invocations only";
+ SessionProxy sessionProxy = (SessionProxy) proxy;
+
// Obtain an explicitly-specified actual class
String actualClass = this.getBusinessInterfaceType();
@@ -98,7 +105,7 @@
SerializableMethod invokedMethod = new SerializableMethod(method, actualClass);
// Use the overloaded implementation
- return this.invoke(proxy, invokedMethod, args);
+ return this.invoke(sessionProxy, invokedMethod, args);
}
// ------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/service/ServiceProxyInvocationHandlerBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/service/ServiceProxyInvocationHandlerBase.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/service/ServiceProxyInvocationHandlerBase.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -30,8 +30,8 @@
import org.jboss.ejb3.common.lang.SerializableMethod;
import org.jboss.ejb3.proxy.handler.ProxyInvocationHandlerBase;
import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
+import org.jboss.ejb3.proxy.intf.SessionProxy;
import org.jboss.logging.Logger;
-import org.jboss.util.NotImplementedException;
/**
* ServiceProxyInvocationHandlerBase
@@ -84,11 +84,16 @@
*/
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
+ // Precondition check
+ assert proxy instanceof SessionProxy : this + " is eligible for handling " + SessionProxy.class.getName()
+ + " invocations only";
+ SessionProxy sessionProxy = (SessionProxy) proxy;
+
// Set the invoked method as a SerializableMethod
SerializableMethod invokedMethod = new SerializableMethod(method);
// Use the overloaded implementation
- return this.invoke(proxy, invokedMethod, args);
+ return this.invoke(sessionProxy, invokedMethod, args);
}
/**
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulLocalProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulLocalProxyInvocationHandler.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulLocalProxyInvocationHandler.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -44,7 +44,7 @@
// --------------------------------------------------------------------------------||
// Constructor --------------------------------------------------------------------||
// --------------------------------------------------------------------------------||
-
+
/**
* Constructor
*
@@ -55,7 +55,7 @@
public StatefulLocalProxyInvocationHandler(final String containerName, final String containerGuid,
final Interceptor[] interceptors)
{
- super(containerName, containerGuid, interceptors, null);
+ super(containerName, containerGuid, interceptors, null, null);
}
/**
@@ -71,7 +71,7 @@
public StatefulLocalProxyInvocationHandler(final String containerName, final String containerGuid,
final Interceptor[] interceptors, final String businessInterfaceType)
{
- super(containerName, containerGuid, interceptors, businessInterfaceType);
+ super(containerName, containerGuid, interceptors, businessInterfaceType, null);
}
// --------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulProxyInvocationHandlerBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulProxyInvocationHandlerBase.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulProxyInvocationHandlerBase.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -23,13 +23,10 @@
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import org.jboss.aop.advice.Interceptor;
-import org.jboss.ejb3.common.lang.SerializableMethod;
import org.jboss.ejb3.proxy.container.InvokableContext;
-import org.jboss.ejb3.proxy.handler.NotEligibleForDirectInvocationException;
import org.jboss.ejb3.proxy.handler.session.SessionSpecProxyInvocationHandlerBase;
import org.jboss.ejb3.proxy.intf.StatefulSessionProxy;
import org.jboss.ejb3.proxy.remoting.ProxyRemotingUtils;
@@ -57,41 +54,7 @@
private static final Logger log = Logger.getLogger(StatefulProxyInvocationHandlerBase.class);
- private static final String METHOD_NAME_GET_SESSION_ID = "getSessionId";
-
- private static final String METHOD_NAME_SET_SESSION_ID = "setSessionId";
-
- private static final SerializableMethod METHOD_GET_SESSION_ID;
-
- private static final SerializableMethod METHOD_SET_SESSION_ID;
-
- static
- {
- try
- {
- METHOD_GET_SESSION_ID = new SerializableMethod(StatefulSessionProxy.class
- .getDeclaredMethod(METHOD_NAME_GET_SESSION_ID));
- METHOD_SET_SESSION_ID = new SerializableMethod(StatefulSessionProxy.class.getDeclaredMethod(
- METHOD_NAME_SET_SESSION_ID, Serializable.class));
- }
- catch (NoSuchMethodException nsme)
- {
- throw new RuntimeException(
- "Methods for handling directly by the InvocationHandler were not initialized correctly", nsme);
- }
-
- }
-
// ------------------------------------------------------------------------------||
- // Instance Members -------------------------------------------------------------||
- // ------------------------------------------------------------------------------||
-
- /**
- * The Session ID of the SFSB Instance to which this ProxyHandler will delegate
- */
- private Serializable sessionId;
-
- // ------------------------------------------------------------------------------||
// Constructors -----------------------------------------------------------------||
// ------------------------------------------------------------------------------||
@@ -106,9 +69,9 @@
* @param interceptors The interceptors to apply to invocations upon this handler
*/
public StatefulProxyInvocationHandlerBase(final String containerName, final String containerGuid,
- final Interceptor[] interceptors, final String businessInterfaceType)
+ final Interceptor[] interceptors, final String businessInterfaceType, final Object target)
{
- super(containerName, containerGuid, interceptors, businessInterfaceType);
+ super(containerName, containerGuid, interceptors, businessInterfaceType, target);
}
// ------------------------------------------------------------------------------||
@@ -116,26 +79,6 @@
// ------------------------------------------------------------------------------||
/**
- * Obtains the Session ID for this SFSB instance
- *
- * @return
- */
- public Serializable getSessionId()
- {
- return this.sessionId;
- }
-
- /**
- * Sets the Session ID for this SFSB instance
- *
- * @param sessionId
- */
- public void setSessionId(Serializable sessionId)
- {
- this.sessionId = sessionId;
- }
-
- /**
* EJB 3.0 Core Specification 3.4.5.1
*
* Determines Equality for SFSB Proxies
@@ -194,13 +137,12 @@
}
// Equal if Session IDs are equal
- Object sessionId = sHandler.getSessionId();
+ Object sessionId = sHandler.getTarget();
assert sessionId != null : "Required Session ID is not present in " + proxy;
- boolean equal = sessionId.equals(sArgument.getSessionId());
+ boolean equal = sessionId.equals(sArgument.getTarget());
// Return
- log.debug("SFSB Equality Check for " + sHandler.getSessionId() + " and " + sArgument.getSessionId() + " = "
- + equal);
+ log.debug("SFSB Equality Check for " + sHandler.getTarget() + " and " + sArgument.getTarget() + " = " + equal);
return equal;
}
@@ -217,7 +159,7 @@
// Generate unique String by value according to rules in "invokeEquals";
// Destination Container, Session ID, and Business Interface
- String unique = handler.getContainerName() + handler.getBusinessInterfaceType() + handler.getSessionId();
+ String unique = handler.getContainerName() + handler.getBusinessInterfaceType() + handler.getTarget();
// Hash the String
return unique.hashCode();
@@ -236,7 +178,7 @@
protected InvokableContext createRemoteProxyToContainer(String url)
{
InvokableContext container = ProxyRemotingUtils.createRemoteProxyToContainer(this.getContainerName(), this
- .getContainerGuid(), url, this.getInterceptors(), this.getSessionId());
+ .getContainerGuid(), url, this.getInterceptors(), this.getTarget());
return container;
}
@@ -252,42 +194,4 @@
+ StatefulProxyInvocationHandlerBase.class.getName() + ", but instead was " + handler;
return (StatefulProxyInvocationHandlerBase) handler;
}
-
- /**
- * Handles the current invocation directly in this invocation handler. Only
- * a subset of method invocations are eligible for this treatment, else
- * a NotEligibleForDirectInvocationException will be thrown
- *
- * @param proxy
- * @param args Arguments of the current invocation
- * @param invokedMethod The method invoked
- * @return
- * @throws NotEligibleForDirectInvocationException
- */
- @Override
- protected Object handleInvocationDirectly(Object proxy, Object[] args, Method invokedMethod)
- throws NotEligibleForDirectInvocationException
- {
- // Obtain the invoked method
- assert invokedMethod != null : "Invoked Method was not set upon invocation of " + this.getClass().getName();
-
- // getSessionId
- if (invokedMethod.equals(METHOD_GET_SESSION_ID.toMethod()))
- {
- return this.getSessionId();
- }
- // setSessionId
- if (invokedMethod.equals(METHOD_SET_SESSION_ID.toMethod()))
- {
- assert args.length == 1 : "Expecting exactly one argument for invocation of " + METHOD_SET_SESSION_ID;
- Object arg = args[0];
- assert arg instanceof Serializable : "Argument must be instance of " + Serializable.class.getName();
- Serializable id = (Serializable) arg;
- this.setSessionId(id);
- return null;
- }
-
- // Call to super
- return super.handleInvocationDirectly(proxy, args, invokedMethod);
- }
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulRemoteProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulRemoteProxyInvocationHandler.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulRemoteProxyInvocationHandler.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -65,7 +65,7 @@
public StatefulRemoteProxyInvocationHandler(final String containerName, final String containerGuid,
final Interceptor[] interceptors, final String businessInterfaceType, final String url)
{
- super(containerName, containerGuid, interceptors, businessInterfaceType);
+ super(containerName, containerGuid, interceptors, businessInterfaceType, null);
// Set properties
this.setUrl(url);
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessProxyInvocationHandlerBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessProxyInvocationHandlerBase.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessProxyInvocationHandlerBase.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -29,7 +29,6 @@
import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
import org.jboss.ejb3.proxy.handler.session.SessionSpecProxyInvocationHandlerBase;
import org.jboss.logging.Logger;
-import org.jboss.util.NotImplementedException;
/**
* StatelessProxyInvocationHandlerBase
@@ -83,7 +82,7 @@
public StatelessProxyInvocationHandlerBase(final String containerName, final String containerGuid,
final Interceptor[] interceptors, final String businessInterfaceType)
{
- super(containerName, containerGuid, interceptors, businessInterfaceType);
+ super(containerName, containerGuid, interceptors, businessInterfaceType, null);
}
// ------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/ServiceProxy.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/ServiceProxy.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/ServiceProxy.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -30,7 +30,7 @@
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
*/
-public interface ServiceProxy extends EjbProxy
+public interface ServiceProxy extends SessionProxy
{
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/SessionProxy.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/SessionProxy.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/SessionProxy.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -32,5 +32,19 @@
*/
public interface SessionProxy extends EjbProxy
{
+ /**
+ * Obtains the target for this Invocation, used
+ * as Session ID
+ *
+ * @return
+ */
+ Object getTarget();
+ /**
+ * Sets the target for the Invocation, used in practice
+ * for Session ID
+ *
+ * @param sessionId
+ */
+ void setTarget(Object target);
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/StatefulSessionProxy.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/StatefulSessionProxy.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/StatefulSessionProxy.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -21,8 +21,6 @@
*/
package org.jboss.ejb3.proxy.intf;
-import java.io.Serializable;
-
/**
* StatefulSessionProxy
*
@@ -33,17 +31,5 @@
*/
public interface StatefulSessionProxy extends SessionProxy
{
- /**
- * Obtains the Session ID for this SFSB instance
- *
- * @return
- */
- Serializable getSessionId();
- /**
- * Sets the Session ID for this SFSB instance
- *
- * @param sessionId
- */
- void setSessionId(Serializable sessionId);
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/invocation/InvokableContextStatefulRemoteProxyInvocationHack.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/invocation/InvokableContextStatefulRemoteProxyInvocationHack.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/invocation/InvokableContextStatefulRemoteProxyInvocationHack.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -21,7 +21,6 @@
*/
package org.jboss.ejb3.proxy.invocation;
-import java.io.Serializable;
import java.lang.reflect.Method;
import org.jboss.aop.advice.Interceptor;
@@ -31,6 +30,7 @@
import org.jboss.aspects.remoting.PojiProxy;
import org.jboss.ejb3.common.lang.SerializableMethod;
import org.jboss.ejb3.proxy.container.InvokableContext;
+import org.jboss.ejb3.proxy.intf.SessionProxy;
import org.jboss.ejb3.proxy.remoting.SessionSpecRemotingMetadata;
import org.jboss.ejb3.proxy.remoting.StatefulSessionRemotingMetadata;
import org.jboss.logging.Logger;
@@ -66,9 +66,9 @@
// --------------------------------------------------------------------------------||
/**
- * The Session ID to be used in SFSB Invocations
+ * The target (Session ID)
*/
- private Serializable sessionId;
+ private Object target;
/**
* The Globally-Unique ID of the target Container
@@ -80,7 +80,7 @@
// --------------------------------------------------------------------------------||
public InvokableContextStatefulRemoteProxyInvocationHack(Object oid, String containerGuid, InvokerLocator uri,
- Interceptor[] interceptors, Serializable sessionId)
+ Interceptor[] interceptors, Object target)
{
// Call Super Implementation
super(oid, uri, interceptors);
@@ -90,7 +90,7 @@
assert containerGuid != null : "Specified Container GUID is null";
// Set additional properties
- this.setSessionId(sessionId);
+ this.setTarget(target);
this.setContainerGuid(containerGuid);
}
@@ -125,7 +125,7 @@
try
{
expectedInvokeMethod = InvokableContext.class.getDeclaredMethod("invoke", new Class<?>[]
- {Object.class, SerializableMethod.class, Object[].class});
+ {SessionProxy.class, SerializableMethod.class, Object[].class});
}
catch (NoSuchMethodException e)
{
@@ -162,7 +162,7 @@
* via ProxyTestClassProxyHack
*/
MethodInvocation sri = new StatefulRemoteInvocation(this.getInterceptors(), hash, dynamicInvokeMethod,
- dynamicInvokeMethod, null, this.getSessionId());
+ dynamicInvokeMethod, null, this.getTarget());
// Manually add metadata for invoked method
sri.getMetaData().addMetaData(SessionSpecRemotingMetadata.TAG_SESSION_INVOCATION,
@@ -181,14 +181,14 @@
// Call Super implementation
super.addMetadataToInvocation(methodInvocation);
- // Obtain Session ID
- Serializable sessionId = this.getSessionId();
+ // Obtain target
+ Object target = this.getTarget();
// Add to the Invocation Metadata, if exists
- if (sessionId != null)
+ if (target != null)
{
methodInvocation.getMetaData().addMetaData(StatefulSessionRemotingMetadata.TAG_SFSB_INVOCATION,
- StatefulSessionRemotingMetadata.KEY_SESSION_ID, sessionId, PayloadKey.AS_IS);
+ StatefulSessionRemotingMetadata.KEY_SESSION_ID, target, PayloadKey.AS_IS);
}
// Add Container Name
@@ -216,14 +216,14 @@
// Accessors / Mutators -----------------------------------------------------------||
// --------------------------------------------------------------------------------||
- protected Serializable getSessionId()
+ protected Object getTarget()
{
- return sessionId;
+ return target;
}
- private void setSessionId(Serializable sessionId)
+ private void setTarget(Object target)
{
- this.sessionId = sessionId;
+ this.target = target;
}
protected String getContainerGuid()
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/remoting/ProxyRemotingUtils.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/remoting/ProxyRemotingUtils.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/remoting/ProxyRemotingUtils.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -21,7 +21,6 @@
*/
package org.jboss.ejb3.proxy.remoting;
-import java.io.Serializable;
import java.lang.reflect.Proxy;
import java.net.MalformedURLException;
@@ -173,12 +172,12 @@
* @param containerGuid
* @param url
* @param interceptors
- * @param sessionId
+ * @param target
* @return
*/
//FIXME
public static InvokableContext createRemoteProxyToContainer(String containerName, String containerGuid, String url,
- Interceptor[] interceptors, Serializable sessionId)
+ Interceptor[] interceptors, Object target)
{
// Default the remoting URL if necessary
if (url == null || url.trim().length() == 0)
@@ -204,7 +203,7 @@
// Create a POJI Proxy to the Container
PojiProxy handler = new InvokableContextStatefulRemoteProxyInvocationHack(containerName, containerGuid, locator,
- interceptors, sessionId);
+ interceptors, target);
Class<?>[] interfaces = new Class<?>[]
{InvokableContext.class};
InvokableContext container = (InvokableContext) Proxy.newProxyInstance(InvokableContext.class.getClassLoader(),
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/SessionContainer.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/SessionContainer.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/SessionContainer.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -46,6 +46,7 @@
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
import org.jboss.ejb3.common.registrar.spi.NotBoundException;
import org.jboss.ejb3.proxy.container.InvokableContext;
+import org.jboss.ejb3.proxy.intf.SessionProxy;
import org.jboss.ejb3.proxy.intf.StatefulSessionProxy;
import org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase;
import org.jboss.ejb3.proxy.remoting.StatefulSessionRemotingMetadata;
@@ -162,7 +163,7 @@
* @throws Throwable A possible exception thrown by the invocation
* @return
*/
- public Object invoke(Object proxy, SerializableMethod method, Object[] args) throws Throwable
+ public Object invoke(SessionProxy proxy, SerializableMethod method, Object[] args) throws Throwable
{
Method m = method.toMethod(this.getClassLoader());
@@ -273,7 +274,7 @@
public Object invokeBean(Object proxy, Method method, Object args[]) throws Throwable
{
// Initialize a Session ID
- Serializable sessionId = null;
+ Object sessionId = null;
// Obtain the InvocationHandler
if (proxy instanceof StatefulSessionProxy)
@@ -281,11 +282,11 @@
StatefulSessionProxy statefulProxy = (StatefulSessionProxy) proxy;
// Get the Session ID
- sessionId = statefulProxy.getSessionId();
+ sessionId = statefulProxy.getTarget();
}
// Get the appropriate instance
- Object obj = this.getBeanInstance(sessionId);
+ Object obj = this.getBeanInstance((Serializable) sessionId);
// Invoke
return method.invoke(obj, args);
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/unit/SfsbProxyEqualityTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/unit/SfsbProxyEqualityTestCase.java 2009-03-11 09:18:21 UTC (rev 85728)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/unit/SfsbProxyEqualityTestCase.java 2009-03-11 10:01:09 UTC (rev 85729)
@@ -131,7 +131,7 @@
{
// Get the InvocationHander for the Proxy
StatefulSessionProxy handler = (StatefulSessionProxy) proxy;
- handler.setSessionId(id);
+ handler.setTarget(id);
}
/**
More information about the jboss-cvs-commits
mailing list