[jboss-cvs] JBossAS SVN: r107593 - in projects/ejb3/trunk: proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateful and 10 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Aug 13 10:22:23 EDT 2010
Author: ALRubinger
Date: 2010-08-13 10:22:21 -0400 (Fri, 13 Aug 2010)
New Revision: 107593
Added:
projects/ejb3/trunk/proxy-impl/src/test/resources/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SlsbProxyEqualityTestCase-jboss-beans.xml
Modified:
projects/ejb3/trunk/proxy-clustered/pom.xml
projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateful/StatefulSessionClusteredProxyFactory.java
projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateless/StatelessSessionClusteredProxyFactory.java
projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/stateful/StatefulClusteredProxyInvocationHandler.java
projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/stateless/StatelessClusteredProxyInvocationHandler.java
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/SessionProxyFactoryBase.java
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/SessionSpecProxyFactory.java
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/service/ServiceLocalProxyFactory.java
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/service/ServiceRemoteProxyFactory.java
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateful/StatefulSessionLocalProxyFactory.java
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateful/StatefulSessionProxyFactoryBase.java
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateful/StatefulSessionRemoteProxyFactory.java
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateless/StatelessSessionLocalProxyFactory.java
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateless/StatelessSessionRemoteProxyFactory.java
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionLocalProxyInvocationHandler.java
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionProxyInvocationHandlerBase.java
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionRemoteProxyInvocationHandler.java
projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SlsbProxyEqualityTestCase.java
Log:
[EJBTHREE-2148] Associate EJB proxies with session on creation; create remotable proxy to the container only once, not per-invocation
Modified: projects/ejb3/trunk/proxy-clustered/pom.xml
===================================================================
--- projects/ejb3/trunk/proxy-clustered/pom.xml 2010-08-13 13:56:51 UTC (rev 107592)
+++ projects/ejb3/trunk/proxy-clustered/pom.xml 2010-08-13 14:22:21 UTC (rev 107593)
@@ -90,7 +90,7 @@
<dependency>
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-proxy-impl</artifactId>
- <version>1.0.10</version>
+ <version>1.0.11-SNAPSHOT</version>
</dependency>
<dependency>
Modified: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateful/StatefulSessionClusteredProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateful/StatefulSessionClusteredProxyFactory.java 2010-08-13 13:56:51 UTC (rev 107592)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateful/StatefulSessionClusteredProxyFactory.java 2010-08-13 14:22:21 UTC (rev 107593)
@@ -21,6 +21,8 @@
*/
package org.jboss.ejb3.proxy.clustered.factory.session.stateful;
+import java.io.Serializable;
+
import org.jboss.aop.Advisor;
import org.jboss.aop.Dispatcher;
import org.jboss.aop.advice.Interceptor;
@@ -137,34 +139,36 @@
@Override
- protected SessionProxyInvocationHandler createBusinessDefaultInvocationHandler()
+ protected SessionProxyInvocationHandler createBusinessDefaultInvocationHandler(final Serializable sessionId)
{
- return createInvocationHandler(null, false);
+ return createInvocationHandler(null, false, sessionId);
}
@Override
- protected SessionProxyInvocationHandler createBusinessInterfaceSpecificInvocationHandler(String businessInterfaceName)
+ protected SessionProxyInvocationHandler createBusinessInterfaceSpecificInvocationHandler(
+ final Serializable sessionId, String businessInterfaceName)
{
- return createInvocationHandler(businessInterfaceName, false);
+ return createInvocationHandler(businessInterfaceName, false, sessionId);
}
@Override
- protected SessionProxyInvocationHandler createEjb2xComponentInterfaceInvocationHandler()
+ protected SessionProxyInvocationHandler createEjb2xComponentInterfaceInvocationHandler(final Serializable sessionId)
{
- return createInvocationHandler(null, false);
+ return createInvocationHandler(null, false, sessionId);
}
@Override
protected SessionProxyInvocationHandler createHomeInvocationHandler()
{
- return createInvocationHandler(null, true);
+ return createInvocationHandler(null, true, null);
}
// --------------------------------------------------------------------------------||
// Private ------------------------------------------------------------------------||
// --------------------------------------------------------------------------------||
- private SessionProxyInvocationHandler createInvocationHandler(String businessInterfaceName, boolean isOnlyHome)
+ private SessionProxyInvocationHandler createInvocationHandler(String businessInterfaceName, boolean isOnlyHome,
+ final Serializable sessionId)
{
// Obtain target properties
String containerName = this.getContainerName();
@@ -187,8 +191,8 @@
// Create
SessionProxyInvocationHandler handler = new StatefulClusteredProxyInvocationHandler(containerName, containerGuid,
- interceptors, businessInterfaceName, url, beanClusteringInfo.getFamilyWrapper(),
- lbp, beanClusteringInfo.getPartitionName());
+ interceptors, businessInterfaceName, sessionId, url, beanClusteringInfo.getFamilyWrapper(), lbp,
+ beanClusteringInfo.getPartitionName());
// Return
return handler;
Modified: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateless/StatelessSessionClusteredProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateless/StatelessSessionClusteredProxyFactory.java 2010-08-13 13:56:51 UTC (rev 107592)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateless/StatelessSessionClusteredProxyFactory.java 2010-08-13 14:22:21 UTC (rev 107593)
@@ -21,6 +21,8 @@
*/
package org.jboss.ejb3.proxy.clustered.factory.session.stateless;
+import java.io.Serializable;
+
import org.jboss.aop.Advisor;
import org.jboss.aop.Dispatcher;
import org.jboss.aop.advice.Interceptor;
@@ -134,19 +136,20 @@
@Override
- protected SessionProxyInvocationHandler createBusinessDefaultInvocationHandler()
+ protected SessionProxyInvocationHandler createBusinessDefaultInvocationHandler(final Serializable sessionId)
{
return createInvocationHandler(null, false);
}
@Override
- protected SessionProxyInvocationHandler createBusinessInterfaceSpecificInvocationHandler(String businessInterfaceName)
+ protected SessionProxyInvocationHandler createBusinessInterfaceSpecificInvocationHandler(
+ final Serializable sessionId, String businessInterfaceName)
{
return createInvocationHandler(businessInterfaceName, false);
}
@Override
- protected SessionProxyInvocationHandler createEjb2xComponentInterfaceInvocationHandler()
+ protected SessionProxyInvocationHandler createEjb2xComponentInterfaceInvocationHandler(final Serializable sessionId)
{
return createInvocationHandler(null, false);
}
Modified: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/stateful/StatefulClusteredProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/stateful/StatefulClusteredProxyInvocationHandler.java 2010-08-13 13:56:51 UTC (rev 107592)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/stateful/StatefulClusteredProxyInvocationHandler.java 2010-08-13 14:22:21 UTC (rev 107593)
@@ -23,6 +23,7 @@
package org.jboss.ejb3.proxy.clustered.handler.session.stateful;
import java.io.Serializable;
+import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.MalformedURLException;
@@ -58,6 +59,11 @@
private FamilyWrapper family;
private LoadBalancePolicy lbPolicy;
private String partitionName;
+
+ /**
+ * Remote clustering proxy to the container
+ */
+ private final InvokableContext container;
// --------------------------------------------------------------------------------||
// Constructor --------------------------------------------------------------------||
@@ -71,10 +77,10 @@
* @param partitionName name of the cluster partition. Cannot be <code>null</code>.
*/
public StatefulClusteredProxyInvocationHandler(String containerName, String containerGuid,
- Interceptor[] interceptors, String businessInterfaceType, String url, FamilyWrapper family,
+ Interceptor[] interceptors, String businessInterfaceType, Object target, String url, FamilyWrapper family,
LoadBalancePolicy lb, String partitionName)
{
- super(containerName, containerGuid, interceptors, businessInterfaceType, url);
+ super(containerName, containerGuid, interceptors, businessInterfaceType, target, url);
assert family != null : "family is null";
assert lb != null : "lb is null";
@@ -83,15 +89,12 @@
this.family = family;
this.lbPolicy = lb;
this.partitionName = partitionName;
- }
-
- // --------------------------------------------------------------------------------||
- // Required Implementations -------------------------------------------------------||
- // --------------------------------------------------------------------------------||
-
- @Override
- protected InvokableContext createRemoteProxyToContainer(String url)
- {
+
+
+ /*
+ * Now create the clustering remote proxy to the container
+ */
+
// Create an InvokerLocator
InvokerLocator locator = null;
try
@@ -109,23 +112,35 @@
*/
// Get interceptors from the stack
- Interceptor[] interceptors = this.getInterceptors();
+ final Interceptor[] resolvedInterceptors = this.getInterceptors();
/*
* Create Proxy
*/
// Create a POJI Proxy to the Container
- String containerName = this.getContainerName();
assert containerName != null && containerName.trim().length() > 0 : "Container Name must be set";
- PojiProxy handler = new InvokableContextClusteredProxyInvocationHandler(this.getContainerName(), this
- .getContainerGuid(), locator, interceptors, (Serializable) this.getTarget(), this.getFamilyWrapper(), this
- .getLoadBalancePolicy(), this.getPartitionName(), true);
+ PojiProxy handler = new InvokableContextClusteredProxyInvocationHandler(this.getContainerName(),
+ this.getContainerGuid(), locator, resolvedInterceptors, (Serializable) this.getTarget(),
+ this.getFamilyWrapper(), this.getLoadBalancePolicy(), this.getPartitionName(), true);
Class<?>[] interfaces = new Class<?>[]
{InvokableContext.class};
- InvokableContext container = (InvokableContext) Proxy.newProxyInstance(InvokableContext.class.getClassLoader(),
- interfaces, handler);
+ final InvokableContext container = (InvokableContext) Proxy.newProxyInstance(
+ InvokableContext.class.getClassLoader(), interfaces, handler);
+ this.container = container;
+ }
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.ejb3.proxy.impl.handler.session.SessionRemoteProxyInvocationHandler#getContainer(java.lang.reflect.Method, java.lang.Object[])
+ */
+ @Override
+ protected InvokableContext getContainer(final Method method, final Object[] args)
+ {
// Return
return container;
}
Modified: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/stateless/StatelessClusteredProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/stateless/StatelessClusteredProxyInvocationHandler.java 2010-08-13 13:56:51 UTC (rev 107592)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/stateless/StatelessClusteredProxyInvocationHandler.java 2010-08-13 14:22:21 UTC (rev 107593)
@@ -21,6 +21,7 @@
*/
package org.jboss.ejb3.proxy.clustered.handler.session.stateless;
+import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.MalformedURLException;
@@ -55,6 +56,8 @@
private FamilyWrapper family;
private LoadBalancePolicy lbPolicy;
private String partitionName;
+
+ private final InvokableContext container;
// --------------------------------------------------------------------------------||
// Constructor --------------------------------------------------------------------||
@@ -71,33 +74,17 @@
final Interceptor[] interceptors, final String businessInterfaceType, final String url,
FamilyWrapper family, LoadBalancePolicy lb, String partitionName)
{
- super(containerName, containerGuid, interceptors, businessInterfaceType, url);
-
- assert family != null : "family is null";
- assert lb != null : "lb is null";
+ super(containerName, containerGuid, interceptors, businessInterfaceType, null, url);
+
+ assert family != null : "family is null";
+ assert lb != null : "lb is null";
assert partitionName != null : "partitionName is null";
-
+
this.family = family;
this.lbPolicy = lb;
- this.partitionName = partitionName;
- }
+ this.partitionName = partitionName;
- // --------------------------------------------------------------------------------||
- // Functional Methods -------------------------------------------------------------||
- // --------------------------------------------------------------------------------||
-
- /**
- * Creates and returns a Remoting Proxy to invoke upon the container
- *
- * @param url The location of the remote host holding the Container
- * @return
- */
- //FIXME Mostly a copy of the SFSB Remote Handler, but passing null
- // as a SessionID. Should be using more intelligent design, SLSB's have
- // no Sessions. To be reworked in InvokableContextStatefulRemoteProxyInvocationHack,
- // as this implementation is @deprecated
- protected InvokableContext createRemoteProxyToContainer(String url)
- { // Create an InvokerLocator
+ // Create an InvokerLocator
InvokerLocator locator = null;
try
{
@@ -109,36 +96,34 @@
+ "\"", e);
}
- /*
- * Define interceptors
- */
-
- // Get interceptors from the stack
- Interceptor[] interceptors = this.getInterceptors();
-
- /*
- * Create Proxy
- */
-
// Create a POJI Proxy to the Container
- String containerName = this.getContainerName();
assert containerName != null && containerName.trim().length() > 0 : "Container Name must be set";
- PojiProxy handler = new InvokableContextClusteredProxyInvocationHandler(this.getContainerName(),
- this.getContainerGuid(), locator, interceptors, null, this.getFamilyWrapper(),
- this.getLoadBalancePolicy(), this.getPartitionName(), false);
+ PojiProxy handler = new InvokableContextClusteredProxyInvocationHandler(this.getContainerName(),
+ this.getContainerGuid(), locator, interceptors, null, this.getFamilyWrapper(), this.getLoadBalancePolicy(),
+ this.getPartitionName(), false);
Class<?>[] interfaces = new Class<?>[]
{InvokableContext.class};
InvokableContext container = (InvokableContext) Proxy.newProxyInstance(InvokableContext.class.getClassLoader(),
interfaces, handler);
-
- // Return
- return container;
+ this.container = container;
}
+
// --------------------------------------------------------------------------------||
// Accessors / Mutators -----------------------------------------------------------||
// --------------------------------------------------------------------------------||
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.ejb3.proxy.impl.handler.session.SessionRemoteProxyInvocationHandler#getContainer(java.lang.reflect.Method, java.lang.Object[])
+ */
+ @Override
+ protected InvokableContext getContainer(Method method, Object[] args)
+ {
+ return container;
+ }
+
+
public FamilyWrapper getFamilyWrapper()
{
return family;
Modified: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/SessionProxyFactoryBase.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/SessionProxyFactoryBase.java 2010-08-13 13:56:51 UTC (rev 107592)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/SessionProxyFactoryBase.java 2010-08-13 14:22:21 UTC (rev 107593)
@@ -21,6 +21,7 @@
*/
package org.jboss.ejb3.proxy.impl.factory.session;
+import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -157,7 +158,7 @@
*
* @return
*/
- public Object createProxyDefault()
+ public Object createProxyDefault(final Serializable sessionId)
{
// Obtain Constructor to Default Proxy
Constructor<?> constructor = this.getConstructorProxyDefault();
@@ -165,7 +166,7 @@
+ SessionProxyFactory.class.getSimpleName() + " was not properly started?";
// Create a new InvocationHandler
- SessionProxyInvocationHandler handler = this.createBusinessDefaultInvocationHandler();
+ SessionProxyInvocationHandler handler = this.createBusinessDefaultInvocationHandler(sessionId);
try
{
@@ -187,7 +188,7 @@
* @param businessInterfaceName
* @return
*/
- public Object createProxyBusiness(final String businessInterfaceName)
+ public Object createProxyBusiness(final Serializable sessionId, final String businessInterfaceName)
{
// Ensure businessInterfaceName is specified
assert businessInterfaceName != null && businessInterfaceName.trim().length() > 0 : "Required business interface type name was not specified";
@@ -204,8 +205,8 @@
+ "\" was found; not created at start() properly? Bad value bound as RefAddr in JNDI?";
// Create a new InvocationHandler
- SessionProxyInvocationHandler handler = this
- .createBusinessInterfaceSpecificInvocationHandler(businessInterfaceName);
+ SessionProxyInvocationHandler handler = this.createBusinessInterfaceSpecificInvocationHandler(sessionId,
+ businessInterfaceName);
// Create a new Proxy instance
Object proxy = constructor.newInstance(handler);
@@ -226,10 +227,10 @@
*
* @return
*/
- public Object createProxyEjb2x()
+ public Object createProxyEjb2x(final Serializable sessionId)
{
// Create a new InvocationHandler
- SessionProxyInvocationHandler handler = this.createEjb2xComponentInterfaceInvocationHandler();
+ SessionProxyInvocationHandler handler = this.createEjb2xComponentInterfaceInvocationHandler(sessionId);
try
{
@@ -591,7 +592,7 @@
* @return
*/
protected abstract SessionProxyInvocationHandler createBusinessInterfaceSpecificInvocationHandler(
- String businessInterfaceName);
+ Serializable target, String businessInterfaceName);
/**
* Returns the Constructor of the SessionProxyInvocationHandler to be used in
@@ -601,7 +602,7 @@
*
* @return
*/
- protected abstract SessionProxyInvocationHandler createBusinessDefaultInvocationHandler();
+ protected abstract SessionProxyInvocationHandler createBusinessDefaultInvocationHandler(Serializable target);
/**
* Returns the Constructor of the SessionProxyInvocationHandler to be used in
@@ -611,7 +612,7 @@
*
* @return
*/
- protected abstract SessionProxyInvocationHandler createEjb2xComponentInterfaceInvocationHandler();
+ protected abstract SessionProxyInvocationHandler createEjb2xComponentInterfaceInvocationHandler(Serializable target);
/**
* Returns the Constructor of the SessionProxyInvocationHandler to be used in
Modified: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/SessionSpecProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/SessionSpecProxyFactory.java 2010-08-13 13:56:51 UTC (rev 107592)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/SessionSpecProxyFactory.java 2010-08-13 14:22:21 UTC (rev 107593)
@@ -21,6 +21,7 @@
*/
package org.jboss.ejb3.proxy.impl.factory.session;
+
/**
* SessionSpecProxyFactory
*
Modified: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/service/ServiceLocalProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/service/ServiceLocalProxyFactory.java 2010-08-13 13:56:51 UTC (rev 107592)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/service/ServiceLocalProxyFactory.java 2010-08-13 14:22:21 UTC (rev 107593)
@@ -99,8 +99,8 @@
Interceptor[] interceptors = this.getInterceptors();
// Create
- SessionLocalProxyInvocationHandler handler = new SessionLocalProxyInvocationHandler(containerName,
- containerGuid, interceptors, null);
+ SessionLocalProxyInvocationHandler handler = new SessionLocalProxyInvocationHandler(containerName, containerGuid,
+ interceptors, null, null);
// Return
return handler;
Modified: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/service/ServiceRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/service/ServiceRemoteProxyFactory.java 2010-08-13 13:56:51 UTC (rev 107592)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/service/ServiceRemoteProxyFactory.java 2010-08-13 14:22:21 UTC (rev 107593)
@@ -121,7 +121,7 @@
// Create
SessionRemoteProxyInvocationHandler handler = new SessionRemoteProxyInvocationHandler(containerName,
- containerGuid, interceptors, null, url);
+ containerGuid, interceptors, null, null, url);
// Return
return handler;
Modified: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateful/StatefulSessionLocalProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateful/StatefulSessionLocalProxyFactory.java 2010-08-13 13:56:51 UTC (rev 107592)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateful/StatefulSessionLocalProxyFactory.java 2010-08-13 14:22:21 UTC (rev 107593)
@@ -21,6 +21,7 @@
*/
package org.jboss.ejb3.proxy.impl.factory.session.stateful;
+import java.io.Serializable;
import java.util.Set;
import org.jboss.aop.Advisor;
@@ -115,7 +116,8 @@
// --------------------------------------------------------------------------------||
@Override
- protected SessionProxyInvocationHandler createBusinessInterfaceSpecificInvocationHandler(String businessInterfaceName)
+ protected SessionProxyInvocationHandler createBusinessInterfaceSpecificInvocationHandler(
+ final Serializable sessionId, String businessInterfaceName)
{
// Obtain target container name
String containerName = this.getContainerName();
@@ -126,28 +128,28 @@
// Create
SessionProxyInvocationHandler handler = new SessionLocalProxyInvocationHandler(containerName, containerGuid,
- interceptors, businessInterfaceName);
+ interceptors, businessInterfaceName, sessionId);
// Return
return handler;
}
@Override
- protected SessionProxyInvocationHandler createBusinessDefaultInvocationHandler()
+ protected SessionProxyInvocationHandler createBusinessDefaultInvocationHandler(final Serializable sessionId)
{
- return this.createBusinessInterfaceSpecificInvocationHandler(null);
+ return this.createBusinessInterfaceSpecificInvocationHandler(sessionId, null);
}
@Override
- protected SessionProxyInvocationHandler createEjb2xComponentInterfaceInvocationHandler()
+ protected SessionProxyInvocationHandler createEjb2xComponentInterfaceInvocationHandler(final Serializable sessionId)
{
- return this.createBusinessDefaultInvocationHandler();
+ return this.createBusinessDefaultInvocationHandler(sessionId);
}
@Override
protected SessionProxyInvocationHandler createHomeInvocationHandler()
{
- return this.createBusinessDefaultInvocationHandler();
+ return this.createBusinessDefaultInvocationHandler(null);
}
/**
Modified: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateful/StatefulSessionProxyFactoryBase.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateful/StatefulSessionProxyFactoryBase.java 2010-08-13 13:56:51 UTC (rev 107592)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateful/StatefulSessionProxyFactoryBase.java 2010-08-13 14:22:21 UTC (rev 107593)
@@ -22,8 +22,6 @@
package org.jboss.ejb3.proxy.impl.factory.session.stateful;
import java.io.Serializable;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
import java.util.Set;
import org.jboss.aop.Advisor;
@@ -31,7 +29,6 @@
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
import org.jboss.ejb3.common.registrar.spi.NotBoundException;
import org.jboss.ejb3.proxy.impl.factory.session.SessionProxyFactoryBase;
-import org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandler;
import org.jboss.ejb3.proxy.spi.container.StatefulSessionFactory;
import org.jboss.logging.Logger;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
@@ -176,30 +173,6 @@
}
/**
- * Create an EJB3 Business proxy with no
- * specific target business interface. The
- * returned proxy will implement all appropriate
- * business interfaces. Additionally, if
- * the Home interface is bound alongside
- * the Default (same JNDI Name), this
- * Proxy will implement the Home interface as well.
- *
- * @param sessionId
- * @return
- */
- public Object createProxyDefault(Serializable sessionId)
- {
- // Obtain Proxy using Super Implementation
- Object proxy = super.createProxyDefault();
-
- // Associate with session
- this.associateProxyWithSession(proxy, sessionId);
-
- // Return
- return proxy;
- }
-
- /**
* Create an EJB3 Business Proxy specific to the specified
* target business interface name (expressed as
* a fully-qualified class name)
@@ -211,11 +184,8 @@
public Object createProxyBusiness(Serializable sessionId, String businessInterfaceName)
{
// Obtain Proxy using Super Implementation
- Object proxy = super.createProxyBusiness(businessInterfaceName);
+ Object proxy = super.createProxyBusiness(sessionId, businessInterfaceName);
- // Associate with session
- this.associateProxyWithSession(proxy, sessionId);
-
// Return
return proxy;
}
@@ -229,11 +199,8 @@
public Object createProxyEjb2x(Serializable sessionId)
{
// Obtain Proxy using Super Implementation
- Object proxy = super.createProxyEjb2x();
+ Object proxy = super.createProxyEjb2x(sessionId);
- // Associate with session
- this.associateProxyWithSession(proxy, sessionId);
-
// Return
return proxy;
}
@@ -241,28 +208,8 @@
// --------------------------------------------------------------------------------||
// Internal Helper Methods --------------------------------------------------------||
// --------------------------------------------------------------------------------||
-
/**
- * Associates the specified Proxy with the session denoted by
- * the specified sessionId
- *
- * @param proxy
- * @param sessionId
- */
- protected void associateProxyWithSession(Object proxy, Serializable sessionId)
- {
- // Obtain the InvocationHandler
- InvocationHandler handler = Proxy.getInvocationHandler(proxy);
- assert handler instanceof SessionProxyInvocationHandler : "SFSB Proxy must be of type "
- + SessionProxyInvocationHandler.class.getName();
- SessionProxyInvocationHandler sHandler = (SessionProxyInvocationHandler) handler;
-
- // Set the Session ID on the Proxy
- sHandler.setTarget(sessionId);
- }
-
- /**
* Creates a new Session on the container and returns the ID
* representing this newly-created session
*
Modified: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateful/StatefulSessionRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateful/StatefulSessionRemoteProxyFactory.java 2010-08-13 13:56:51 UTC (rev 107592)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateful/StatefulSessionRemoteProxyFactory.java 2010-08-13 14:22:21 UTC (rev 107593)
@@ -21,6 +21,7 @@
*/
package org.jboss.ejb3.proxy.impl.factory.session.stateful;
+import java.io.Serializable;
import java.util.Set;
import org.jboss.aop.Advisor;
@@ -132,7 +133,8 @@
// --------------------------------------------------------------------------------||
@Override
- protected SessionProxyInvocationHandler createBusinessInterfaceSpecificInvocationHandler(String businessInterfaceName)
+ protected SessionProxyInvocationHandler createBusinessInterfaceSpecificInvocationHandler(Serializable target,
+ String businessInterfaceName)
{
// Obtain target properties
String containerName = this.getContainerName();
@@ -144,28 +146,28 @@
// Create
SessionProxyInvocationHandler handler = new SessionRemoteProxyInvocationHandler(containerName, containerGuid,
- interceptors, businessInterfaceName, url);
+ interceptors, businessInterfaceName, target, url);
// Return
return handler;
}
@Override
- protected SessionProxyInvocationHandler createBusinessDefaultInvocationHandler()
+ protected SessionProxyInvocationHandler createBusinessDefaultInvocationHandler(final Serializable target)
{
- return this.createBusinessInterfaceSpecificInvocationHandler(null);
+ return this.createBusinessInterfaceSpecificInvocationHandler(target,null);
}
@Override
- protected SessionProxyInvocationHandler createEjb2xComponentInterfaceInvocationHandler()
+ protected SessionProxyInvocationHandler createEjb2xComponentInterfaceInvocationHandler(final Serializable target)
{
- return this.createBusinessDefaultInvocationHandler();
+ return this.createBusinessDefaultInvocationHandler(target);
}
@Override
protected SessionProxyInvocationHandler createHomeInvocationHandler()
{
- return this.createBusinessDefaultInvocationHandler();
+ return this.createBusinessDefaultInvocationHandler(null);
}
/**
Modified: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateless/StatelessSessionLocalProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateless/StatelessSessionLocalProxyFactory.java 2010-08-13 13:56:51 UTC (rev 107592)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateless/StatelessSessionLocalProxyFactory.java 2010-08-13 14:22:21 UTC (rev 107593)
@@ -21,6 +21,7 @@
*/
package org.jboss.ejb3.proxy.impl.factory.session.stateless;
+import java.io.Serializable;
import java.util.Set;
import org.jboss.aop.Advisor;
@@ -48,7 +49,7 @@
// --------------------------------------------------------------------------------||
private static final Logger logger = Logger.getLogger(StatelessSessionLocalProxyFactory.class);
-
+
/**
* Default interceptor stack name
*/
@@ -118,7 +119,8 @@
// --------------------------------------------------------------------------------||
@Override
- protected SessionProxyInvocationHandler createBusinessInterfaceSpecificInvocationHandler(String businessInterfaceName)
+ protected SessionProxyInvocationHandler createBusinessInterfaceSpecificInvocationHandler(final Serializable target,
+ final String businessInterfaceName)
{
// Obtain container name
String containerName = this.getContainerName();
@@ -129,30 +131,30 @@
// Create
SessionProxyInvocationHandler handler = new SessionLocalProxyInvocationHandler(containerName, containerGuid,
- interceptors, businessInterfaceName);
+ interceptors, businessInterfaceName, target);
// Return
return handler;
}
@Override
- protected SessionProxyInvocationHandler createBusinessDefaultInvocationHandler()
+ protected SessionProxyInvocationHandler createBusinessDefaultInvocationHandler(final Serializable target)
{
- return this.createBusinessInterfaceSpecificInvocationHandler(null);
+ return this.createBusinessInterfaceSpecificInvocationHandler(null, null);
}
@Override
- protected SessionProxyInvocationHandler createEjb2xComponentInterfaceInvocationHandler()
+ protected SessionProxyInvocationHandler createEjb2xComponentInterfaceInvocationHandler(final Serializable target)
{
- return this.createBusinessDefaultInvocationHandler();
+ return this.createBusinessDefaultInvocationHandler(target);
}
@Override
protected SessionProxyInvocationHandler createHomeInvocationHandler()
{
- return this.createBusinessDefaultInvocationHandler();
+ return this.createBusinessDefaultInvocationHandler(null);
}
-
+
/**
* {@inheritDoc}
* @see org.jboss.ejb3.proxy.impl.factory.ProxyFactoryBase#getDefaultInterceptorStackName()
@@ -162,4 +164,26 @@
{
return DEFAULT_STACK_NAME_LOCAL_CLIENT_INTERCEPTORS;
}
+
+ @Override
+ public Object createProxyBusiness(String businessInterfaceName)
+ {
+ return this.createProxyBusiness(null, businessInterfaceName);
+ }
+
+ @Override
+ public Object createProxyEjb2x()
+ {
+ return this.createProxyEjb2x(null);
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.ejb3.proxy.impl.factory.session.SessionProxyFactory#createProxyDefault()
+ */
+ @Override
+ public Object createProxyDefault()
+ {
+ return super.createProxyDefault(null);
+ }
}
Modified: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateless/StatelessSessionRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateless/StatelessSessionRemoteProxyFactory.java 2010-08-13 13:56:51 UTC (rev 107592)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/factory/session/stateless/StatelessSessionRemoteProxyFactory.java 2010-08-13 14:22:21 UTC (rev 107593)
@@ -21,6 +21,7 @@
*/
package org.jboss.ejb3.proxy.impl.factory.session.stateless;
+import java.io.Serializable;
import java.util.Set;
import org.jboss.aop.Advisor;
@@ -134,7 +135,8 @@
// --------------------------------------------------------------------------------||
@Override
- protected SessionProxyInvocationHandler createBusinessInterfaceSpecificInvocationHandler(String businessInterfaceName)
+ protected SessionProxyInvocationHandler createBusinessInterfaceSpecificInvocationHandler(Serializable target,
+ String businessInterfaceName)
{
// Obtain properties
String containerName = this.getContainerName();
@@ -146,28 +148,28 @@
// Create
SessionProxyInvocationHandler handler = new SessionRemoteProxyInvocationHandler(containerName, containerGuid,
- interceptors, businessInterfaceName, url);
+ interceptors, businessInterfaceName, target, url);
// Return
return handler;
}
@Override
- protected SessionProxyInvocationHandler createBusinessDefaultInvocationHandler()
+ protected SessionProxyInvocationHandler createBusinessDefaultInvocationHandler(final Serializable target)
{
- return this.createBusinessInterfaceSpecificInvocationHandler(null);
+ return this.createBusinessInterfaceSpecificInvocationHandler(target, null);
}
@Override
- protected SessionProxyInvocationHandler createEjb2xComponentInterfaceInvocationHandler()
+ protected SessionProxyInvocationHandler createEjb2xComponentInterfaceInvocationHandler(final Serializable target)
{
- return this.createBusinessDefaultInvocationHandler();
+ return this.createBusinessDefaultInvocationHandler(target);
}
@Override
protected SessionProxyInvocationHandler createHomeInvocationHandler()
{
- return this.createBusinessDefaultInvocationHandler();
+ return this.createBusinessDefaultInvocationHandler(null);
}
/**
@@ -180,6 +182,36 @@
return DEFAULT_STACK_NAME_STATELESS_SESSION_CLIENT_INTERCEPTORS;
}
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.ejb3.proxy.impl.factory.session.SessionSpecProxyFactory#createProxyBusiness(java.lang.String)
+ */
+ @Override
+ public Object createProxyBusiness(String businessInterfaceName)
+ {
+ return this.createProxyBusiness(null, businessInterfaceName);
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.ejb3.proxy.impl.factory.session.SessionSpecProxyFactory#createProxyEjb2x()
+ */
+ @Override
+ public Object createProxyEjb2x()
+ {
+ return this.createProxyEjb2x(null);
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.ejb3.proxy.impl.factory.session.SessionProxyFactory#createProxyDefault()
+ */
+ @Override
+ public Object createProxyDefault()
+ {
+ return super.createProxyDefault(null);
+ }
+
// --------------------------------------------------------------------------------||
// Accessors / Mutators -----------------------------------------------------------||
// --------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionLocalProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionLocalProxyInvocationHandler.java 2010-08-13 13:56:51 UTC (rev 107592)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionLocalProxyInvocationHandler.java 2010-08-13 14:22:21 UTC (rev 107593)
@@ -22,9 +22,18 @@
package org.jboss.ejb3.proxy.impl.handler.session;
import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import org.jboss.aop.Advisor;
import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.util.MethodHashing;
+import org.jboss.ejb3.common.lang.SerializableMethod;
+import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
+import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.proxy.impl.invocation.StatefulRemoteInvocation;
import org.jboss.ejb3.proxy.spi.container.InvokableContext;
/**
@@ -70,22 +79,126 @@
* @param interceptors The interceptors to apply to invocations upon this handler
*/
public SessionLocalProxyInvocationHandler(final String containerName, final String containerGuid,
- final Interceptor[] interceptors, final String businessInterfaceType)
+ final Interceptor[] interceptors, final String businessInterfaceType, final Serializable sessionId)
{
- super(containerName, containerGuid, interceptors, businessInterfaceType, null);
+ super(containerName, containerGuid, interceptors, businessInterfaceType, sessionId);
}
// --------------------------------------------------------------------------------||
// Required Implementations -------------------------------------------------------||
// --------------------------------------------------------------------------------||
-
- /* (non-Javadoc)
- * @see org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandlerBase#getContainer()
+
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase#getContainer(java.lang.reflect.Method, java.lang.Object[])
*/
@Override
protected InvokableContext getContainer(final Method method, final Object[] args)
{
- return this.getContainerLocally(method,args);
+ // Lookup
+ Object obj = Ejb3RegistrarLocator.locateRegistrar().lookup(this.getContainerName());
+
+ // Ensure of correct type
+ assert obj instanceof InvokableContext : "Container retrieved from " + Ejb3Registrar.class.getSimpleName()
+ + " was not of expected type " + InvokableContext.class.getName() + " but was instead " + obj;
+
+ final InvokableContext container = (InvokableContext) obj;
+
+ final InvokableContext proxyToContainer = (InvokableContext) Proxy.newProxyInstance(InvokableContext.class
+ .getClassLoader(), new Class<?>[]
+ {InvokableContext.class}, new LocalInvokableContextHandler(method, args, this.getTarget(), this.getInterceptors(),
+ container));
+
+ // Return
+ return proxyToContainer;
}
+
+ // --------------------------------------------------------------------------------||
+ // Internal Helper Members --------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Invocation handler to adapt interceptors to local invocations
+ * upon the container
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+ private static final class LocalInvokableContextHandler implements InvocationHandler
+ {
+ private final Method realMethod;
+
+ private final Object[] realArgs;
+
+ private final Object session;
+
+ private final Interceptor[] interceptors;
+ final InvokableContext container;
+
+ LocalInvokableContextHandler(final Method realMethod, final Object[] realArgs, final Object session,
+ final Interceptor[] interceptors,final InvokableContext container)
+ {
+ assert realMethod != null : "method must be specified";
+ assert realArgs != null : "realArgs must be specified";
+ assert interceptors != null : "interceptors must be specified";
+ assert container != null : "container must be specified";
+ this.realMethod = realMethod;
+ this.realArgs = realArgs;
+ this.session = session;
+ this.interceptors = interceptors;
+ this.container = container;
+
+ }
+
+ public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable
+ {
+ final long hash = MethodHashing.calculateHash(realMethod);
+ final LocalContainerInvocation invocation = new LocalContainerInvocation(interceptors, hash, realMethod,
+ realMethod, null, session);
+ invocation.setTargetObject(container);
+ invocation.setArguments(args);
+ return invocation.invokeNext();
+ }
+ }
+
+ /**
+ * Adaptor invocation implementation to intercept based on real methods,
+ * yet invoke the target {@link InvokableContext} at the end
+ * of the interceptor chain
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ */
+ private static class LocalContainerInvocation extends StatefulRemoteInvocation{
+
+ public LocalContainerInvocation(Interceptor[] interceptors, long methodHash, Method advisedMethod,
+ Method unadvisedMethod, Advisor advisor, Object id)
+ {
+ super(interceptors, methodHash, advisedMethod, unadvisedMethod, advisor, id);
+ }
+
+ @Override
+ public Object invokeTarget() throws Throwable
+ {
+ try
+ {
+ final Method methodToInvoke =InvokableContext.class.getMethod("invoke", Object.class,
+ SerializableMethod.class, Object[].class);
+ return methodToInvoke.invoke(getTargetObject(), arguments);
+ }
+ catch (Throwable t)
+ {
+ throw handleErrors(getTargetObject(), getMethod(), arguments, t);
+ }
+ }
+
+ @Override
+ public Invocation copy()
+ {
+ final LocalContainerInvocation copy = new LocalContainerInvocation(this.interceptors, this.methodHash, this.advisedMethod,
+ this.unadvisedMethod, this.advisor, this.id);
+ copy.setMetaData(this.getMetaData());
+ copy.setArguments(this.getArguments());
+ copy.setTargetObject(targetObject);
+ return copy;
+ }
+ }
+
}
Modified: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionProxyInvocationHandlerBase.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionProxyInvocationHandlerBase.java 2010-08-13 13:56:51 UTC (rev 107592)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionProxyInvocationHandlerBase.java 2010-08-13 14:22:21 UTC (rev 107593)
@@ -28,16 +28,8 @@
import java.util.HashSet;
import java.util.Set;
-import org.jboss.aop.Advisor;
import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.InvocationResponse;
-import org.jboss.aop.util.MethodHashing;
import org.jboss.ejb3.common.lang.SerializableMethod;
-import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
-import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
-import org.jboss.ejb3.proxy.impl.invocation.StatefulRemoteInvocation;
-import org.jboss.ejb3.proxy.impl.remoting.ProxyRemotingUtils;
import org.jboss.ejb3.proxy.spi.container.InvokableContext;
import org.jboss.logging.Logger;
@@ -405,136 +397,6 @@
return hash;
}
- /**
- * Returns the container housed locally
- *
- * @return
- */
- protected InvokableContext getContainerLocally(final Method method, final Object[] args)
- {
- // Lookup
- Object obj = Ejb3RegistrarLocator.locateRegistrar().lookup(this.getContainerName());
-
- // Ensure of correct type
- assert obj instanceof InvokableContext : "Container retrieved from " + Ejb3Registrar.class.getSimpleName()
- + " was not of expected type " + InvokableContext.class.getName() + " but was instead " + obj;
-
- final InvokableContext container = (InvokableContext) obj;
-
- final InvokableContext proxyToContainer = (InvokableContext) Proxy.newProxyInstance(InvokableContext.class
- .getClassLoader(), new Class<?>[]
- {InvokableContext.class}, new LocalInvokableContextHandler(method, args, this.target, this.interceptors,
- container));
-
- // Return
- return proxyToContainer;
- }
-
- /**
- * Invocation handler to adapt interceptors to local invocations
- * upon the container
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- */
- private static final class LocalInvokableContextHandler implements InvocationHandler
- {
-
- private final Method realMethod;
-
- private final Object[] realArgs;
-
- private final Object session;
-
- private final Interceptor[] interceptors;
- final InvokableContext container;
-
- LocalInvokableContextHandler(final Method realMethod, final Object[] realArgs, final Object session,
- final Interceptor[] interceptors,final InvokableContext container)
- {
- assert realMethod != null : "method must be specified";
- assert realArgs != null : "realArgs must be specified";
- assert interceptors != null : "interceptors must be specified";
- assert container != null : "container must be specified";
- this.realMethod = realMethod;
- this.realArgs = realArgs;
- this.session = session;
- this.interceptors = interceptors;
- this.container = container;
-
- }
-
- public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable
- {
- final long hash = MethodHashing.calculateHash(realMethod);
- final LocalContainerInvocation invocation = new LocalContainerInvocation(interceptors, hash, realMethod,
- realMethod, null, session);
- invocation.setTargetObject(container);
- invocation.setArguments(args);
- return invocation.invokeNext();
- }
-
- }
-
- /**
- * Adaptor invocation implementation to intercept based on real methods,
- * yet invoke the target {@link InvokableContext} at the end
- * of the interceptor chain
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- */
- private static class LocalContainerInvocation extends StatefulRemoteInvocation{
-
- public LocalContainerInvocation(Interceptor[] interceptors, long methodHash, Method advisedMethod,
- Method unadvisedMethod, Advisor advisor, Object id)
- {
- super(interceptors, methodHash, advisedMethod, unadvisedMethod, advisor, id);
- }
-
- @Override
- public Object invokeTarget() throws Throwable
- {
- try
- {
- final Method methodToInvoke =InvokableContext.class.getMethod("invoke", Object.class,
- SerializableMethod.class, Object[].class);
- return methodToInvoke.invoke(getTargetObject(), arguments);
- }
- catch (Throwable t)
- {
- throw handleErrors(getTargetObject(), getMethod(), arguments, t);
- }
- }
-
- @Override
- public Invocation copy()
- {
- final LocalContainerInvocation copy = new LocalContainerInvocation(this.interceptors, this.methodHash, this.advisedMethod,
- this.unadvisedMethod, this.advisor, this.id);
- copy.setMetaData(this.getMetaData());
- copy.setArguments(this.getArguments());
- copy.setTargetObject(targetObject);
- return copy;
- }
-
-
-
- }
-
- /**
- * Creates and returns a Remoting Proxy to invoke upon the container
- *
- * This implementation is marked as FIXME as remoting should be an add-on
- * capability atop ejb3-proxy
- *
- * @param url The location of the remote host holding the Container
- * @return
- */
- //FIXME
- protected InvokableContext createRemoteProxyToContainer(String url)
- {
- InvokableContext container = ProxyRemotingUtils.createRemoteProxyToContainer(this.getContainerName(),
- this.getContainerGuid(), url, this.getInterceptors(), this.getTarget());
- return container;
- }
-
// ------------------------------------------------------------------------------||
// Contracts --------------------------------------------------------------------||
// ------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionRemoteProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionRemoteProxyInvocationHandler.java 2010-08-13 13:56:51 UTC (rev 107592)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/handler/session/SessionRemoteProxyInvocationHandler.java 2010-08-13 14:22:21 UTC (rev 107593)
@@ -25,6 +25,7 @@
import java.lang.reflect.Method;
import org.jboss.aop.advice.Interceptor;
+import org.jboss.ejb3.proxy.impl.remoting.ProxyRemotingUtils;
import org.jboss.ejb3.proxy.spi.container.InvokableContext;
/**
@@ -48,6 +49,11 @@
private String url;
+ /**
+ * Remote hook to the container
+ */
+ private final InvokableContext container;
+
// --------------------------------------------------------------------------------||
// Constructor --------------------------------------------------------------------||
// --------------------------------------------------------------------------------||
@@ -64,25 +70,28 @@
* @param interceptors The interceptors to apply to invocations upon this handler
*/
public SessionRemoteProxyInvocationHandler(final String containerName, final String containerGuid,
- final Interceptor[] interceptors, final String businessInterfaceType, final String url)
+ final Interceptor[] interceptors, final String businessInterfaceType, final Object target, final String url)
{
- super(containerName, containerGuid, interceptors, businessInterfaceType, null);
+ super(containerName, containerGuid, interceptors, businessInterfaceType, target);
// Set properties
this.setUrl(url);
+ this.container = ProxyRemotingUtils.createRemoteProxyToContainer(this.getContainerName(),
+ this.getContainerGuid(), url, this.getInterceptors(), target);
}
// --------------------------------------------------------------------------------||
// Required Implementations -------------------------------------------------------||
// --------------------------------------------------------------------------------||
- /* (non-Javadoc)
- * @see org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandlerBase#getContainer()
+ /**
+ * {@inheritDoc}
+ * @see org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase#getContainer(java.lang.reflect.Method, java.lang.Object[])
*/
@Override
protected InvokableContext getContainer(final Method method, final Object[] args)
{
- return this.createRemoteProxyToContainer(this.getUrl());
+ return container;
}
// --------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SlsbProxyEqualityTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SlsbProxyEqualityTestCase.java 2010-08-13 13:56:51 UTC (rev 107592)
+++ projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SlsbProxyEqualityTestCase.java 2010-08-13 14:22:21 UTC (rev 107593)
@@ -87,20 +87,30 @@
@Test
public void testDifferentSlsbRemoteProxiesEqual() throws Throwable
{
- // Make a Remote Proxy Factory
- StatelessSessionRemoteProxyFactory factory = this.createSessionRemoteProxyFactory();
- factory.start();
+ // Bind the Connector
+ getBootstrap().deploy(SlsbProxyEqualityTestCase.class);
+ try
+ {
+ // Make a Remote Proxy Factory
+ StatelessSessionRemoteProxyFactory factory = this.createSessionRemoteProxyFactory();
+ factory.start();
- // Create 2 Proxies
- Object proxy1 = factory.createProxyDefault();
- Object proxy2 = factory.createProxyDefault();
+ // Create 2 Proxies
+ Object proxy1 = factory.createProxyDefault();
+ Object proxy2 = factory.createProxyDefault();
- // Ensure they're equal to one another
- TestCase
- .assertTrue(
- "EJB 3.0 Core Specification 3.4.5.2 Violation: Different remote proxies to same SLSB should be equal by value",
- proxy1.equals(proxy2));
- TestCase.assertTrue("Hash Codes for equal Proxies should be equal", proxy1.hashCode() == proxy2.hashCode());
+ // Ensure they're equal to one another
+ TestCase
+ .assertTrue(
+ "EJB 3.0 Core Specification 3.4.5.2 Violation: Different remote proxies to same SLSB should be equal by value",
+ proxy1.equals(proxy2));
+ TestCase.assertTrue("Hash Codes for equal Proxies should be equal", proxy1.hashCode() == proxy2.hashCode());
+ }
+ finally
+ {
+ // Bind the Connector
+ getBootstrap().undeploy(SlsbProxyEqualityTestCase.class);
+ }
}
// --------------------------------------------------------------------------------||
@@ -175,8 +185,8 @@
// Create the Factory
StatelessSessionRemoteProxyFactory factory = new StatelessSessionRemoteProxyFactory(
- StatelessSessionRemoteProxyFactory.class.getName(), container.getName(), container.getName(), container
- .getMetaData(), container.getClassLoader(), null, ProxyEqualityTestCaseBase.advisor, null);
+ StatelessSessionRemoteProxyFactory.class.getName(), container.getName(), container.getName(),
+ container.getMetaData(), container.getClassLoader(), null, ProxyEqualityTestCaseBase.advisor, null);
// Start
factory.start();
Added: projects/ejb3/trunk/proxy-impl/src/test/resources/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SlsbProxyEqualityTestCase-jboss-beans.xml
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/test/resources/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SlsbProxyEqualityTestCase-jboss-beans.xml (rev 0)
+++ projects/ejb3/trunk/proxy-impl/src/test/resources/org/jboss/ejb3/test/proxy/impl/spec_3_4_5/unit/SlsbProxyEqualityTestCase-jboss-beans.xml 2010-08-13 14:22:21 UTC (rev 107593)
@@ -0,0 +1,35 @@
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd"
+ xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!--
+
+ Remoting
+
+ -->
+
+ <!-- Remoting Configuration -->
+ <bean name="ServerConfiguration"
+ class="org.jboss.remoting.ServerConfiguration">
+ <property name="invocationHandlers">
+ <map keyClass="java.lang.String" valueClass="java.lang.String">
+ <entry>
+ <key>AOP</key>
+ <value>
+ org.jboss.aspects.remoting.AOPRemotingInvocationHandler
+ </value>
+ </entry>
+ </map>
+ </property>
+ </bean>
+
+ <!-- Remoting Connector -->
+ <bean name="org.jboss.ejb3.RemotingConnector"
+ class="org.jboss.remoting.transport.Connector">
+ <property name="invokerLocator">socket://0.0.0.0:3874</property>
+ <property name="serverConfiguration">
+ <inject bean="ServerConfiguration" />
+ </property>
+ </bean>
+
+</deployment>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list