[jboss-cvs] JBossAS SVN: r73645 - in projects/ejb3/trunk/proxy/src: main/java/org/jboss/ejb3/proxy/container and 17 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat May 24 02:27:00 EDT 2008
Author: ALRubinger
Date: 2008-05-24 02:26:59 -0400 (Sat, 24 May 2008)
New Revision: 73645
Added:
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/JbossProxy.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
Modified:
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/container/StatefulSessionInvokableContext.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactory.java
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/SessionProxyFactoryBase.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/StatefulSessionProxyFactoryBase.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/StatelessSessionProxyFactoryBase.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/ProxyInvocationHandler.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/StatefulProxyInvocationHandler.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessProxyInvocationHandler.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiRegistrar.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyFactoryReferenceAddressTypes.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/SessionProxyObjectFactory.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/stateful/StatefulSessionProxyObjectFactory.java
projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/stateless/StatelessSessionProxyObjectFactory.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/common/container/StatefulContainer.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/StatelessContainer.java
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/unit/SfsbProxyEqualityTestCase.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/unit/SlsbProxyEqualityTestCase.java
Log:
[EJBTHREE-1345] SFSB Implementations, Equality tests (Spec 3.4.5), ProxyFactory no longer specific to EJB Container
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/container/StatefulSessionInvokableContext.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/container/StatefulSessionInvokableContext.java 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/container/StatefulSessionInvokableContext.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -37,5 +37,10 @@
extends
InvokableContext<StatefulSessionContainerMethodInvocation>
{
-
+ /**
+ * Creates a new user session and returns the unique Session ID
+ *
+ * @return
+ */
+ Object createSession();
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactory.java 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactory.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -34,21 +34,11 @@
public interface ProxyFactory
{
// --------------------------------------------------------------------------------||
- // Contracts ----------------------------------------------------------------------||
- // --------------------------------------------------------------------------------||
-
- /**
- * Obtains the name of the target container used by
- * Proxies generated by this ProxyFactory for invocation
- */
- String getContainerName();
-
- // --------------------------------------------------------------------------------||
// Lifecycle Methods --------------------------------------------------------------||
// --------------------------------------------------------------------------------||
/**
- * Lifecycle callback to be invoked by the ProxyFactoryDeployer
+ * Lifecycle callback to be invoked
* before the ProxyFactory is able to service requests
*
* @throws Exception
@@ -56,7 +46,7 @@
void start() throws Exception;
/**
- * Lifecycle callback to be invoked by the ProxyFactoryDeployer
+ * Lifecycle callback to be invoked
* before the ProxyFactory is taken out of service,
* possibly GC'd
*
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-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryBase.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -24,7 +24,10 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
+import java.util.HashSet;
+import java.util.Set;
+import org.jboss.ejb3.proxy.intf.JbossProxy;
import org.jboss.logging.Logger;
/**
@@ -49,8 +52,6 @@
private ClassLoader classloader;
- private String containerName;
-
// --------------------------------------------------------------------------------||
// Constructor --------------------------------------------------------------------||
// --------------------------------------------------------------------------------||
@@ -60,13 +61,11 @@
*
* @param classloader The ClassLoader associated with the EJBContainer
* for which this ProxyFactory is to generate Proxies
- * @param containerName The name under which the target container is registered
*/
- public ProxyFactoryBase(final ClassLoader classloader, final String containerName)
+ public ProxyFactoryBase(final ClassLoader classloader)
{
// Set properties
this.setClassLoader(classloader);
- this.setContainerName(containerName);
}
// --------------------------------------------------------------------------------||
@@ -81,9 +80,13 @@
* @return
* @throws Exception
*/
- protected Constructor<?> createProxyConstructor(Class<?>[] interfaces, ClassLoader cl)
+ protected Constructor<?> createProxyConstructor(Set<Class<?>> interfaces, ClassLoader cl)
{
- Class<?> proxyClass = Proxy.getProxyClass(cl, interfaces);
+ // Add interfaces common to all proxies
+ interfaces.addAll(this.getProxyInterfaces());
+
+ Class<?> proxyClass = Proxy.getProxyClass(cl, interfaces.toArray(new Class<?>[]
+ {}));
Constructor<?> proxyConstructor = null;
try
{
@@ -96,6 +99,24 @@
return proxyConstructor;
}
+ /**
+ * Returns Proxy interfaces common to all Proxies generated
+ * by this ProxyFactory
+ *
+ * @return
+ */
+ protected Set<Class<?>> getProxyInterfaces()
+ {
+ // Initialize
+ Set<Class<?>> interfaces = new HashSet<Class<?>>();
+
+ // Add all Proxy Interfaces
+ interfaces.add(JbossProxy.class);
+
+ // Return
+ return interfaces;
+ }
+
// --------------------------------------------------------------------------------||
// Contracts ----------------------------------------------------------------------||
// --------------------------------------------------------------------------------||
@@ -160,14 +181,4 @@
this.classloader = classloader;
}
- public String getContainerName()
- {
- return containerName;
- }
-
- protected void setContainerName(String containerName)
- {
- this.containerName = containerName;
- }
-
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/SessionProxyFactoryBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/SessionProxyFactoryBase.java 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/SessionProxyFactoryBase.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -37,6 +37,7 @@
import org.jboss.ejb3.common.string.StringUtils;
import org.jboss.ejb3.proxy.factory.ProxyFactoryBase;
import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
+import org.jboss.ejb3.proxy.intf.SessionProxy;
import org.jboss.logging.Logger;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
@@ -97,13 +98,11 @@
* @param metadata The metadata representing this Session Bean
* @param classloader The ClassLoader associated with the SessionContainer
* for which this ProxyFactory is to generate Proxies
- * @param containerName The name under which the target container is registered
*/
- public SessionProxyFactoryBase(final JBossSessionBeanMetaData metadata, final ClassLoader classloader,
- final String containerName)
+ public SessionProxyFactoryBase(final JBossSessionBeanMetaData metadata, final ClassLoader classloader)
{
// Call Super
- super(classloader, containerName);
+ super(classloader);
// Set Metadata
this.setMetadata(metadata);
@@ -130,7 +129,7 @@
{
// Create a new Proxy instance, and return
return this.getConstructorProxyHome().newInstance(
- this.getInvocationHandlerConstructor().newInstance(this.getContainerName(), null));
+ this.getInvocationHandlerConstructor().newInstance((String) null));
}
catch (Throwable t)
@@ -161,8 +160,7 @@
try
{
// Create a new Proxy instance, and return
- return constructor.newInstance(this.getInvocationHandlerConstructor().newInstance(this.getContainerName(),
- null));
+ return constructor.newInstance(this.getInvocationHandlerConstructor().newInstance((String) null));
}
catch (Throwable t)
{
@@ -195,8 +193,7 @@
+ "\" was found; not created at start() properly? Bad value bound as RefAddr in JNDI?";
// Create a new Proxy instance, and return
- return constructor.newInstance(this.getInvocationHandlerConstructor().newInstance(this.getContainerName(),
- businessInterfaceName));
+ return constructor.newInstance(this.getInvocationHandlerConstructor().newInstance(businessInterfaceName));
}
catch (Throwable t)
{
@@ -216,8 +213,7 @@
try
{
// Create a new Proxy instance, and return
- return this.getConstructorProxyEjb2x().newInstance(
- this.getInvocationHandlerConstructor().newInstance(this.getContainerName()));
+ return this.getConstructorProxyEjb2x().newInstance(this.getInvocationHandlerConstructor().newInstance());
}
catch (Throwable t)
{
@@ -231,7 +227,7 @@
// --------------------------------------------------------------------------------||
/**
- * Lifecycle callback to be invoked by the ProxyFactoryDeployer
+ * Lifecycle callback to be invoked
* before the ProxyFactory is able to service requests
*
* @throws Exception
@@ -285,8 +281,10 @@
businessInterfaceClasses.add(businessInterface);
// Make Proxy specific to the business interface
- Constructor<?> businessInterfaceConstructor = this.createProxyConstructor(new Class<?>[]
- {businessInterface}, this.getClassLoader());
+ Set<Class<?>> businessInterfaces = new HashSet<Class<?>>();
+ businessInterfaces.add(businessInterface);
+ Constructor<?> businessInterfaceConstructor = this.createProxyConstructor(businessInterfaces, this
+ .getClassLoader());
log.debug("Created Session Bean Business Interface-Specific Proxy Constructor implementing \""
+ businessInterfaceType + "\"");
@@ -333,8 +331,9 @@
}
// Make the Home Proxy Constructor
- Constructor<?> homeConstructor = this.createProxyConstructor(new Class<?>[]
- {homeInterfaceClass}, this.getClassLoader());
+ Set<Class<?>> homeInterfaces = new HashSet<Class<?>>();
+ homeInterfaces.add(homeInterfaceClass);
+ Constructor<?> homeConstructor = this.createProxyConstructor(homeInterfaces, this.getClassLoader());
log.debug("Created Session Bean Home Proxy Constructor implementing \"" + homeInterfaceType + "\"");
// Set the Home Proxy Constructor
@@ -361,9 +360,8 @@
}
// Make the Default Business Interfaces Proxy Constructor
- Constructor<?> businessInterfacesConstructor = this.createProxyConstructor(defaultProxyInterfaces
- .toArray(new Class<?>[]
- {}), this.getClassLoader());
+ Constructor<?> businessInterfacesConstructor = this.createProxyConstructor(defaultProxyInterfaces, this
+ .getClassLoader());
log.debug("Created Session Bean Default EJB3 Business Proxy Constructor implementing " + defaultProxyInterfaces);
// Set
@@ -412,8 +410,7 @@
}
// Make the EJB2.x Proxy Constructor
- Constructor<?> ejb2xConstructor = this.createProxyConstructor(ejb2xInterfaces.toArray(new Class<?>[]
- {}), this.getClassLoader());
+ Constructor<?> ejb2xConstructor = this.createProxyConstructor(ejb2xInterfaces, this.getClassLoader());
log.debug("Created Session Bean EJB2x Proxy Constructor implementing " + ejb2xInterfaces);
// Set the EJB2.x Proxy Constructor
@@ -436,6 +433,25 @@
//TODO
}
+ /**
+ * Returns Proxy interfaces common to all Proxies generated
+ * by this ProxyFactory
+ *
+ * @return
+ */
+ @Override
+ protected Set<Class<?>> getProxyInterfaces()
+ {
+ // Initialize
+ Set<Class<?>> interfaces = super.getProxyInterfaces();
+
+ // Add
+ interfaces.add(SessionProxy.class);
+
+ // Return
+ return interfaces;
+ }
+
// --------------------------------------------------------------------------------||
// Functional 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-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionLocalProxyFactory.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -53,13 +53,11 @@
* @param metadata The metadata representing this SLSB
* @param classloader The ClassLoader associated with the StatelessContainer
* for which this ProxyFactory is to generate Proxies
- * @param containerName The name under which the target container is registered
*/
- public StatefulSessionLocalProxyFactory(final JBossSessionBeanMetaData metadata, final ClassLoader classloader,
- final String containerName)
+ public StatefulSessionLocalProxyFactory(final JBossSessionBeanMetaData metadata, final ClassLoader classloader)
{
// Call Super
- super(metadata, classloader, containerName);
+ super(metadata, classloader);
}
// --------------------------------------------------------------------------------||
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 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionProxyFactoryBase.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -27,6 +27,7 @@
import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
import org.jboss.ejb3.proxy.factory.session.SessionProxyFactoryBase;
import org.jboss.ejb3.proxy.handler.session.stateful.StatefulProxyInvocationHandler;
+import org.jboss.ejb3.proxy.intf.StatefulSessionProxy;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
/**
@@ -49,13 +50,11 @@
* @param metadata The metadata representing this SFSB
* @param classloader The ClassLoader associated with the StatelessContainer
* for which this ProxyFactory is to generate Proxies
- * @param containerName The name under which the target container is registered
*/
- public StatefulSessionProxyFactoryBase(final JBossSessionBeanMetaData metadata, final ClassLoader classloader,
- final String containerName)
+ public StatefulSessionProxyFactoryBase(final JBossSessionBeanMetaData metadata, final ClassLoader classloader)
{
// Call Super
- super(metadata, classloader, containerName);
+ super(metadata, classloader);
}
// --------------------------------------------------------------------------------||
@@ -88,12 +87,31 @@
try
{
return StatefulProxyInvocationHandler.class.getConstructor(new Class[]
- {String.class, String.class});
+ {String.class});
}
catch (NoSuchMethodException e)
{
- throw new RuntimeException("Could not find Constructor with two String arguments for "
+ throw new RuntimeException("Could not find Constructor with one String argument for "
+ StatefulProxyInvocationHandler.class.getName(), e);
}
}
+
+ /**
+ * Returns Proxy interfaces common to all Proxies generated
+ * by this ProxyFactory
+ *
+ * @return
+ */
+ @Override
+ protected Set<Class<?>> getProxyInterfaces()
+ {
+ // Initialize
+ Set<Class<?>> interfaces = super.getProxyInterfaces();
+
+ // Add
+ interfaces.add(StatefulSessionProxy.class);
+
+ // Return
+ return interfaces;
+ }
}
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-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionRemoteProxyFactory.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -55,13 +55,11 @@
* @param metadata The metadata representing this SFSB
* @param classloader The ClassLoader associated with the StatelessContainer
* for which this ProxyFactory is to generate Proxies
- * @param containerName The name under which the target container is registered
*/
- public StatefulSessionRemoteProxyFactory(final JBossSessionBeanMetaData metadata, final ClassLoader classloader,
- final String containerName)
+ public StatefulSessionRemoteProxyFactory(final JBossSessionBeanMetaData metadata, final ClassLoader classloader)
{
// Call Super
- super(metadata, classloader, containerName);
+ super(metadata, classloader);
}
// --------------------------------------------------------------------------------||
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-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionLocalProxyFactory.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -53,13 +53,11 @@
* @param metadata The metadata representing this SLSB
* @param classloader The ClassLoader associated with the StatelessContainer
* for which this ProxyFactory is to generate Proxies
- * @param containerName The name under which the target container is registered
*/
- public StatelessSessionLocalProxyFactory(final JBossSessionBeanMetaData metadata, final ClassLoader classloader,
- final String containerName)
+ public StatelessSessionLocalProxyFactory(final JBossSessionBeanMetaData metadata, final ClassLoader classloader)
{
// Call Super
- super(metadata, classloader, containerName);
+ super(metadata, classloader);
}
// --------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionProxyFactoryBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionProxyFactoryBase.java 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionProxyFactoryBase.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -49,13 +49,11 @@
* @param metadata The metadata representing this SLSB
* @param classloader The ClassLoader associated with the StatelessContainer
* for which this ProxyFactory is to generate Proxies
- * @param containerName The name under which the target container is registered
*/
- public StatelessSessionProxyFactoryBase(final JBossSessionBeanMetaData metadata, final ClassLoader classloader,
- final String containerName)
+ public StatelessSessionProxyFactoryBase(final JBossSessionBeanMetaData metadata, final ClassLoader classloader)
{
// Call Super
- super(metadata, classloader, containerName);
+ super(metadata, classloader);
}
// --------------------------------------------------------------------------------||
@@ -88,11 +86,11 @@
try
{
return StatelessProxyInvocationHandler.class.getConstructor(new Class[]
- {String.class, String.class});
+ {String.class});
}
catch (NoSuchMethodException e)
{
- throw new RuntimeException("Could not find Constructor with two String arguments for "
+ throw new RuntimeException("Could not find Constructor with one String argument for "
+ StatelessProxyInvocationHandler.class.getName(), e);
}
}
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-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionRemoteProxyFactory.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -55,13 +55,11 @@
* @param metadata The metadata representing this SLSB
* @param classloader The ClassLoader associated with the StatelessContainer
* for which this ProxyFactory is to generate Proxies
- * @param containerName The name under which the target container is registered
*/
- public StatelessSessionRemoteProxyFactory(final JBossSessionBeanMetaData metadata, final ClassLoader classloader,
- final String containerName)
+ public StatelessSessionRemoteProxyFactory(final JBossSessionBeanMetaData metadata, final ClassLoader classloader)
{
// Call Super
- super(metadata, classloader, containerName);
+ super(metadata, classloader);
}
// --------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandler.java 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandler.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -47,9 +47,17 @@
SerializableMethod getInvokedMethod();
/**
- * Obtain the name under which the target container is registered
+ * Get the target container name
*
* @return
*/
String getContainerName();
+
+ /**
+ * Sets the target container name
+ *
+ * @param containerName
+ */
+ void setContainerName(String containerName);
+
}
\ No newline at end of file
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-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/ProxyInvocationHandlerBase.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -21,6 +21,8 @@
*/
package org.jboss.ejb3.proxy.handler;
+import java.lang.reflect.Proxy;
+
import org.jboss.ejb3.proxy.lang.SerializableMethod;
/**
@@ -95,12 +97,9 @@
/**
* Constructor
- *
- * @param containerName The name under which the target container is registered
*/
- protected ProxyInvocationHandlerBase(String containerName)
+ protected ProxyInvocationHandlerBase()
{
- this.setContainerName(containerName);
}
// ------------------------------------------------------------------------------||
@@ -120,7 +119,6 @@
protected Object handleInvocationDirectly(Object proxy, Object[] args)
throws NotEligibleForDirectInvocationException
{
-
// Obtain the invoked method
SerializableMethod invokedMethod = this.getInvokedMethod();
assert invokedMethod != null : "Invoked Method was not set upon invocation of " + this.getClass().getName();
@@ -128,7 +126,10 @@
// equals
if (invokedMethod.equals(ProxyInvocationHandlerBase.METHOD_EQUALS))
{
- return new Boolean(this.equals(args[0]));
+ assert args.length == 1 : "Invocation for 'equals' should have exactly one argument, instead was: "
+ + invokedMethod;
+ Object argument = args[0];
+ return new Boolean(this.invokeEquals(proxy, argument));
}
// toString
if (invokedMethod.equals(ProxyInvocationHandlerBase.METHOD_TO_STRING))
@@ -138,7 +139,7 @@
// hashCode
if (invokedMethod.equals(ProxyInvocationHandlerBase.METHOD_HASH_CODE))
{
- return new Integer(this.hashCode());
+ return new Integer(Proxy.getInvocationHandler(proxy).hashCode());
}
// If no eligible methods were invoked
@@ -147,6 +148,19 @@
}
// ------------------------------------------------------------------------------||
+ // Contracts --------------------------------------------------------------------||
+ // ------------------------------------------------------------------------------||
+
+ /**
+ * Handles invocation of "equals(Object)" upon the Proxy
+ *
+ * @param proxy
+ * @param args
+ * @return
+ */
+ protected abstract boolean invokeEquals(Object proxy, Object argument);
+
+ // ------------------------------------------------------------------------------||
// Accessors / Mutators ---------------------------------------------------------||
// ------------------------------------------------------------------------------||
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-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionProxyInvocationHandlerBase.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -41,12 +41,10 @@
// ------------------------------------------------------------------------------||
/**
- * Constructor
- *
- * @param containerName The name under which the target container is registered
+ * Constructor
*/
- protected SessionProxyInvocationHandlerBase(String containerName)
+ protected SessionProxyInvocationHandlerBase()
{
- super(containerName);
+ super();
}
}
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-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/SessionSpecProxyInvocationHandlerBase.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -57,9 +57,9 @@
* marking this invocation hander as specific to a given
* EJB3 Business Interface
*/
- protected SessionSpecProxyInvocationHandlerBase(String containerName, String businessInterfaceType)
+ protected SessionSpecProxyInvocationHandlerBase(String businessInterfaceType)
{
- super(containerName);
+ super();
this.setBusinessInterfaceType(businessInterfaceType);
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulProxyInvocationHandler.java 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateful/StatefulProxyInvocationHandler.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -23,6 +23,7 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.List;
@@ -31,6 +32,7 @@
import org.jboss.ejb3.proxy.hack.Hack;
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.lang.SerializableMethod;
import org.jboss.kernel.spi.registry.KernelBus;
import org.jboss.logging.Logger;
@@ -45,6 +47,8 @@
* @version $Revision: $
*/
public class StatefulProxyInvocationHandler extends SessionSpecProxyInvocationHandlerBase
+ implements
+ StatefulSessionProxy
{
// ------------------------------------------------------------------------------||
@@ -54,30 +58,36 @@
private static final Logger log = Logger.getLogger(StatefulProxyInvocationHandler.class);
// ------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------||
+ // ------------------------------------------------------------------------------||
+
+ /**
+ * The Session ID of the SFSB Instance to which this ProxyHandler will delegate
+ */
+ private Object sessionId;
+
+ // ------------------------------------------------------------------------------||
// Constructors -----------------------------------------------------------------||
// ------------------------------------------------------------------------------||
/**
* Constructor
- *
- * @param containerName The name under which the target container is registered
*/
- public StatefulProxyInvocationHandler(String containerName)
+ public StatefulProxyInvocationHandler()
{
- this(containerName, null);
+ this(null);
}
/**
* Constructor
*
- * @param containerName The name under which the target container is registered
* @param businessInterfaceType The possibly null businessInterfaceType
* marking this invocation hander as specific to a given
* EJB3 Business Interface
*/
- public StatefulProxyInvocationHandler(String containerName, String businessInterfaceType)
+ public StatefulProxyInvocationHandler(String businessInterfaceType)
{
- super(containerName, businessInterfaceType);
+ super(businessInterfaceType);
}
// ------------------------------------------------------------------------------||
@@ -134,6 +144,69 @@
}
+ /**
+ * Obtains the Session ID for this SFSB instance
+ *
+ * @return
+ */
+ public Object getSessionId()
+ {
+ return this.sessionId;
+ }
+
+ /**
+ * Sets the Session ID for this SFSB instance
+ *
+ * @param sessionId
+ */
+ public void setSessionId(Object sessionId)
+ {
+ this.sessionId = sessionId;
+ }
+
+ /**
+ * EJB 3.0 Core Specification 3.4.5.1
+ *
+ * Determines Equality for SFSB Proxies
+ *
+ * @param proxy
+ * @param argument
+ */
+ @Override
+ protected boolean invokeEquals(Object proxy, Object argument)
+ {
+ // If these objects are not of the same type
+ if (!argument.getClass().equals(proxy.getClass()))
+ {
+ // Not equal
+ if (log.isTraceEnabled())
+ {
+ log.trace(argument + " is not equal to " + proxy + " as they are different types");
+ }
+ return false;
+ }
+
+ // Ensure InvocationHandler is of expected type
+ InvocationHandler handler = Proxy.getInvocationHandler(proxy);
+ assert handler instanceof StatefulSessionProxy : InvocationHandler.class.getSimpleName() + " " + handler
+ + " must be of type " + StatefulSessionProxy.class.getName() + " but instead was: "
+ + handler.getClass().getInterfaces();
+
+ // Cast
+ StatefulSessionProxy sHandler = (StatefulSessionProxy) handler;
+ StatefulSessionProxy sArgument = (StatefulSessionProxy) Proxy.getInvocationHandler(argument);
+
+ // Equal if Session IDs are equal
+ Object sessionId = sHandler.getSessionId();
+ assert sessionId != null : "Required Session ID is not present in " + proxy;
+ boolean equal = sessionId.equals(sArgument.getSessionId());
+
+ // Return
+ log.debug("SFSB Equality Check for " + sHandler.getSessionId() + " and " + sArgument.getSessionId() + " ="
+ + equal);
+ return equal;
+ }
+
// ------------------------------------------------------------------------------||
// TO BE IMPLEMENTED ------------------------------------------------------------||
// ------------------------------------------------------------------------------||
@@ -145,5 +218,4 @@
{
throw new NotImplementedException("ALR");
}
-
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessProxyInvocationHandler.java 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/handler/session/stateless/StatelessProxyInvocationHandler.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -59,25 +59,22 @@
/**
* Constructor
- *
- * @param containerName The name under which the target container is registered
*/
- public StatelessProxyInvocationHandler(String containerName)
+ public StatelessProxyInvocationHandler()
{
- this(containerName, null);
+ this(null);
}
/**
* Constructor
*
- * @param containerName The name under which the target container is registered
* @param businessInterfaceType The possibly null businessInterfaceType
* marking this invocation hander as specific to a given
* EJB3 Business Interface
*/
- public StatelessProxyInvocationHandler(String containerName, String businessInterfaceType)
+ public StatelessProxyInvocationHandler(String businessInterfaceType)
{
- super(containerName, businessInterfaceType);
+ super(businessInterfaceType);
}
// ------------------------------------------------------------------------------||
@@ -128,6 +125,38 @@
}
+ /**
+ * Handles invocation of "equals(Object)" upon a SLSB Proxy
+ *
+ * EJB 3.0 Specification 3.4.5.2
+ *
+ * @param proxy
+ * @param args
+ * @return
+ */
+ protected boolean invokeEquals(Object proxy, Object argument)
+ {
+ // If these are not of the same type
+ if (!proxy.getClass().equals(argument.getClass()))
+ {
+ // Return false
+ return false;
+ }
+
+ //TODO
+
+ /*
+ * EJB3 3.4.5.2: "Session bean references to either different business interface types
+ * or different session beans will not be equal."
+ *
+ * See if we must test these conditions as well for Complicance
+ */
+
+ // Same type, SLSB, so return true
+ return true;
+
+ }
+
// ------------------------------------------------------------------------------||
// TO BE IMPLEMENTED ------------------------------------------------------------||
// ------------------------------------------------------------------------------||
Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/JbossProxy.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/JbossProxy.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/JbossProxy.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.proxy.intf;
+
+/**
+ * JbossProxy
+ *
+ * Defines the contract for all methods required
+ * of JBoss EJB3 Proxies
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface JbossProxy
+{
+
+}
Added: 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 (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/SessionProxy.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.proxy.intf;
+
+/**
+ * SessionProxy
+ *
+ * Defines the contract for all methods required
+ * of JBoss EJB3 Session Bean Proxies
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface SessionProxy
+{
+
+}
Added: 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 (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/intf/StatefulSessionProxy.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.proxy.intf;
+
+/**
+ * StatefulSessionProxy
+ *
+ * Contract for operations required of Stateful Proxies
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface StatefulSessionProxy extends SessionProxy
+{
+ /**
+ * Obtains the Session ID for this SFSB instance
+ *
+ * @return
+ */
+ Object getSessionId();
+
+ /**
+ * Sets the Session ID for this SFSB instance
+ *
+ * @param sessionId
+ */
+ void setSessionId(Object sessionId);
+}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiRegistrar.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiRegistrar.java 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiRegistrar.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -178,13 +178,6 @@
this.bindSessionEjb(smd, cl, containerName);
}
- // If this is a MDB
- else if (md.isMessageDriven())
- {
- //TODO MDB Impl
- return;
- }
-
//TODO If this is @Service
else if (md.isService())
{
@@ -258,7 +251,7 @@
if (hasLocalView)
{
// Create and register a local proxy factory
- ProxyFactory factory = new StatelessSessionLocalProxyFactory(smd, cl, containerName);
+ ProxyFactory factory = new StatelessSessionLocalProxyFactory(smd, cl);
localProxyFactoryKey = this.registerProxyFactory(factory, smd, true);
}
@@ -267,7 +260,7 @@
if (hasRemoteView)
{
// Create and register a local proxy factory
- ProxyFactory factory = new StatelessSessionRemoteProxyFactory(smd, cl, containerName);
+ ProxyFactory factory = new StatelessSessionRemoteProxyFactory(smd, cl);
remoteProxyFactoryKey = this.registerProxyFactory(factory, smd, false);
}
@@ -310,7 +303,7 @@
String homeAddress = smd.determineResolvedJndiName(homeType);
log.debug("Remote Home View for EJB " + smd.getEjbName() + " to be bound into JNDI at \"" + homeAddress
+ "\"");
- this.bind(homeRef, homeAddress, remoteProxyFactoryKey);
+ this.bind(homeRef, homeAddress, remoteProxyFactoryKey, containerName);
}
/*
@@ -337,7 +330,7 @@
String defaultRemoteAddress = smd.determineJndiName();
log.debug("Default Remote View for EJB " + smd.getEjbName() + " to be bound into JNDI at \""
+ defaultRemoteAddress + "\"");
- this.bind(defaultRemoteRef, defaultRemoteAddress, remoteProxyFactoryKey);
+ this.bind(defaultRemoteRef, defaultRemoteAddress, remoteProxyFactoryKey, containerName);
// Bind ObjectFactory specific to each Remote Business Interface
for (String businessRemote : businessRemotes)
@@ -350,7 +343,7 @@
String address = smd.determineResolvedJndiName(businessRemote);
log.debug("Remote Business View for " + businessRemote + " of EJB " + smd.getEjbName()
+ " to be bound into JNDI at \"" + address + "\"");
- this.bind(ref, address, remoteProxyFactoryKey);
+ this.bind(ref, address, remoteProxyFactoryKey, containerName);
}
}
@@ -390,7 +383,7 @@
String localHomeAddress = smd.determineResolvedJndiName(localHomeType);
log.debug("Local Home View for EJB " + smd.getEjbName() + " to be bound into JNDI at \""
+ localHomeAddress + "\"");
- this.bind(localHomeRef, localHomeAddress, localProxyFactoryKey);
+ this.bind(localHomeRef, localHomeAddress, localProxyFactoryKey, containerName);
}
/*
@@ -417,7 +410,7 @@
String defaultLocalAddress = smd.determineLocalJndiName();
log.debug("Default Local View for EJB " + smd.getEjbName() + " to be bound into JNDI at \""
+ defaultLocalAddress + "\"");
- this.bind(defaultLocalRef, defaultLocalAddress, localProxyFactoryKey);
+ this.bind(defaultLocalRef, defaultLocalAddress, localProxyFactoryKey, containerName);
// Bind ObjectFactory specific to each Local Business Interface
for (String businessLocal : businessLocals)
@@ -430,7 +423,7 @@
String address = smd.determineResolvedJndiName(businessLocal);
log.debug("Local Business View for " + businessLocal + " of EJB " + smd.getEjbName()
+ " to be bound into JNDI at \"" + address + "\"");
- this.bind(ref, address, localProxyFactoryKey);
+ this.bind(ref, address, localProxyFactoryKey, containerName);
}
}
@@ -459,13 +452,18 @@
* @param proxyFactoryRegistryKey The key under which the proxy factory
* for this reference is stored in the proxy factory registry
*/
- protected void bind(Reference ref, String address, String proxyFactoryRegistryKey)
+ protected void bind(Reference ref, String address, String proxyFactoryRegistryKey, String containerName)
{
// Add the Proxy Factory Registry key for this Reference
- RefAddr refAddr = new StringRefAddr(ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY,
- proxyFactoryRegistryKey);
- ref.add(refAddr);
+ RefAddr proxyFactoryRefAddr = new StringRefAddr(
+ ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY, proxyFactoryRegistryKey);
+ ref.add(proxyFactoryRefAddr);
+ // Add the Container name for this Reference
+ RefAddr containerRefAddr = new StringRefAddr(ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_EJBCONTAINER_NAME,
+ containerName);
+ ref.add(containerRefAddr);
+
// Bind
try
{
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyFactoryReferenceAddressTypes.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyFactoryReferenceAddressTypes.java 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyFactoryReferenceAddressTypes.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -76,4 +76,10 @@
*/
String REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY = ProxyFactoryRegistry.class.getSimpleName() + "Key";
+ /*
+ * The following are ReferenceAddress types denoting the Name of the EJB Container associated
+ * with a Reference
+ */
+ String REF_ADDR_TYPE_EJBCONTAINER_NAME = "EJB Container Name";
+
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -126,6 +126,29 @@
return proxy;
}
+ /**
+ * Obtains the container name bound as a reference address to the JNDI Name specified
+ *
+ * @param name
+ * @param referenceAddresses
+ * @return
+ */
+ protected String getContainerName(Name name, Map<String, List<String>> referenceAddresses)
+ {
+ // Get the Container Name
+ String refAddrType = ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_EJBCONTAINER_NAME;
+ List<String> containerNames = referenceAddresses.get(refAddrType);
+ assert containerNames != null : RefAddr.class.getSimpleName() + " type of " + refAddrType
+ + " is required to find the EJB Container associated with the " + Reference.class.getSimpleName()
+ + " for JNDI Name " + name;
+ assert containerNames.size() == 1 : "Only one " + RefAddr.class.getSimpleName() + " of type " + refAddrType
+ + " may be defined, instead found: " + containerNames;
+ String containerName = containerNames.get(0);
+
+ // Return
+ return containerName;
+ }
+
// --------------------------------------------------------------------------------||
// Specifications -----------------------------------------------------------------||
// --------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/SessionProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/SessionProxyObjectFactory.java 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/SessionProxyObjectFactory.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -21,18 +21,18 @@
*/
package org.jboss.ejb3.proxy.objectfactory.session;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
import java.util.List;
import java.util.Map;
import javax.naming.Name;
-import javax.naming.RefAddr;
import org.jboss.ejb3.proxy.factory.ProxyFactory;
import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
+import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
import org.jboss.ejb3.proxy.objectfactory.McProxyObjectFactory;
import org.jboss.ejb3.proxy.objectfactory.ProxyFactoryReferenceAddressTypes;
-import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryNotRegisteredException;
-import org.jboss.ejb3.proxy.spi.registry.ProxyFactoryRegistry;
import org.jboss.logging.Logger;
/**
@@ -60,8 +60,15 @@
// Required Implementations ------------------------------------------------------||
// --------------------------------------------------------------------------------||
- @Override
- protected Object getProxy(ProxyFactory proxyFactory, Name name, Map<String, List<String>> referenceAddresses)
+ /**
+ * Creates an proxy from the appropriate ProxyFactory as determined by
+ * metadata in the specified reference addresses
+ *
+ * @param name The JNDI Name looked up
+ * @param referenceAddresses A Map of RefAddr instances in form key = type and
+ * value = List of values for this type
+ */
+ protected Object createProxy(ProxyFactory factory, Name name, Map<String, List<String>> referenceAddresses)
{
// Initialize
Object proxy = null;
@@ -72,56 +79,22 @@
// Determine if a business interface is defined here
boolean hasBusiness = this.hasBusiness(name, referenceAddresses);
- // Obtain Proxy Factory Registry
- ProxyFactoryRegistry registry = this.getProxyFactoryRegistry();
- assert registry != null : ProxyFactoryRegistry.class.getSimpleName() + " is required but found null reference";
+ // Cast
+ assert factory instanceof SessionProxyFactory : ProxyFactory.class.getSimpleName() + " used in "
+ + SessionProxyObjectFactory.class.getSimpleName() + " must be of type "
+ + SessionProxyFactory.class.getName();
+ SessionProxyFactory sFactory = (SessionProxyFactory) factory;
- // Obtain Proxy Factory
- SessionProxyFactory factory = null;
- Object pFactory = null;
- List<String> proxyFactoryRegistryKeys = referenceAddresses
- .get(ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY);
- assert proxyFactoryRegistryKeys != null : "Required " + RefAddr.class.getSimpleName() + " of type "
- + ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY
- + " is required present in JNDI at " + name.toString() + " but was not found";
- assert proxyFactoryRegistryKeys.size() == 1 : "Exactly one " + RefAddr.class.getSimpleName() + " of type "
- + ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY
- + " should be defined but instead found " + proxyFactoryRegistryKeys;
- String proxyFactoryRegistryKey = proxyFactoryRegistryKeys.get(0);
- assert proxyFactoryRegistryKey != null && !proxyFactoryRegistryKey.equals("") : "Required "
- + RefAddr.class.getSimpleName() + " of type "
- + ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY
- + " is required present in JNDI at " + name.toString() + " but was not found";
- try
- {
- // Get the Factory
- pFactory = registry.getProxyFactory(proxyFactoryRegistryKey);
- // Cast into a SessionProxyFactory
- factory = SessionProxyFactory.class.cast(pFactory);
- log.debug("Using: " + factory + " as specified from JNDI reference " + name.toString());
- }
- catch (ProxyFactoryNotRegisteredException e)
- {
- throw new RuntimeException("Expected " + SessionProxyFactory.class.getName() + " in " + registry
- + " under key \"" + proxyFactoryRegistryKey + "\" but found none", e);
- }
- catch (ClassCastException cce)
- {
- throw new RuntimeException("Found Proxy Factory in " + registry + " under key \"" + proxyFactoryRegistryKey
- + "\", but was of type " + pFactory.getClass().getName() + " instead of expected "
- + SessionProxyFactory.class.getName(), cce);
- }
-
// If home and business are bound together
if (hasHome && hasBusiness)
{
- proxy = factory.createProxyDefault();
+ proxy = sFactory.createProxyDefault();
log.debug("Created Proxy " + proxy + " for both EJB2.x and EJB3 Business Interfaces.");
}
// If bound to home only
else if (hasHome)
{
- proxy = factory.createProxyHome();
+ proxy = sFactory.createProxyHome();
log.debug("Created Proxy " + proxy + " for EJB2.x Home Interface(s)");
}
// If bound to business only
@@ -149,13 +122,13 @@
{
// Obtain a proxy specific to this business interface
String businessInterface = businessInterfaces.get(0);
- proxy = factory.createProxyBusiness(businessInterface);
+ proxy = sFactory.createProxyBusiness(businessInterface);
log.debug("Created Proxy " + proxy + " for EJB3 Business Interface: " + businessInterface);
}
else
{
// Use a general-purpose proxy for all business interfaces
- proxy = factory.createProxyDefault();
+ proxy = sFactory.createProxyDefault();
log.debug("Created Proxy " + proxy + " for EJB3 Business Interfaces: " + businessInterfaces);
}
}
@@ -166,6 +139,19 @@
+ " is not bound to create/return any valid EJB2.x Home or EJB3 Business Interfaces");
}
+ // Obtain the target container name
+ String containerName = this.getContainerName(name, referenceAddresses);
+
+ // Get the proxy's invocation handler
+ InvocationHandler handler = Proxy.getInvocationHandler(proxy);
+
+ // Set the target Container Name
+ assert handler instanceof SessionProxyInvocationHandler : InvocationHandler.class.getSimpleName()
+ + " must be of type " + SessionProxyInvocationHandler.class.getName() + " but instead was assignable to "
+ + proxy.getClass().getInterfaces();
+ SessionProxyInvocationHandler sHandler = (SessionProxyInvocationHandler) handler;
+ sHandler.setContainerName(containerName);
+
// Return
return proxy;
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/stateful/StatefulSessionProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/stateful/StatefulSessionProxyObjectFactory.java 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/stateful/StatefulSessionProxyObjectFactory.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -21,7 +21,19 @@
*/
package org.jboss.ejb3.proxy.objectfactory.session.stateful;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.Name;
+import javax.naming.RefAddr;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.ejb3.proxy.container.StatefulSessionInvokableContext;
+import org.jboss.ejb3.proxy.factory.ProxyFactory;
+import org.jboss.ejb3.proxy.hack.Hack;
+import org.jboss.ejb3.proxy.intf.StatefulSessionProxy;
import org.jboss.ejb3.proxy.objectfactory.session.SessionProxyObjectFactory;
+import org.jboss.kernel.Kernel;
/**
* StatefulSessionProxyObjectFactory
@@ -40,4 +52,52 @@
private static final long serialVersionUID = 1L;
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * SFSB Object Factories must always create a new SFSB Proxy with every lookup,
+ * set a new Session ID as obtained by the SFSB Container, and return.
+ *
+ * @param proxyFactory The ProxyFactory to use
+ * @param name The JNDI name looked up
+ * @param referenceAddresses
+ */
+ @Override
+ protected Object getProxy(ProxyFactory proxyFactory, Name name, Map<String, List<String>> referenceAddresses)
+ {
+ // Get the Proxy from the Super Implementation
+ Object proxy = this.createProxy(proxyFactory, name, referenceAddresses);
+
+ // Get the Container Name
+ String containerName = this.getContainerName(name, referenceAddresses);
+
+ // Get the Container
+ Kernel kernel = Hack.BOOTSTRAP.getKernel();
+ ControllerContext context = kernel.getController().getInstalledContext(containerName);
+ assert context != null && context.getTarget() != null : "EJB Container could not be found at " + containerName
+ + "; perhaps it has not been properly registered or the " + RefAddr.class.getSimpleName()
+ + " is incorrect?";
+ Object obj = context.getTarget();
+ assert obj instanceof StatefulSessionInvokableContext : "Object found registered under name " + containerName
+ + " must be of type " + StatefulSessionInvokableContext.class.getName() + " but was instead " + obj;
+ StatefulSessionInvokableContext<?> container = (StatefulSessionInvokableContext<?>) obj;
+
+ // Create a Session ID from the Container
+ Object sessionId = container.createSession();
+
+ // Ensure Proxy is of expected type
+ assert proxy instanceof StatefulSessionProxy : "Proxy " + proxy + " must be of type "
+ + StatefulSessionProxy.class.getName();
+
+ // Cast
+ StatefulSessionProxy sProxy = (StatefulSessionProxy) proxy;
+
+ // Set the Session ID
+ sProxy.setSessionId(sessionId);
+
+ // Return
+ return proxy;
+ }
}
Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/stateless/StatelessSessionProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/stateless/StatelessSessionProxyObjectFactory.java 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/stateless/StatelessSessionProxyObjectFactory.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -21,6 +21,12 @@
*/
package org.jboss.ejb3.proxy.objectfactory.session.stateless;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.Name;
+
+import org.jboss.ejb3.proxy.factory.ProxyFactory;
import org.jboss.ejb3.proxy.objectfactory.session.SessionProxyObjectFactory;
/**
@@ -39,7 +45,7 @@
// --------------------------------------------------------------------------------||
private static final long serialVersionUID = 1L;
-
+
/*
* TODO
*
@@ -50,5 +56,20 @@
* Business
* One per interface-specific business
*/
+ /**
+ * SLSB Object Factories must always create a new SLSB Proxy if one is not
+ * available in the internal cache, otherwise use the cached one and return
+ *
+ * @param proxyFactory The ProxyFactory to use
+ * @param name The JNDI name looked up
+ * @param referenceAddresses
+ */
+ @Override
+ protected Object getProxy(ProxyFactory proxyFactory, Name name, Map<String, List<String>> referenceAddresses)
+ {
+ //TODO Implement caching
+ // Just create a new Proxy instance for now
+ return this.createProxy(proxyFactory, name, referenceAddresses);
+ }
}
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 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/SessionContainer.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -92,6 +92,9 @@
// Set CL
this.setClassLoader(classLoader);
+
+ // Set name
+ this.setName(this.createContainerName());
// Set Bean Class
String beanClassName = this.getMetaData().getEjbClass();
@@ -210,6 +213,17 @@
}
// --------------------------------------------------------------------------------||
+ // contracts ----------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Creates a unique name for this container
+ *
+ * @return
+ */
+ protected abstract String createContainerName();
+
+ // --------------------------------------------------------------------------------||
// Accessors / Mutators -----------------------------------------------------------||
// --------------------------------------------------------------------------------||
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/StatefulContainer.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/StatefulContainer.java 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/StatefulContainer.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -21,8 +21,10 @@
*/
package org.jboss.ejb3.test.proxy.common.container;
-import org.jboss.ejb3.interceptors.container.ContainerMethodInvocation;
-import org.jboss.ejb3.proxy.container.InvokableContext;
+import java.util.UUID;
+
+import org.jboss.ejb3.proxy.container.StatefulSessionInvokableContext;
+import org.jboss.ejb3.proxy.invocation.StatefulSessionContainerMethodInvocation;
import org.jboss.ejb3.proxy.mc.MicrocontainerBindings;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
@@ -34,16 +36,51 @@
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
*/
-public class StatefulContainer extends SessionSpecContainer implements InvokableContext<ContainerMethodInvocation>
+public class StatefulContainer extends SessionSpecContainer
+ implements
+ StatefulSessionInvokableContext<StatefulSessionContainerMethodInvocation>
{
+
+ // --------------------------------------------------------------------------------||
+ // Instance Members ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ // --------------------------------------------------------------------------------||
+ // Constructor ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
public StatefulContainer(JBossSessionBeanMetaData metaData, ClassLoader classLoader) throws ClassNotFoundException
{
super(metaData, classLoader);
+ }
- // Create and set Container Name
- String containerName = MicrocontainerBindings.MC_NAMESPACE_EJBCONTAINER_STATEFUL + metaData.getEjbName();
- this.setName(containerName);
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+ /**
+ * Creates a new user session and returns the unique Session ID
+ *
+ * @return
+ */
+ public Object createSession()
+ {
+ /*
+ * Just create a UUID, in practice this would create a new instance and
+ * associate it with an ID in the cache
+ */
+ return UUID.randomUUID();
}
+ /**
+ * Creates a unique name for this container
+ *
+ * @return
+ */
+ protected final String createContainerName()
+ {
+ return MicrocontainerBindings.MC_NAMESPACE_EJBCONTAINER_STATEFUL + this.getMetaData().getEjbName() + "/"
+ + UUID.randomUUID();
+ }
+
}
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/StatelessContainer.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/StatelessContainer.java 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/StatelessContainer.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -21,6 +21,8 @@
*/
package org.jboss.ejb3.test.proxy.common.container;
+import java.util.UUID;
+
import org.jboss.ejb3.interceptors.container.ContainerMethodInvocation;
import org.jboss.ejb3.proxy.container.InvokableContext;
import org.jboss.ejb3.proxy.mc.MicrocontainerBindings;
@@ -37,11 +39,16 @@
public StatelessContainer(JBossSessionBeanMetaData metaData, ClassLoader classLoader) throws ClassNotFoundException
{
super(metaData, classLoader);
+ }
- // Create and set Container Name
- String containerName = MicrocontainerBindings.MC_NAMESPACE_EJBCONTAINER_STATELESS + metaData.getEjbName();
- this.setName(containerName);
-
+ /**
+ * Creates a unique name for this container
+ *
+ * @return
+ */
+ protected final String createContainerName()
+ {
+ return MicrocontainerBindings.MC_NAMESPACE_EJBCONTAINER_STATELESS + this.getMetaData().getEjbName() + "/"
+ + UUID.randomUUID();
}
-
}
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-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/ProxyEqualityTestCaseBase.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -35,7 +35,10 @@
/**
* ProxyEqualityTestCaseBase
*
- * Support for Proxy Equality Test Cases
+ * Support for Proxy Equality Test Cases as
+ * defined by:
+ *
+ * EJB 3.0 Core Specification 3.4.5
*
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
@@ -71,7 +74,7 @@
SessionProxyFactory factory = this.createSessionLocalProxyFactory();
// Create Proxy
- Object proxy = factory.createProxyDefault();
+ Object proxy = this.createProxyDefault(factory);
// Ensure equal to itself by value
TestCase
@@ -92,7 +95,7 @@
SessionProxyFactory factory = this.createSessionLocalProxyFactory();
// Create Proxy
- Object proxy = factory.createProxyDefault();
+ Object proxy = this.createProxyDefault(factory);
// Ensure equal to itself by value
TestCase
@@ -127,6 +130,18 @@
}
// --------------------------------------------------------------------------------||
+ // Helper Methods -----------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Creates a default proxy for the specified Session ProxyFactory
+ */
+ protected Object createProxyDefault(SessionProxyFactory factory)
+ {
+ return factory.createProxyDefault();
+ }
+
+ // --------------------------------------------------------------------------------||
// Specifications -----------------------------------------------------------------||
// --------------------------------------------------------------------------------||
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 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/unit/SfsbProxyEqualityTestCase.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -21,10 +21,15 @@
*/
package org.jboss.ejb3.test.proxy.spec_3_4_5.unit;
+import java.lang.reflect.Proxy;
+import java.util.UUID;
+
import junit.framework.TestCase;
+import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
import org.jboss.ejb3.proxy.factory.session.stateful.StatefulSessionLocalProxyFactory;
import org.jboss.ejb3.proxy.factory.session.stateful.StatefulSessionRemoteProxyFactory;
+import org.jboss.ejb3.proxy.intf.StatefulSessionProxy;
import org.jboss.ejb3.test.proxy.common.Utils;
import org.jboss.ejb3.test.proxy.common.container.StatefulContainer;
import org.jboss.ejb3.test.proxy.common.ejb.sfsb.MyStatefulBean;
@@ -61,7 +66,7 @@
* Tests that two local proxies to the same SFSB are not equal by value
*/
@Test
- public void testDifferentSlsbLocalProxiesNotEqual() throws Throwable
+ public void testDifferentSfsbLocalProxiesNotEqual() throws Throwable
{
// Make a Local Proxy Factory
StatefulSessionLocalProxyFactory factory = this.createSessionLocalProxyFactory();
@@ -70,6 +75,10 @@
Object proxy1 = factory.createProxyDefault();
Object proxy2 = factory.createProxyDefault();
+ // Manually Set Session IDs
+ this.setSessionIdOnProxy(proxy1, new Integer(1));
+ this.setSessionIdOnProxy(proxy2, new Integer(2));
+
// Ensure they're not equal to one another
TestCase
.assertTrue(
@@ -85,7 +94,7 @@
* Tests that two remote proxies to the same SFSB are not equal by value
*/
@Test
- public void testDifferentSlsbRemoteProxiesNotEqual() throws Throwable
+ public void testDifferentSfsbRemoteProxiesNotEqual() throws Throwable
{
// Make a Remote Proxy Factory
StatefulSessionRemoteProxyFactory factory = this.createSessionRemoteProxyFactory();
@@ -94,6 +103,10 @@
Object proxy1 = factory.createProxyDefault();
Object proxy2 = factory.createProxyDefault();
+ // Manually Set Session IDs
+ this.setSessionIdOnProxy(proxy1, new Integer(1));
+ this.setSessionIdOnProxy(proxy2, new Integer(2));
+
// Ensure they're not equal to one another
TestCase
.assertTrue(
@@ -104,6 +117,35 @@
}
// --------------------------------------------------------------------------------||
+ // Helper Methods -----------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Sets the specified ID on the specified proxy
+ */
+ private void setSessionIdOnProxy(Object proxy, Object id)
+ {
+ // Get the InvocationHander for the Proxy
+ StatefulSessionProxy handler = (StatefulSessionProxy) Proxy.getInvocationHandler(proxy);
+ handler.setSessionId(id);
+ }
+
+ /**
+ * Creates a default proxy for the specified Session ProxyFactory
+ */
+ protected Object createProxyDefault(SessionProxyFactory factory)
+ {
+ // Get Proxy
+ Object proxy = super.createProxyDefault(factory);
+
+ // Set a unique ID
+ this.setSessionIdOnProxy(proxy, UUID.randomUUID());
+
+ // Return
+ return proxy;
+ }
+
+ // --------------------------------------------------------------------------------||
// Lifecycle Methods --------------------------------------------------------------||
// --------------------------------------------------------------------------------||
@@ -151,7 +193,7 @@
// Make a Local Proxy Factory
StatefulSessionLocalProxyFactory factory = new StatefulSessionLocalProxyFactory(sfsb.getMetaData(), sfsb
- .getClassLoader(), sfsb.getName());
+ .getClassLoader());
// Start
factory.start();
@@ -174,7 +216,7 @@
// Make a Remote Proxy Factory
StatefulSessionRemoteProxyFactory factory = new StatefulSessionRemoteProxyFactory(sfsb.getMetaData(), sfsb
- .getClassLoader(), sfsb.getName());
+ .getClassLoader());
// Start
factory.start();
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/unit/SlsbProxyEqualityTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/unit/SlsbProxyEqualityTestCase.java 2008-05-23 23:29:13 UTC (rev 73644)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/unit/SlsbProxyEqualityTestCase.java 2008-05-24 06:26:59 UTC (rev 73645)
@@ -151,7 +151,7 @@
// Create the Factory
StatelessSessionLocalProxyFactory factory = new StatelessSessionLocalProxyFactory(container.getMetaData(),
- container.getClassLoader(), container.getName());
+ container.getClassLoader());
// Start
factory.start();
@@ -174,7 +174,7 @@
// Create the Factory
StatelessSessionRemoteProxyFactory factory = new StatelessSessionRemoteProxyFactory(container.getMetaData(),
- container.getClassLoader(), container.getName());
+ container.getClassLoader());
// Start
factory.start();
More information about the jboss-cvs-commits
mailing list