[jboss-cvs] JBossAS SVN: r76754 - in projects/ejb3/trunk/proxy/src: main/java/org/jboss/ejb3/proxy/factory/session/stateful and 10 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Aug 7 05:51:17 EDT 2008
Author: ALRubinger
Date: 2008-08-07 05:51:17 -0400 (Thu, 07 Aug 2008)
New Revision: 76754
Added:
projects/ejb3/trunk/proxy/src/test/resources/ejb3-interceptors-aop.xml
Modified:
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryBase.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionLocalProxyFactory.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionRemoteProxyFactory.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionLocalProxyFactory.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionRemoteProxyFactory.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/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/StatelessLocalProxyInvocationHandler.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/handler/session/stateless/StatelessRemoteProxyInvocationHandler.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/unit/JndiSessionRegistrarBaseTestCase.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServer.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCaseBase.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/ProxyEqualityTestCaseBase.java
Log:
[EJBTHREE-1345] Add interceptor stack to invocation of Proxy handlers
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryBase.java 2008-08-07 09:16:26 UTC (rev 76753)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryBase.java 2008-08-07 09:51:17 UTC (rev 76754)
@@ -27,6 +27,9 @@
import java.util.HashSet;
import java.util.Set;
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.advice.AdviceStack;
+import org.jboss.aop.advice.Interceptor;
import org.jboss.ejb3.proxy.intf.EjbProxy;
import org.jboss.logging.Logger;
@@ -142,10 +145,32 @@
*/
protected String getInterceptorStackName()
{
- // Apply no interceptors by default
return null;
}
+ /**
+ * Obtains all interceptors in this Proxy Factory's stack
+ *
+ * @return
+ */
+ protected Interceptor[] getInterceptors()
+ {
+ // If there's no stack name, return no interceptors
+ String stackName = this.getInterceptorStackName();
+ if (stackName == null)
+ {
+ return new Interceptor[]
+ {};
+ }
+
+ // Obtain interceptors by stack name via Aspect Manager
+ AspectManager manager = AspectManager.instance();
+ AdviceStack stack = manager.getAdviceStack(stackName);
+ assert stack != null : "Could not find Advice Stack with name: " + stackName;
+ Interceptor[] interceptors = stack.createInterceptors();
+ return interceptors;
+ }
+
// --------------------------------------------------------------------------------||
// Lifecycle Methods --------------------------------------------------------------||
// --------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionLocalProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionLocalProxyFactory.java 2008-08-07 09:16:26 UTC (rev 76753)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionLocalProxyFactory.java 2008-08-07 09:51:17 UTC (rev 76754)
@@ -23,6 +23,7 @@
import java.util.Set;
+import org.jboss.aop.advice.Interceptor;
import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
import org.jboss.ejb3.proxy.handler.session.stateful.StatefulLocalProxyInvocationHandler;
@@ -109,9 +110,12 @@
// Obtain target container name
String containerName = this.getContainerName();
+ // Obtain interceptors
+ Interceptor[] interceptors = this.getInterceptors();
+
// Create
SessionProxyInvocationHandler handler = new StatefulLocalProxyInvocationHandler(containerName,
- businessInterfaceName);
+ businessInterfaceName, interceptors);
// Return
return handler;
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionRemoteProxyFactory.java 2008-08-07 09:16:26 UTC (rev 76753)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionRemoteProxyFactory.java 2008-08-07 09:51:17 UTC (rev 76754)
@@ -23,6 +23,7 @@
import java.util.Set;
+import org.jboss.aop.advice.Interceptor;
import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
import org.jboss.ejb3.proxy.handler.session.stateful.StatefulRemoteProxyInvocationHandler;
@@ -138,9 +139,12 @@
String containterName = this.getContainerName();
String url = this.getUrl();
+ // Get Interceptors
+ Interceptor[] interceptors = this.getInterceptors();
+
// Create
SessionProxyInvocationHandler handler = new StatefulRemoteProxyInvocationHandler(containterName,
- businessInterfaceName, url);
+ businessInterfaceName, url, interceptors);
// Return
return handler;
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionLocalProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionLocalProxyFactory.java 2008-08-07 09:16:26 UTC (rev 76753)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionLocalProxyFactory.java 2008-08-07 09:51:17 UTC (rev 76754)
@@ -23,6 +23,7 @@
import java.util.Set;
+import org.jboss.aop.advice.Interceptor;
import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
import org.jboss.ejb3.proxy.handler.session.stateless.StatelessLocalProxyInvocationHandler;
@@ -112,9 +113,12 @@
// Obtain container name
String containerName = this.getContainerName();
+ // Get Interceptors
+ Interceptor[] interceptors = this.getInterceptors();
+
// Create
SessionProxyInvocationHandler handler = new StatelessLocalProxyInvocationHandler(containerName,
- businessInterfaceName);
+ businessInterfaceName, interceptors);
// Return
return handler;
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionRemoteProxyFactory.java 2008-08-07 09:16:26 UTC (rev 76753)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionRemoteProxyFactory.java 2008-08-07 09:51:17 UTC (rev 76754)
@@ -23,6 +23,7 @@
import java.util.Set;
+import org.jboss.aop.advice.Interceptor;
import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
import org.jboss.ejb3.proxy.handler.session.stateless.StatelessRemoteProxyInvocationHandler;
@@ -138,9 +139,12 @@
String containerName = this.getContainerName();
String url = this.getUrl();
+ // Get Interceptors
+ Interceptor[] interceptors = this.getInterceptors();
+
// Create
SessionProxyInvocationHandler handler = new StatelessRemoteProxyInvocationHandler(containerName,
- businessInterfaceName, url);
+ businessInterfaceName, url, interceptors);
// Return
return handler;
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 2008-08-07 09:16:26 UTC (rev 76753)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandlerBase.java 2008-08-07 09:51:17 UTC (rev 76754)
@@ -24,6 +24,7 @@
import java.io.Serializable;
import java.lang.reflect.Method;
+import org.jboss.aop.advice.Interceptor;
import org.jboss.ejb3.common.lang.SerializableMethod;
/**
@@ -38,6 +39,15 @@
public abstract class ProxyInvocationHandlerBase implements ProxyInvocationHandler, Serializable
{
// ------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------||
+ // ------------------------------------------------------------------------------||
+
+ /**
+ * The interceptors to apply to inovcations upon this handler
+ */
+ private Interceptor[] interceptors;
+
+ // ------------------------------------------------------------------------------||
// Class Members ----------------------------------------------------------------||
// ------------------------------------------------------------------------------||
@@ -95,10 +105,12 @@
* Constructor
*
* @param containerName The name of the target container
+ * @param interceptors The interceptors to apply to invocations upon this handler
*/
- protected ProxyInvocationHandlerBase(final String containerName)
+ protected ProxyInvocationHandlerBase(final String containerName, final Interceptor[] interceptors)
{
this.setContainerName(containerName);
+ this.setInterceptors(interceptors);
}
// ------------------------------------------------------------------------------||
@@ -181,4 +193,14 @@
assert containerName != null && containerName.trim().length() > 0 : "Container Name must be specified";
this.containerName = containerName;
}
+
+ protected Interceptor[] getInterceptors()
+ {
+ return interceptors;
+ }
+
+ private void setInterceptors(Interceptor[] interceptors)
+ {
+ this.interceptors = interceptors;
+ }
}
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 2008-08-07 09:16:26 UTC (rev 76753)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionProxyInvocationHandlerBase.java 2008-08-07 09:51:17 UTC (rev 76754)
@@ -23,6 +23,7 @@
import java.io.Serializable;
+import org.jboss.aop.advice.Interceptor;
import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
import org.jboss.ejb3.proxy.container.InvokableContext;
@@ -59,10 +60,11 @@
* Constructor
*
* @param containerName The name of the target Container
+ * @param interceptors The interceptors to apply to invocations upon this handler
*/
- protected SessionProxyInvocationHandlerBase(final String containerName)
+ protected SessionProxyInvocationHandlerBase(final String containerName, final Interceptor[] interceptors)
{
- super(containerName);
+ super(containerName, interceptors);
}
/**
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 2008-08-07 09:16:26 UTC (rev 76753)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecProxyInvocationHandlerBase.java 2008-08-07 09:51:17 UTC (rev 76754)
@@ -24,6 +24,7 @@
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.container.InvokableContext;
import org.jboss.ejb3.proxy.handler.NotEligibleForDirectInvocationException;
@@ -71,10 +72,12 @@
* @param businessInterfaceType The possibly null businessInterfaceType
* marking this invocation hander as specific to a given
* EJB3 Business Interface
+ * @param interceptors The interceptors to apply to invocations upon this handler
*/
- protected SessionSpecProxyInvocationHandlerBase(final String containerName, final String businessInterfaceType)
+ protected SessionSpecProxyInvocationHandlerBase(final String containerName, final String businessInterfaceType,
+ final Interceptor[] interceptors)
{
- super(containerName);
+ super(containerName, interceptors);
this.setBusinessInterfaceType(businessInterfaceType);
}
@@ -94,7 +97,7 @@
{
log.debug("Couldn't handle invocation directly within " + this + ": " + nefdie.getMessage());
}
-
+
// Obtain an explicitly-specified actual class
String actualClass = this.getBusinessInterfaceType();
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 2008-08-07 09:16:26 UTC (rev 76753)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulLocalProxyInvocationHandler.java 2008-08-07 09:51:17 UTC (rev 76754)
@@ -23,6 +23,7 @@
import java.io.Serializable;
+import org.jboss.aop.advice.Interceptor;
import org.jboss.ejb3.proxy.container.InvokableContext;
/**
@@ -51,10 +52,12 @@
* @param businessInterfaceType The possibly null businessInterfaceType
* marking this invocation hander as specific to a given
* EJB3 Business Interface
+ * @param interceptors The interceptors to apply to invocations upon this handler
*/
- public StatefulLocalProxyInvocationHandler(final String containerName, final String businessInterfaceType)
+ public StatefulLocalProxyInvocationHandler(final String containerName, final String businessInterfaceType,
+ final Interceptor[] interceptors)
{
- super(containerName, businessInterfaceType);
+ super(containerName, businessInterfaceType, interceptors);
}
// --------------------------------------------------------------------------------||
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 2008-08-07 09:16:26 UTC (rev 76753)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulProxyInvocationHandlerBase.java 2008-08-07 09:51:17 UTC (rev 76754)
@@ -25,6 +25,10 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.net.MalformedURLException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import org.jboss.aop.advice.Interceptor;
import org.jboss.aspects.remoting.InvokeRemoteInterceptor;
@@ -80,10 +84,12 @@
* @param businessInterfaceType The possibly null businessInterfaceType
* marking this invocation hander as specific to a given
* EJB3 Business Interface
+ * @param interceptors The interceptors to apply to invocations upon this handler
*/
- public StatefulProxyInvocationHandlerBase(final String containerName, final String businessInterfaceType)
+ public StatefulProxyInvocationHandlerBase(final String containerName, final String businessInterfaceType,
+ final Interceptor[] interceptors)
{
- super(containerName, businessInterfaceType);
+ super(containerName, businessInterfaceType, interceptors);
}
// ------------------------------------------------------------------------------||
@@ -218,9 +224,27 @@
+ "\"", e);
}
+ /*
+ * Define interceptors
+ */
+
+ // Manually define a few
+ Interceptor[] interceptorsManuallyDefined =
+ {IsLocalProxyFactoryInterceptor.singleton, InvokeRemoteInterceptor.singleton};
+
+ // Get interceptors from the stack
+ Interceptor[] interceptorsFromStack = this.getInterceptors();
+
+ // Merge
+ List<Interceptor> interceptorsManuallyDefinedList = Arrays.asList(interceptorsManuallyDefined);
+ List<Interceptor> interceptorsFromStackList = Arrays.asList(interceptorsFromStack);
+ Set<Interceptor> mergedInterceptors = new HashSet<Interceptor>();
+ mergedInterceptors.addAll(interceptorsManuallyDefinedList);
+ mergedInterceptors.addAll(interceptorsFromStackList);
+ Interceptor[] interceptors = mergedInterceptors.toArray(new Interceptor[]
+ {});
+
// Create a POJI Proxy to the Container
- Interceptor[] interceptors =
- {IsLocalProxyFactoryInterceptor.singleton, InvokeRemoteInterceptor.singleton};
String containerName = this.getContainerName();
assert containerName != null && containerName.trim().length() > 0 : "Container Name must be set";
PojiProxy handler = new InvokableContextStatefulRemoteProxyInvocationHack(this.getContainerName(), locator,
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 2008-08-07 09:16:26 UTC (rev 76753)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulRemoteProxyInvocationHandler.java 2008-08-07 09:51:17 UTC (rev 76754)
@@ -23,6 +23,7 @@
import java.io.Serializable;
+import org.jboss.aop.advice.Interceptor;
import org.jboss.ejb3.proxy.container.InvokableContext;
/**
@@ -58,11 +59,12 @@
* marking this invocation hander as specific to a given
* EJB3 Business Interface
* @param url The URL to the Remote Host
+ * @param interceptors The interceptors to apply to invocations upon this handler
*/
public StatefulRemoteProxyInvocationHandler(final String containerName, final String businessInterfaceType,
- final String url)
+ final String url, final Interceptor[] interceptors)
{
- super(containerName, businessInterfaceType);
+ super(containerName, businessInterfaceType, interceptors);
this.setUrl(url);
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessLocalProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessLocalProxyInvocationHandler.java 2008-08-07 09:16:26 UTC (rev 76753)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessLocalProxyInvocationHandler.java 2008-08-07 09:51:17 UTC (rev 76754)
@@ -23,6 +23,7 @@
import java.io.Serializable;
+import org.jboss.aop.advice.Interceptor;
import org.jboss.ejb3.proxy.container.InvokableContext;
/**
@@ -51,10 +52,12 @@
* @param businessInterfaceType The possibly null businessInterfaceType
* marking this invocation hander as specific to a given
* EJB3 Business Interface
+ * @param interceptors The interceptors to apply to invocations upon this handler
*/
- public StatelessLocalProxyInvocationHandler(final String containerName, final String businessInterfaceType)
+ public StatelessLocalProxyInvocationHandler(final String containerName, final String businessInterfaceType,
+ final Interceptor[] interceptors)
{
- super(containerName, businessInterfaceType);
+ super(containerName, businessInterfaceType, interceptors);
}
// --------------------------------------------------------------------------------||
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 2008-08-07 09:16:26 UTC (rev 76753)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessProxyInvocationHandlerBase.java 2008-08-07 09:51:17 UTC (rev 76754)
@@ -25,6 +25,7 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
+import org.jboss.aop.advice.Interceptor;
import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
import org.jboss.ejb3.proxy.handler.session.SessionSpecProxyInvocationHandlerBase;
import org.jboss.logging.Logger;
@@ -60,10 +61,11 @@
* Constructor
*
* @param containerName
+ * @param interceptors The interceptors to apply to invocations upon this handler
*/
- public StatelessProxyInvocationHandlerBase(final String containerName)
+ public StatelessProxyInvocationHandlerBase(final String containerName, final Interceptor[] interceptors)
{
- this(containerName, null);
+ this(containerName, null, interceptors);
}
/**
@@ -73,10 +75,12 @@
* @param businessInterfaceType The possibly null businessInterfaceType
* marking this invocation hander as specific to a given
* EJB3 Business Interface
+ * @param interceptors The interceptors to apply to invocations upon this handler
*/
- public StatelessProxyInvocationHandlerBase(final String containerName, final String businessInterfaceType)
+ public StatelessProxyInvocationHandlerBase(final String containerName, final String businessInterfaceType,
+ final Interceptor[] interceptors)
{
- super(containerName, businessInterfaceType);
+ super(containerName, businessInterfaceType, interceptors);
}
// ------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessRemoteProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessRemoteProxyInvocationHandler.java 2008-08-07 09:16:26 UTC (rev 76753)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessRemoteProxyInvocationHandler.java 2008-08-07 09:51:17 UTC (rev 76754)
@@ -24,6 +24,10 @@
import java.io.Serializable;
import java.lang.reflect.Proxy;
import java.net.MalformedURLException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import org.jboss.aop.advice.Interceptor;
import org.jboss.aspects.remoting.InvokeRemoteInterceptor;
@@ -66,11 +70,12 @@
* marking this invocation hander as specific to a given
* EJB3 Business Interface
* @param url The URL to the Remote Host
+ * @param interceptors The interceptors to apply to invocations upon this handler
*/
public StatelessRemoteProxyInvocationHandler(final String containerName, final String businessInterfaceType,
- final String url)
+ final String url, final Interceptor[] interceptors)
{
- super(containerName, businessInterfaceType);
+ super(containerName, businessInterfaceType, interceptors);
this.setUrl(url);
}
@@ -115,9 +120,27 @@
+ "\"", e);
}
+ /*
+ * Define interceptors
+ */
+
+ // Manually define a few
+ Interceptor[] interceptorsManuallyDefined =
+ {IsLocalProxyFactoryInterceptor.singleton, InvokeRemoteInterceptor.singleton};
+
+ // Get interceptors from the stack
+ Interceptor[] interceptorsFromStack = this.getInterceptors();
+
+ // Merge
+ List<Interceptor> interceptorsManuallyDefinedList = Arrays.asList(interceptorsManuallyDefined);
+ List<Interceptor> interceptorsFromStackList = Arrays.asList(interceptorsFromStack);
+ Set<Interceptor> mergedInterceptors = new HashSet<Interceptor>();
+ mergedInterceptors.addAll(interceptorsManuallyDefinedList);
+ mergedInterceptors.addAll(interceptorsFromStackList);
+ Interceptor[] interceptors = mergedInterceptors.toArray(new Interceptor[]
+ {});
+
// Create a POJI Proxy to the Container
- Interceptor[] interceptors =
- {IsLocalProxyFactoryInterceptor.singleton, InvokeRemoteInterceptor.singleton};
PojiProxy handler = new InvokableContextStatefulRemoteProxyInvocationHack(this.getContainerName(), locator,
interceptors, null);
Class<?>[] interfaces = new Class<?>[]
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/unit/JndiSessionRegistrarBaseTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/unit/JndiSessionRegistrarBaseTestCase.java 2008-08-07 09:16:26 UTC (rev 76753)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/jndiregistrar/unit/JndiSessionRegistrarBaseTestCase.java 2008-08-07 09:51:17 UTC (rev 76754)
@@ -25,6 +25,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.net.URL;
import java.util.HashSet;
import java.util.Set;
@@ -32,6 +33,8 @@
import javax.naming.InitialContext;
import javax.naming.NameNotFoundException;
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.AspectXmlLoader;
import org.jboss.ejb3.common.registrar.plugin.mc.Ejb3McRegistrar;
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
import org.jboss.ejb3.common.registrar.spi.NotBoundException;
@@ -93,6 +96,8 @@
* Instance of logger
*/
private static Logger logger = Logger.getLogger(JndiSessionRegistrarBaseTestCase.class);
+
+ private static final String FILENAME_EJB3_INTERCEPTORS_AOP = "ejb3-interceptors-aop.xml";
/**
* Initializes the required services
@@ -109,6 +114,16 @@
Ejb3RegistrarLocator.bindRegistrar(new Ejb3McRegistrar(bootstrap.getKernel()));
bootstrap.deploy(JndiSessionRegistrarBaseTestCase.class);
+
+ // Load ejb3-interceptors-aop.xml into AspectManager
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ URL url = cl.getResource(FILENAME_EJB3_INTERCEPTORS_AOP);
+ if (url == null)
+ {
+ throw new RuntimeException("Could not load " + AspectManager.class.getSimpleName()
+ + " with definitions from XML as file " + FILENAME_EJB3_INTERCEPTORS_AOP + " could not be found");
+ }
+ AspectXmlLoader.deployXML(url);
}
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServer.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServer.java 2008-08-07 09:16:26 UTC (rev 76753)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServer.java 2008-08-07 09:51:17 UTC (rev 76754)
@@ -1,5 +1,9 @@
package org.jboss.ejb3.test.proxy.remoteaccess;
+import java.net.URL;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.AspectXmlLoader;
import org.jboss.ejb3.common.registrar.plugin.mc.Ejb3McRegistrar;
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
import org.jboss.ejb3.test.mc.bootstrap.EmbeddedTestMcBootstrap;
@@ -29,6 +33,8 @@
private static final Logger log = Logger.getLogger(MockServer.class);
private static MockServer server;
+
+ private static final String FILENAME_EJB3_INTERCEPTORS_AOP = "ejb3-interceptors-aop.xml";
// --------------------------------------------------------------------------------||
// Instance Members ---------------------------------------------------------------||
@@ -115,6 +121,16 @@
// Deploy *-beans.xml
this.getBootstrap().deploy(this.getTestClass());
+
+ // Load ejb3-interceptors-aop.xml into AspectManager
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ URL url = cl.getResource(FILENAME_EJB3_INTERCEPTORS_AOP);
+ if (url == null)
+ {
+ throw new RuntimeException("Could not load " + AspectManager.class.getSimpleName()
+ + " with definitions from XML as file " + FILENAME_EJB3_INTERCEPTORS_AOP + " could not be found");
+ }
+ AspectXmlLoader.deployXML(url);
// Restore old CL
Thread.currentThread().setContextClassLoader(olderLoader);
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCaseBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCaseBase.java 2008-08-07 09:16:26 UTC (rev 76753)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCaseBase.java 2008-08-07 09:51:17 UTC (rev 76754)
@@ -21,6 +21,10 @@
*/
package org.jboss.ejb3.test.proxy.session.unit;
+import java.net.URL;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.AspectXmlLoader;
import org.jboss.ejb3.common.registrar.plugin.mc.Ejb3McRegistrar;
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
import org.jboss.ejb3.test.mc.bootstrap.EmbeddedTestMcBootstrap;
@@ -42,6 +46,8 @@
protected static EmbeddedTestMcBootstrap bootstrap;
+ private static final String FILENAME_EJB3_INTERCEPTORS_AOP = "ejb3-interceptors-aop.xml";
+
// --------------------------------------------------------------------------------||
// Lifecycle Methods --------------------------------------------------------------||
// --------------------------------------------------------------------------------||
@@ -53,5 +59,15 @@
// Bind the Registrar
Ejb3RegistrarLocator.bindRegistrar(new Ejb3McRegistrar(bootstrap.getKernel()));
+
+ // Load ejb3-interceptors-aop.xml into AspectManager
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ URL url = cl.getResource(FILENAME_EJB3_INTERCEPTORS_AOP);
+ if (url == null)
+ {
+ throw new RuntimeException("Could not load " + AspectManager.class.getSimpleName()
+ + " with definitions from XML as file " + FILENAME_EJB3_INTERCEPTORS_AOP + " could not be found");
+ }
+ AspectXmlLoader.deployXML(url);
}
}
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/ProxyEqualityTestCaseBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/ProxyEqualityTestCaseBase.java 2008-08-07 09:16:26 UTC (rev 76753)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/ProxyEqualityTestCaseBase.java 2008-08-07 09:51:17 UTC (rev 76754)
@@ -21,8 +21,12 @@
*/
package org.jboss.ejb3.test.proxy.spec_3_4_5;
+import java.net.URL;
+
import junit.framework.TestCase;
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.AspectXmlLoader;
import org.jboss.ejb3.common.registrar.plugin.mc.Ejb3McRegistrar;
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
@@ -54,6 +58,8 @@
private static EmbeddedTestMcBootstrap bootstrap;
+ private static final String FILENAME_EJB3_INTERCEPTORS_AOP = "ejb3-interceptors-aop.xml";
+
/**
* Name of the SLSB Container for these tests
*/
@@ -117,6 +123,17 @@
// Bind the Ejb3Registrar
Ejb3RegistrarLocator.bindRegistrar(new Ejb3McRegistrar(bootstrap.getKernel()));
+
+ // Load ejb3-interceptors-aop.xml into AspectManager
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ URL url = cl.getResource(FILENAME_EJB3_INTERCEPTORS_AOP);
+ if (url == null)
+ {
+ throw new RuntimeException("Could not load " + AspectManager.class.getSimpleName()
+ + " with definitions from XML as file " + FILENAME_EJB3_INTERCEPTORS_AOP + " could not be found");
+ }
+ AspectXmlLoader.deployXML(url);
+
}
@AfterClass
Added: projects/ejb3/trunk/proxy/src/test/resources/ejb3-interceptors-aop.xml
===================================================================
--- projects/ejb3/trunk/proxy/src/test/resources/ejb3-interceptors-aop.xml (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/resources/ejb3-interceptors-aop.xml 2008-08-07 09:51:17 UTC (rev 76754)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+
+ Mock ejb3-interceptors-aop.xml for use in testing EJB3 Proxy
+
+ -->
+<aop xmlns="urn:jboss:aop-beans:1.0">
+
+
+ <!--
+
+ Client Interceptor Stack Definitions
+
+ -->
+
+ <stack name="ServiceClientInterceptors">
+
+ </stack>
+
+ <stack name="AsynchronousStatelessSessionClientInterceptors">
+
+ </stack>
+
+ <stack name="AsynchronousStatefulSessionClientInterceptors">
+
+ </stack>
+
+ <stack name="StatelessSessionClientInterceptors">
+
+ </stack>
+
+ <stack name="StatefulSessionClientInterceptors">
+
+ </stack>
+
+</aop>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list