[jboss-cvs] JBossAS SVN: r73605 - in projects/ejb3/trunk/proxy/src: main/java/org/jboss/ejb3/proxy/factory/session and 11 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu May 22 22:00:34 EDT 2008
Author: ALRubinger
Date: 2008-05-22 22:00:34 -0400 (Thu, 22 May 2008)
New Revision: 73605
Added:
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/Utils.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/
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/SessionSpecContainer.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/common/ejb/
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStateless.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStateless21Local.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStateless21Remote.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessBean.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessLocal.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessLocalHome.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessRemote.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessRemoteHome.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/
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/
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/unit/SlsbProxyEqualityTestCase.java
Removed:
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/StatelessContainer.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless21Local.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless21Remote.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessBean.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessLocal.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessLocalHome.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessRemote.java
projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessRemoteHome.java
projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/
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/SessionProxyFactoryBase.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/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase.java
Log:
[EJBTHREE-1345] Exposed Specification Violations in Proxy Equality, EJB3 Core Spec 3.4.5; Centralized some common Testing Code
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-22 22:23:27 UTC (rev 73604)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactoryBase.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -95,6 +95,18 @@
}
return proxyConstructor;
}
+
+ // --------------------------------------------------------------------------------||
+ // Contracts ----------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Return the name of the interceptor stack to apply to
+ * proxies created by this proxy factory
+ *
+ * @return
+ */
+ protected abstract String getInterceptorStackName();
// --------------------------------------------------------------------------------||
// Lifecycle Methods --------------------------------------------------------------||
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-22 22:23:27 UTC (rev 73604)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/SessionProxyFactoryBase.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -130,7 +130,7 @@
{
// Create a new Proxy instance, and return
return this.getConstructorProxyHome().newInstance(
- this.getInvocationHandlerConstructor().newInstance(this.getContainerName(),null));
+ this.getInvocationHandlerConstructor().newInstance(this.getContainerName(), null));
}
catch (Throwable t)
@@ -153,19 +153,21 @@
*/
public Object createProxyDefault()
{
- // Initialize an error message
- String errorMessage = "Could not create the Default Proxy for " + this.getMetadata().getEjbName();
+ // Obtain Constructor to Default Proxy
+ Constructor<?> constructor = this.getConstructorProxyDefault();
+ assert constructor != null : "Constructor for Default Proxy was null; perhaps the "
+ + SessionProxyFactory.class.getSimpleName() + " was not properly started?";
try
{
// Create a new Proxy instance, and return
- return this.getConstructorProxyDefault().newInstance(
- this.getInvocationHandlerConstructor().newInstance(this.getContainerName(), null));
+ return constructor.newInstance(this.getInvocationHandlerConstructor().newInstance(this.getContainerName(),
+ null));
}
catch (Throwable t)
{
// Throw a descriptive error message along with the originating Throwable
- throw new RuntimeException(errorMessage, t);
+ throw new RuntimeException("Could not create the Default Proxy for " + this.getMetadata().getEjbName(), t);
}
}
@@ -179,10 +181,6 @@
*/
public Object createProxyBusiness(final String businessInterfaceName)
{
- // Initialize an error message
- String errorMessage = "Could not create the EJB3 Business Proxy implementing \"" + businessInterfaceName
- + "\" for " + this.getMetadata().getEjbName();
-
try
{
// Ensure businessInterfaceName is specified
@@ -203,7 +201,8 @@
catch (Throwable t)
{
// Throw a descriptive error message along with the originating Throwable
- throw new RuntimeException(errorMessage, t);
+ throw new RuntimeException("Could not create the EJB3 Business Proxy implementing \"" + businessInterfaceName
+ + "\" for " + this.getMetadata().getEjbName(), t);
}
}
@@ -214,9 +213,6 @@
*/
public Object createProxyEjb2x()
{
- // Initialize an error message
- String errorMessage = "Could not create the EJB2.x Proxy for " + this.getMetadata().getEjbName();
-
try
{
// Create a new Proxy instance, and return
@@ -226,7 +222,7 @@
catch (Throwable t)
{
// Throw a descriptive error message along with the originating Throwable
- throw new RuntimeException(errorMessage, t);
+ throw new RuntimeException("Could not create the EJB2.x Proxy for " + this.getMetadata().getEjbName(), t);
}
}
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-22 22:23:27 UTC (rev 73604)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionLocalProxyFactory.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -117,11 +117,24 @@
}
catch (NoSuchMethodException e)
{
- throw new RuntimeException("Could not find Constructor with one String argument for "
+ throw new RuntimeException("Could not find Constructor with two String arguments for "
+ StatelessProxyInvocationHandler.class.getName(), e);
}
}
+ /**
+ * Return the name of the interceptor stack to apply to
+ * proxies created by this proxy factory
+ *
+ * @return
+ */
+ @Override
+ protected String getInterceptorStackName()
+ {
+ // No client-side interceptors for remote
+ return null;
+ }
+
// --------------------------------------------------------------------------------||
// Lifecycle Methods --------------------------------------------------------------||
// --------------------------------------------------------------------------------||
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-22 22:23:27 UTC (rev 73604)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionRemoteProxyFactory.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -46,6 +46,8 @@
private static final Logger logger = Logger.getLogger(StatelessSessionRemoteProxyFactory.class);
+ private static final String STACK_NAME_STATELESS_SESSION_CLIENT_INTERCEPTORS = "StatelessSessionClientInterceptors";
+
// --------------------------------------------------------------------------------||
// Constructor --------------------------------------------------------------------||
// --------------------------------------------------------------------------------||
@@ -117,11 +119,23 @@
}
catch (NoSuchMethodException e)
{
- throw new RuntimeException("Could not find Constructor with one String argument for "
+ throw new RuntimeException("Could not find Constructor with two String arguments for "
+ StatelessProxyInvocationHandler.class.getName(), e);
}
}
+ /**
+ * Return the name of the interceptor stack to apply to
+ * proxies created by this proxy factory
+ *
+ * @return
+ */
+ @Override
+ protected String getInterceptorStackName()
+ {
+ return StatelessSessionRemoteProxyFactory.STACK_NAME_STATELESS_SESSION_CLIENT_INTERCEPTORS;
+ }
+
// --------------------------------------------------------------------------------||
// Lifecycle Methods --------------------------------------------------------------||
// --------------------------------------------------------------------------------||
Deleted: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/StatelessContainer.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/StatelessContainer.java 2008-05-22 22:23:27 UTC (rev 73604)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/StatelessContainer.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -1,174 +0,0 @@
-/*
- * 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.test.proxy.common;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.beans.metadata.api.annotations.Start;
-import org.jboss.beans.metadata.api.annotations.Stop;
-import org.jboss.ejb3.interceptors.container.ContainerMethodInvocation;
-import org.jboss.ejb3.proxy.container.InvokableContext;
-import org.jboss.ejb3.proxy.hack.Hack;
-import org.jboss.ejb3.proxy.jndiregistrar.JndiRegistrar;
-import org.jboss.ejb3.proxy.lang.SerializableMethod;
-import org.jboss.ejb3.proxy.mc.MicrocontainerBindings;
-import org.jboss.kernel.Kernel;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
-
-/**
- * A simple stateless container that binds proxies and can be invoked.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class StatelessContainer implements InvokableContext<ContainerMethodInvocation>
-{
- private static final Logger log = Logger.getLogger(StatelessContainer.class);
-
- private JBossSessionBeanMetaData metaData;
-
- private Class<?> beanClass;
-
- private Kernel kernel;
-
- /**
- * The unique name under which this container has been registered
- */
- private String containerName;
-
- /**
- * Invokes the method described by the specified serializable method
- * as called from the specified proxy, using the specified arguments
- *
- * @param proxy The proxy making the invocation
- * @param method The method to be invoked
- * @param args The arguments to the invocation
- * @throws Throwable A possible exception thrown by the invocation
- * @return
- */
- public Object invoke(Object proxy, SerializableMethod method, Object[] args) throws Throwable
- {
- // Get the types from the arguments
- List<Class<?>> types = new ArrayList<Class<?>>();
- for (Object arg : args)
- {
- types.add(arg.getClass());
- }
- Class<?>[] argTypes = types.toArray(new Class<?>[]
- {});
-
- // Obtain the method for invocation
- //TODO Use correct classloader, should probably be an instance of the Container
- Method m = Class.forName(method.getClassName()).getDeclaredMethod(method.getName(), argTypes);
-
- return localInvoke(m, args);
- }
-
- public StatelessContainer(String containerName, JBossSessionBeanMetaData metaData) throws ClassNotFoundException
- {
- this.metaData = metaData;
- this.beanClass = Class.forName(metaData.getEjbClass());
- this.kernel = Hack.BOOTSTRAP.getKernel(); //TODO Remove and get properly
- this.setContainerName(containerName);
- }
-
- private Object createInstance() throws InstantiationException, IllegalAccessException
- {
- return beanClass.newInstance();
- }
-
- public Object localInvoke(Method method, Object args[]) throws Throwable
- {
- // Mock up a new instance, traditionally this would be obtained from a Pool
- Object obj = createInstance();
-
- // Invoke
- return method.invoke(obj, args);
- }
-
- @Start
- public void start() throws Throwable
- {
- log.info("Starting " + this);
-
- // Carlo's original code
- // InitialContext ctx = new InitialContext();
- // //String jndiName = metaData.determineLocalJndiName();
- // String jndiName = "MyStatelessBean/local";
- // ClassLoader classLoader = beanClass.getClassLoader();
- // Class<?> interfaces[] = { MyStatelessLocal.class };
- // InvocationHandler handler = new StatelessInvocationHandler();
- // Object proxy = Proxy.newProxyInstance(classLoader, interfaces, handler);
- // Util.createSubcontext(ctx, "MyStatelessBean");
- // // TODO: should no be non-serializable (how to get Kernel instance?)
- // NonSerializableFactory.rebind(ctx, jndiName, proxy);
-
- // Obtain registrar
- JndiRegistrar registrar = this.getJndiRegistrar();
-
- // Obtain the TCL
- //TODO Previously the CL was a member of the Container itself, this should fly for now
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
-
- // Bind all appropriate references/factories to Global JNDI for Client access
- registrar.bindEjb(this.metaData, cl, this.getContainerName());
-
- }
-
- @Stop
- public void stop()
- {
- log.info("Stopping " + this);
-
- //TODO We need to unbind the EJB, something like:
- //registrar.unbindEjb(this.metaData);
- // or some key by which the registrar will keep track of all bindings
- }
-
- /**
- * Obtains the JndiRegistrar from MC
- *
- * @return
- */
- protected JndiRegistrar getJndiRegistrar()
- {
- // Lookup
- JndiRegistrar registrar = (JndiRegistrar) this.kernel.getController().getInstalledContext(
- MicrocontainerBindings.MC_BEAN_NAME_JNDI_REGISTRAR).getTarget();
-
- // Return
- return registrar;
- }
-
- public String getContainerName()
- {
- return containerName;
- }
-
- private void setContainerName(String containerName)
- {
- this.containerName = containerName;
- }
-}
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/Utils.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/Utils.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/Utils.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -0,0 +1,107 @@
+/*
+ * 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.test.proxy.common;
+
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.jboss.ejb3.test.proxy.common.container.StatelessContainer;
+import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessBean;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.annotation.creator.ejb.EjbJar30Creator;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionPolicyDecorator;
+import org.jboss.metadata.ejb.spec.EjbJar30MetaData;
+
+/**
+ * Utils
+ *
+ * Utilities for Generating Test EJBs
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class Utils
+{
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(Utils.class);
+
+ // --------------------------------------------------------------------------------||
+ // Functional Methods -------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Creates and returns a SLSB Container for the SLSB Implementation Class specified
+ *
+ * @param slsbImplementationClass
+ * @return
+ * @throws Throwable
+ */
+ public static StatelessContainer createSlsb(Class<?> slsbImplementationClass) throws Throwable
+ {
+ // emulate annotation deployer
+ AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+ Collection<Class<?>> classes = new HashSet<Class<?>>();
+ classes.add(MyStatelessBean.class);
+ EjbJar30MetaData metaData = new EjbJar30Creator(finder).create(classes);
+
+ // emulate merge deployer
+ JBossMetaData mergedMetaData = new JBossMetaData();
+ mergedMetaData.merge(null, metaData);
+
+ JBossSessionBeanMetaData beanMetaDataDelegate = (JBossSessionBeanMetaData) mergedMetaData
+ .getEnterpriseBean(MyStatelessBean.class.getSimpleName());
+
+ // Use a Session JNDI Binding Policy for the metadata
+ JBossSessionPolicyDecorator beanMetaData = new JBossSessionPolicyDecorator(beanMetaDataDelegate);
+
+ // Log out JNDI Names
+ log.info("Business Remote JNDI Name: " + beanMetaData.determineJndiName()); // MyStatelessBean/remote
+ for (String businessInterface : beanMetaData.getBusinessRemotes())
+ {
+ log.info("Business Remote JNDI Name for " + businessInterface + ": "
+ + beanMetaData.determineResolvedJndiName(businessInterface));
+ }
+ log.info("Local JNDI Name: " + beanMetaData.determineLocalJndiName()); // MyStatelessBean/local
+ for (String businessInterface : beanMetaData.getBusinessLocals())
+ {
+ log.info("Business Local JNDI Name for " + businessInterface + ": "
+ + beanMetaData.determineResolvedJndiName(businessInterface));
+ }
+ log.info("Local Home JNDI Name: " + beanMetaData.determineResolvedJndiName(beanMetaData.getLocalHome()));
+ log.info("Home JNDI Name: " + beanMetaData.determineResolvedJndiName(beanMetaData.getHome()));
+
+ // Make a Container
+ StatelessContainer container = new StatelessContainer(beanMetaData, Thread.currentThread()
+ .getContextClassLoader());
+
+ // Return
+ return container;
+ }
+}
Added: 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 (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/SessionContainer.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -0,0 +1,255 @@
+/*
+ * 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.test.proxy.common.container;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.beans.metadata.api.annotations.Start;
+import org.jboss.beans.metadata.api.annotations.Stop;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.ejb3.proxy.hack.Hack;
+import org.jboss.ejb3.proxy.jndiregistrar.JndiRegistrar;
+import org.jboss.ejb3.proxy.lang.SerializableMethod;
+import org.jboss.ejb3.proxy.mc.MicrocontainerBindings;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+
+/**
+ * SessionContainer
+ *
+ * A Mock Session Container for use in Proxy Testing
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class SessionContainer
+{
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(SessionContainer.class);
+
+ // --------------------------------------------------------------------------------||
+ // Instance Members ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * The unique name under which this container has been registered
+ */
+ private String name;
+
+ /**
+ * The CL for this container and all classes associated with this EJB
+ */
+ private ClassLoader classLoader;
+
+ /**
+ * Metadata for this Container
+ */
+ private JBossSessionBeanMetaData metaData;
+
+ /**
+ * The Bean Implementation Class
+ */
+ private Class<?> beanClass;
+
+ // --------------------------------------------------------------------------------||
+ // Constructor --------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Constructor
+ *
+ * @param metaData
+ * @param classLoader
+ */
+ protected SessionContainer(JBossSessionBeanMetaData metaData, ClassLoader classLoader)
+ {
+ // Set Metadata
+ this.setMetaData(metaData);
+
+ // Set CL
+ this.setClassLoader(classLoader);
+
+ // Set Bean Class
+ String beanClassName = this.getMetaData().getEjbClass();
+ try
+ {
+ this.setBeanClass(this.getClassLoader().loadClass(beanClassName));
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new RuntimeException("Could not find Bean Implementation class \"" + beanClassName + "\" in the "
+ + ClassLoader.class.getSimpleName() + " for " + this);
+ }
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Functional Methods -------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Invokes the method described by the specified serializable method
+ * as called from the specified proxy, using the specified arguments
+ *
+ * @param proxy The proxy making the invocation
+ * @param method The method to be invoked
+ * @param args The arguments to the invocation
+ * @throws Throwable A possible exception thrown by the invocation
+ * @return
+ */
+ public Object invoke(Object proxy, SerializableMethod method, Object[] args) throws Throwable
+ {
+ // Get the types from the arguments
+ List<Class<?>> types = new ArrayList<Class<?>>();
+ for (Object arg : args)
+ {
+ types.add(arg.getClass());
+ }
+ Class<?>[] argTypes = types.toArray(new Class<?>[]
+ {});
+
+ // Obtain the method for invocation
+ Method m = this.getClassLoader().loadClass(method.getClassName()).getDeclaredMethod(method.getName(), argTypes);
+
+ // Invoke on the bean
+ return invokeBean(m, args);
+ }
+
+ private Object createInstance() throws InstantiationException, IllegalAccessException
+ {
+ return this.getBeanClass().newInstance();
+ }
+
+ public Object invokeBean(Method method, Object args[]) throws Throwable
+ {
+ // Mock up a new instance, traditionally this would be obtained from a Pool
+ Object obj = createInstance();
+
+ // Invoke
+ return method.invoke(obj, args);
+ }
+
+ @Start
+ public void start() throws Throwable
+ {
+ log.info("Starting " + this);
+
+ // Obtain registrar
+ JndiRegistrar registrar = this.getJndiRegistrar();
+
+ // Bind all appropriate references/factories to Global JNDI for Client access, if a JNDI Registrar is present
+ if (registrar != null)
+ {
+ registrar.bindEjb(this.getMetaData(), this.getClassLoader(), this.getName());
+ }
+ else
+ {
+ log.warn("No " + JndiRegistrar.class.getSimpleName() + " was found; byassing binding of Proxies to "
+ + this.getName() + " in Global JNDI.");
+ }
+
+ }
+
+ @Stop
+ public void stop()
+ {
+ log.info("Stopping " + this);
+
+ //TODO We need to unbind the EJB, something like:
+ //JndiRegistrar.unbindEjb(this.metaData);
+ // or some key by which the registrar will keep track of all bindings
+ }
+
+ /**
+ * Obtains the JndiRegistrar from MC, null if not found
+ *
+ * @return
+ */
+ protected JndiRegistrar getJndiRegistrar()
+ {
+ // Lookup
+ ControllerContext context = Hack.BOOTSTRAP.getKernel().getController().getInstalledContext(
+ MicrocontainerBindings.MC_BEAN_NAME_JNDI_REGISTRAR);
+
+ // If not installed, warn and continue
+ if (context == null)
+ {
+ log.warn("No " + JndiRegistrar.class.getName() + " was found installed in MC at "
+ + MicrocontainerBindings.MC_BEAN_NAME_JNDI_REGISTRAR);
+ return null;
+ }
+
+ // Cast
+ JndiRegistrar registrar = (JndiRegistrar) context.getTarget();
+
+ // Return
+ return registrar;
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Accessors / Mutators -----------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ public String getName()
+ {
+ return name;
+ }
+
+ protected void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public ClassLoader getClassLoader()
+ {
+ return classLoader;
+ }
+
+ private void setClassLoader(ClassLoader classLoader)
+ {
+ this.classLoader = classLoader;
+ }
+
+ public JBossSessionBeanMetaData getMetaData()
+ {
+ return metaData;
+ }
+
+ private void setMetaData(JBossSessionBeanMetaData metaData)
+ {
+ this.metaData = metaData;
+ }
+
+ public Class<?> getBeanClass()
+ {
+ return beanClass;
+ }
+
+ private void setBeanClass(Class<?> beanClass)
+ {
+ this.beanClass = beanClass;
+ }
+}
Added: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/SessionSpecContainer.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/SessionSpecContainer.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/SessionSpecContainer.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -0,0 +1,51 @@
+/*
+ * 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.test.proxy.common.container;
+
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+
+/**
+ * SessionSpecContainer
+ *
+ * A Mock Session Container adhering to the EJB 3.0 Specification
+ * for use in Proxy Testing
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class SessionSpecContainer extends SessionContainer
+{
+ // --------------------------------------------------------------------------------||
+ // Constructor --------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Constructor
+ *
+ * @param metadata
+ * @param classLoader
+ */
+ protected SessionSpecContainer(JBossSessionBeanMetaData metadata, ClassLoader classLoader)
+ {
+ super(metadata, classLoader);
+ }
+}
Copied: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/StatelessContainer.java (from rev 73603, projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/StatelessContainer.java)
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/StatelessContainer.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/container/StatelessContainer.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -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.test.proxy.common.container;
+
+import org.jboss.ejb3.interceptors.container.ContainerMethodInvocation;
+import org.jboss.ejb3.proxy.container.InvokableContext;
+import org.jboss.ejb3.proxy.mc.MicrocontainerBindings;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+
+/**
+ * A simple stateless container that binds proxies and can be invoked.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class StatelessContainer extends SessionSpecContainer implements InvokableContext<ContainerMethodInvocation>
+{
+ public StatelessContainer(JBossSessionBeanMetaData metaData, ClassLoader classLoader) throws ClassNotFoundException
+ {
+ super(metaData, classLoader);
+
+ // Create and set Container Name
+ String containerName = MicrocontainerBindings.MC_NAMESPACE_CONTAINER_STATELESS + metaData.getEjbName();
+ this.setName(containerName);
+
+ }
+
+}
Copied: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStateless.java (from rev 73603, projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless.java)
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStateless.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStateless.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -0,0 +1,31 @@
+/*
+ * 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.test.proxy.common.ejb.slsb;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface MyStateless
+{
+ String sayHi(String name);
+}
Copied: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStateless21Local.java (from rev 73603, projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless21Local.java)
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStateless21Local.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStateless21Local.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -0,0 +1,33 @@
+/*
+ * 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.test.proxy.common.ejb.slsb;
+
+import javax.ejb.EJBLocalObject;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface MyStateless21Local extends EJBLocalObject, MyStateless
+{
+
+}
Copied: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStateless21Remote.java (from rev 73603, projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless21Remote.java)
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStateless21Remote.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStateless21Remote.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -0,0 +1,33 @@
+/*
+ * 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.test.proxy.common.ejb.slsb;
+
+import javax.ejb.EJBObject;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface MyStateless21Remote extends EJBObject, MyStateless
+{
+
+}
Copied: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessBean.java (from rev 73603, projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessBean.java)
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessBean.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessBean.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -0,0 +1,41 @@
+/*
+ * 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.test.proxy.common.ejb.slsb;
+
+import javax.ejb.LocalHome;
+import javax.ejb.RemoteHome;
+import javax.ejb.Stateless;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at LocalHome(MyStatelessLocalHome.class)
+ at RemoteHome(MyStatelessRemoteHome.class)
+public class MyStatelessBean implements MyStatelessLocal, MyStatelessRemote
+{
+ public String sayHi(String name)
+ {
+ return "Hi " + name;
+ }
+}
Copied: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessLocal.java (from rev 73603, projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessLocal.java)
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessLocal.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessLocal.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -0,0 +1,34 @@
+/*
+ * 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.test.proxy.common.ejb.slsb;
+
+import javax.ejb.Local;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Local
+public interface MyStatelessLocal extends MyStateless
+{
+
+}
Copied: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessLocalHome.java (from rev 73603, projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessLocalHome.java)
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessLocalHome.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessLocalHome.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -0,0 +1,33 @@
+/*
+ * 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.test.proxy.common.ejb.slsb;
+
+import javax.ejb.EJBLocalHome;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface MyStatelessLocalHome extends EJBLocalHome
+{
+ MyStateless21Local create();
+}
Copied: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessRemote.java (from rev 73603, projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessRemote.java)
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessRemote.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessRemote.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -0,0 +1,34 @@
+/*
+ * 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.test.proxy.common.ejb.slsb;
+
+import javax.ejb.Remote;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Remote
+public interface MyStatelessRemote extends MyStateless
+{
+
+}
Copied: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessRemoteHome.java (from rev 73603, projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessRemoteHome.java)
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessRemoteHome.java (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/ejb/slsb/MyStatelessRemoteHome.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -0,0 +1,33 @@
+/*
+ * 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.test.proxy.common.ejb.slsb;
+
+import javax.ejb.EJBHome;
+
+/**
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface MyStatelessRemoteHome extends EJBHome
+{
+ MyStateless21Remote create();
+}
Deleted: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless.java 2008-05-22 22:23:27 UTC (rev 73604)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -1,31 +0,0 @@
-/*
- * 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.test.proxy.session;
-
-/**
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public interface MyStateless
-{
- String sayHi(String name);
-}
Deleted: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless21Local.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless21Local.java 2008-05-22 22:23:27 UTC (rev 73604)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless21Local.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -1,33 +0,0 @@
-/*
- * 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.test.proxy.session;
-
-import javax.ejb.EJBLocalObject;
-
-/**
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public interface MyStateless21Local extends EJBLocalObject, MyStateless
-{
-
-}
Deleted: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless21Remote.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless21Remote.java 2008-05-22 22:23:27 UTC (rev 73604)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStateless21Remote.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -1,33 +0,0 @@
-/*
- * 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.test.proxy.session;
-
-import javax.ejb.EJBObject;
-
-/**
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public interface MyStateless21Remote extends EJBObject, MyStateless
-{
-
-}
Deleted: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessBean.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessBean.java 2008-05-22 22:23:27 UTC (rev 73604)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessBean.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -1,41 +0,0 @@
-/*
- * 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.test.proxy.session;
-
-import javax.ejb.LocalHome;
-import javax.ejb.RemoteHome;
-import javax.ejb.Stateless;
-
-/**
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
- at Stateless
- at LocalHome(MyStatelessLocalHome.class)
- at RemoteHome(MyStatelessRemoteHome.class)
-public class MyStatelessBean implements MyStatelessLocal, MyStatelessRemote
-{
- public String sayHi(String name)
- {
- return "Hi " + name;
- }
-}
Deleted: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessLocal.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessLocal.java 2008-05-22 22:23:27 UTC (rev 73604)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessLocal.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -1,34 +0,0 @@
-/*
- * 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.test.proxy.session;
-
-import javax.ejb.Local;
-
-/**
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
- at Local
-public interface MyStatelessLocal extends MyStateless
-{
-
-}
Deleted: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessLocalHome.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessLocalHome.java 2008-05-22 22:23:27 UTC (rev 73604)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessLocalHome.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -1,33 +0,0 @@
-/*
- * 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.test.proxy.session;
-
-import javax.ejb.EJBLocalHome;
-
-/**
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public interface MyStatelessLocalHome extends EJBLocalHome
-{
- MyStateless21Local create();
-}
Deleted: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessRemote.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessRemote.java 2008-05-22 22:23:27 UTC (rev 73604)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessRemote.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -1,34 +0,0 @@
-/*
- * 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.test.proxy.session;
-
-import javax.ejb.Remote;
-
-/**
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
- at Remote
-public interface MyStatelessRemote extends MyStateless
-{
-
-}
Deleted: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessRemoteHome.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessRemoteHome.java 2008-05-22 22:23:27 UTC (rev 73604)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/MyStatelessRemoteHome.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -1,33 +0,0 @@
-/*
- * 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.test.proxy.session;
-
-import javax.ejb.EJBHome;
-
-/**
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public interface MyStatelessRemoteHome extends EJBHome
-{
- MyStateless21Remote create();
-}
Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase.java 2008-05-22 22:23:27 UTC (rev 73604)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCase.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -33,18 +33,20 @@
import org.jboss.ejb3.proxy.hack.Hack;
import org.jboss.ejb3.proxy.mc.MicrocontainerBindings;
import org.jboss.ejb3.test.proxy.common.EmbeddedTestMcBootstrap;
-import org.jboss.ejb3.test.proxy.common.StatelessContainer;
-import org.jboss.ejb3.test.proxy.session.MyStatelessBean;
-import org.jboss.ejb3.test.proxy.session.MyStatelessLocal;
-import org.jboss.ejb3.test.proxy.session.MyStatelessLocalHome;
-import org.jboss.ejb3.test.proxy.session.MyStatelessRemote;
-import org.jboss.ejb3.test.proxy.session.MyStatelessRemoteHome;
+import org.jboss.ejb3.test.proxy.common.Utils;
+import org.jboss.ejb3.test.proxy.common.container.StatelessContainer;
+import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessBean;
+import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessLocal;
+import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessLocalHome;
+import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessRemote;
+import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessRemoteHome;
import org.jboss.logging.Logger;
import org.jboss.metadata.annotation.creator.ejb.EjbJar30Creator;
import org.jboss.metadata.annotation.finder.AnnotationFinder;
import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
import org.jboss.metadata.ejb.jboss.JBossMetaData;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionPolicyDecorator;
import org.jboss.metadata.ejb.jboss.jndipolicy.spi.EjbDeploymentSummary;
import org.jboss.metadata.ejb.spec.EjbJar30MetaData;
import org.junit.AfterClass;
@@ -75,64 +77,11 @@
bootstrap.deploy(ProxySessionTestCase.class);
- // emulate annotation deployer
- AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
- Collection<Class<?>> classes = new HashSet<Class<?>>();
- classes.add(MyStatelessBean.class);
- EjbJar30MetaData metaData = new EjbJar30Creator(finder).create(classes);
+ // Create a SLSB
+ StatelessContainer container = Utils.createSlsb(MyStatelessBean.class);
- // emulate merge deployer
- JBossMetaData mergedMetaData = new JBossMetaData();
- mergedMetaData.merge(null, metaData);
-
- JBossSessionBeanMetaData beanMetaData = (JBossSessionBeanMetaData) mergedMetaData
- .getEnterpriseBean("MyStatelessBean");
-
- // Set a deployment summary (mock the resolver deployer)
- ClassLoader loader = MyStatelessBean.class.getClassLoader(); //TODO was: unit.getClassLoader()
- EjbDeploymentSummary summary = new EjbDeploymentSummary();
- summary.setBeanMD(beanMetaData);
- summary.setBeanClassName(beanMetaData.getEjbClass());
- summary.setDeploymentName(MyStatelessBean.class.getSimpleName()); //TODO was: unit.getShortName()
- String baseName = MyStatelessBean.class.getSimpleName(); //TODO was: unit.getRootFile().getName()
- summary.setDeploymentScopeBaseName(baseName);
- summary.setEjbName(beanMetaData.getEjbName());
- summary.setLoader(loader);
- summary.setLocal(beanMetaData.isMessageDriven());
- if (beanMetaData instanceof JBossSessionBeanMetaData)
- {
- JBossSessionBeanMetaData sbeanMD = (JBossSessionBeanMetaData) beanMetaData;
- summary.setStateful(sbeanMD.isStateful());
- }
- summary.setService(beanMetaData.isService());
-
- // Set the deployment summary
- mergedMetaData.setDeploymentSummary(summary);
-
- // Log out JNDI Names
- log.info("Business Remote JNDI Name: " + beanMetaData.determineJndiName()); // MyStatelessBean/remote
- for (String businessInterface : beanMetaData.getBusinessRemotes())
- {
- log.info("Business Remote JNDI Name for " + businessInterface + ": "
- + beanMetaData.determineResolvedJndiName(businessInterface));
- }
- log.info("Local JNDI Name: " + beanMetaData.determineLocalJndiName()); // MyStatelessBean/local
- for (String businessInterface : beanMetaData.getBusinessLocals())
- {
- log.info("Business Local JNDI Name for " + businessInterface + ": "
- + beanMetaData.determineResolvedJndiName(businessInterface));
- }
- log.info("Local Home JNDI Name: " + beanMetaData.determineResolvedJndiName(beanMetaData.getLocalHome()));
- log.info("Home JNDI Name: " + beanMetaData.determineResolvedJndiName(beanMetaData.getHome()));
-
- // Create a unique container name
- String containerName = MicrocontainerBindings.MC_NAMESPACE_CONTAINER_STATELESS + beanMetaData.getEjbName();
-
- // Make a Container
- StatelessContainer container = new StatelessContainer(containerName, beanMetaData);
-
// Install into MC
- bootstrap.installInstance(containerName, container);
+ bootstrap.installInstance(container.getName(), container);
}
/**
@@ -181,7 +130,7 @@
{
InitialContext ctx = new InitialContext();
- Object bean = ctx.lookup("MyStatelessBean/remoteHome"); // "home" or "remoteHome"?
+ Object bean = ctx.lookup("MyStatelessBean/home");
assertTrue(bean instanceof MyStatelessRemoteHome);
}
}
Added: 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 (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/ProxyEqualityTestCaseBase.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -0,0 +1,187 @@
+/*
+ * 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.test.proxy.spec_3_4_5;
+
+import junit.framework.TestCase;
+
+import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
+import org.jboss.ejb3.proxy.hack.Hack;
+import org.jboss.ejb3.test.proxy.common.EmbeddedTestMcBootstrap;
+import org.jboss.ejb3.test.proxy.common.container.SessionContainer;
+import org.jboss.logging.Logger;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * ProxyEqualityTestCaseBase
+ *
+ * Support for Proxy Equality Test Cases
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public abstract class ProxyEqualityTestCaseBase
+{
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(ProxyEqualityTestCaseBase.class);
+
+ private static EmbeddedTestMcBootstrap bootstrap;
+
+ /**
+ * Name of the SLSB Container for these tests
+ */
+ private static String slsbContainerName;
+
+ // --------------------------------------------------------------------------------||
+ // Tests --------------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * EJB 3.0 Core Specification 3.4.5
+ *
+ * Tests that a local proxy to a Session Bean is equal by value to itself
+ */
+ @Test
+ public void testSameLocalProxyEqual() throws Throwable
+ {
+ // Get the Container
+ SessionContainer container = this.getContainer();
+
+ // Make a Local Proxy Factory
+ SessionProxyFactory factory = this.createSessionLocalProxyFactory(container);
+ factory.start();
+
+ // Create Proxy
+ Object proxy = factory.createProxyDefault();
+
+ // Ensure equal to itself by value
+ TestCase
+ .assertTrue(
+ "EJB 3.0 Core Specification 3.4.5 Violation: Local proxy to Session Bean should be equal by value to itself",
+ proxy.equals(proxy));
+ }
+
+ /**
+ * EJB 3.0 Core Specification 3.4.5
+ *
+ * Tests that a remote proxy to a Session Bean is equal by value to itself
+ */
+ @Test
+ public void testSameRemoteProxyEqual() throws Throwable
+ {
+ // Get the Session Container
+ SessionContainer container = this.getContainer();
+
+ // Make a Local Proxy Factory
+ SessionProxyFactory factory = this.createSessionLocalProxyFactory(container);
+ factory.start();
+
+ // Create Proxy
+ Object proxy = factory.createProxyDefault();
+
+ // Ensure equal to itself by value
+ TestCase
+ .assertTrue(
+ "EJB 3.0 Core Specification 3.4.5 Violation: Remote proxy to Session Bean should be equal by value to itself",
+ proxy.equals(proxy));
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Lifecycle Methods --------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ @BeforeClass
+ public static void beforeClass() throws Throwable
+ {
+ // Create and set a new MC Bootstrap
+ ProxyEqualityTestCaseBase.setBootstrap(EmbeddedTestMcBootstrap.createEmbeddedMcBootstrap());
+
+ //TODO Remove Hack
+ Hack.BOOTSTRAP = bootstrap;
+ }
+
+ @AfterClass
+ public static void afterClass() throws Exception
+ {
+ // Shutdown MC
+ ProxyEqualityTestCaseBase.getBootstrap().shutdown();
+
+ // Set Bootstrap to null
+ ProxyEqualityTestCaseBase.setBootstrap(null);
+ Hack.BOOTSTRAP = null;
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Specifications -----------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the Container for use in this TestCase
+ *
+ * @return
+ */
+ protected abstract SessionContainer getContainer();
+
+ /**
+ * Creates a Proxy Factory for local Proxies
+ *
+ * @param container
+ * @return
+ */
+ protected abstract SessionProxyFactory createSessionLocalProxyFactory(SessionContainer container);
+
+ /**
+ * Creates a Proxy Factory for remote Proxies
+ *
+ * @param container
+ * @return
+ */
+ protected abstract SessionProxyFactory createSessionRemoteProxyFactory(SessionContainer container);
+
+ // --------------------------------------------------------------------------------||
+ // Accessors / Mutators -----------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ public static EmbeddedTestMcBootstrap getBootstrap()
+ {
+ return ProxyEqualityTestCaseBase.bootstrap;
+ }
+
+ public static void setBootstrap(EmbeddedTestMcBootstrap bootstrap)
+ {
+ ProxyEqualityTestCaseBase.bootstrap = bootstrap;
+ }
+
+ protected static String getSlsbContainerName()
+ {
+ return slsbContainerName;
+ }
+
+ protected static void setSlsbContainerName(String slsbContainerName)
+ {
+ ProxyEqualityTestCaseBase.slsbContainerName = slsbContainerName;
+ }
+}
Added: 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 (rev 0)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/spec_3_4_5/unit/SlsbProxyEqualityTestCase.java 2008-05-23 02:00:34 UTC (rev 73605)
@@ -0,0 +1,191 @@
+/*
+ * 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.test.proxy.spec_3_4_5.unit;
+
+import junit.framework.TestCase;
+
+import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
+import org.jboss.ejb3.proxy.factory.session.stateless.StatelessSessionLocalProxyFactory;
+import org.jboss.ejb3.proxy.factory.session.stateless.StatelessSessionRemoteProxyFactory;
+import org.jboss.ejb3.test.proxy.common.Utils;
+import org.jboss.ejb3.test.proxy.common.container.SessionContainer;
+import org.jboss.ejb3.test.proxy.common.container.StatelessContainer;
+import org.jboss.ejb3.test.proxy.common.ejb.slsb.MyStatelessBean;
+import org.jboss.ejb3.test.proxy.spec_3_4_5.ProxyEqualityTestCaseBase;
+import org.jboss.logging.Logger;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * SlsbProxyEqualityTestCase
+ *
+ * Test Cases to ensure that SLSB Proxies properly implement
+ * the notion of object equality described by
+ * EJB3 Core Specification 3.4.5.2
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class SlsbProxyEqualityTestCase extends ProxyEqualityTestCaseBase
+{
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(SlsbProxyEqualityTestCase.class);
+
+ // --------------------------------------------------------------------------------||
+ // Tests --------------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * EJB 3.0 Core Specification 3.4.5.2
+ *
+ * Tests that two local proxies to the same SLSB are equal by value
+ */
+ @Test
+ public void testDifferentSlsbLocalProxiesEqual() throws Throwable
+ {
+ // Get the SLSB Container
+ StatelessContainer slsb = this.getSlsb();
+
+ // Make a Local Proxy Factory
+ StatelessSessionLocalProxyFactory factory = new StatelessSessionLocalProxyFactory(slsb.getMetaData(), slsb
+ .getClassLoader(), slsb.getName());
+ factory.start();
+
+ // Create 2 Proxies
+ Object proxy1 = factory.createProxyDefault();
+ Object proxy2 = factory.createProxyDefault();
+
+ // Ensure they're equal to one another
+ TestCase
+ .assertTrue(
+ "EJB 3.0 Core Specification 3.4.5.2 Violation: Different local proxies to same SLSB should be equal by value",
+ proxy1.equals(proxy2));
+ TestCase.assertTrue("Hash Codes for equal Proxies should be equal", proxy1.hashCode() == proxy2.hashCode());
+ }
+
+ /**
+ * EJB 3.0 Core Specification 3.4.5.2
+ *
+ * Tests that two remote proxies to the same SLSB are equal by value
+ */
+ @Test
+ public void testDifferentSlsbRemoteProxiesEqual() throws Throwable
+ {
+ // Get the SLSB Container
+ StatelessContainer slsb = this.getSlsb();
+
+ // Make a Remote Proxy Factory
+ StatelessSessionRemoteProxyFactory factory = new StatelessSessionRemoteProxyFactory(slsb.getMetaData(), slsb
+ .getClassLoader(), slsb.getName());
+ factory.start();
+
+ // Create 2 Proxies
+ Object proxy1 = factory.createProxyDefault();
+ Object proxy2 = factory.createProxyDefault();
+
+ // Ensure they're equal to one another
+ TestCase
+ .assertTrue(
+ "EJB 3.0 Core Specification 3.4.5.2 Violation: Different remote proxies to same SLSB should be equal by value",
+ proxy1.equals(proxy2));
+ TestCase.assertTrue("Hash Codes for equal Proxies should be equal", proxy1.hashCode() == proxy2.hashCode());
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Lifecycle Methods --------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ @BeforeClass
+ public static void beforeClass() throws Throwable
+ {
+ // Call Super
+ ProxyEqualityTestCaseBase.beforeClass();
+
+ // Create a SLSB Container
+ StatelessContainer container = Utils.createSlsb(MyStatelessBean.class);
+ log.info("Created SLSB Container: " + container.getName());
+ SlsbProxyEqualityTestCase.setSlsbContainerName(container.getName());
+
+ // Install into MC
+ SlsbProxyEqualityTestCase.getBootstrap().installInstance(container.getName(), container);
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the Container for use in this TestCase
+ *
+ * @return
+ */
+ @Override
+ protected StatelessContainer getContainer()
+ {
+ return this.getSlsb();
+ }
+
+ /**
+ * Creates a Proxy Factory for local Proxies
+ *
+ * @param container
+ * @return
+ */
+ @Override
+ protected SessionProxyFactory createSessionLocalProxyFactory(SessionContainer container)
+ {
+ return new StatelessSessionLocalProxyFactory(container.getMetaData(), container.getClassLoader(), container
+ .getName());
+ }
+
+ /**
+ * Creates a Proxy Factory for remote Proxies
+ *
+ * @param container
+ * @return
+ */
+ @Override
+ protected SessionProxyFactory createSessionRemoteProxyFactory(SessionContainer container)
+ {
+ return new StatelessSessionRemoteProxyFactory(container.getMetaData(), container.getClassLoader(), container
+ .getName());
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Helper Methods -----------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the SLSB Container from MC
+ *
+ * @return
+ */
+ protected StatelessContainer getSlsb()
+ {
+ return (StatelessContainer) SlsbProxyEqualityTestCase.getBootstrap().getKernel().getController()
+ .getInstalledContext(SlsbProxyEqualityTestCase.getSlsbContainerName()).getTarget();
+ }
+
+}
More information about the jboss-cvs-commits
mailing list