[jboss-cvs] JBossAS SVN: r96170 - in projects/ejb3/trunk: core/src/main/java/org/jboss/ejb3 and 21 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Nov 9 08:49:05 EST 2009
Author: wolfc
Date: 2009-11-09 08:49:05 -0500 (Mon, 09 Nov 2009)
New Revision: 96170
Added:
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/io/
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/io/ObjectInputStream.java
projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/ejbthree1889/
projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/ejbthree1889/RedefiningClassLoader.java
projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/ejbthree1889/unit/
projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/ejbthree1889/unit/RemoteServiceTestCase.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/a/
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/a/EJBTestARemote.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/a/EJBTestAService.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/b/
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/b/EJBTestBRemote.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/b/EJBTestBService.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/unit/
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/unit/RedeployServiceTestCase.java
projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1889/
projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1889/a/
projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1889/a/META-INF/
projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1889/a/META-INF/jboss.xml
projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1889/b/
projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1889/b/META-INF/
projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1889/b/META-INF/jboss.xml
Modified:
projects/ejb3/trunk/core/pom.xml
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java
projects/ejb3/trunk/proxy-impl/.settings/org.maven.ide.eclipse.prefs
projects/ejb3/trunk/proxy-impl/pom.xml
projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/objectfactory/ProxyObjectFactory.java
projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/ejbthree1517/ReturnStaticValueInterceptor.java
projects/ejb3/trunk/testsuite/build-test.xml
Log:
EJBTHREE-1889: allow redeploy of service bean which exposes remote view
Modified: projects/ejb3/trunk/core/pom.xml
===================================================================
--- projects/ejb3/trunk/core/pom.xml 2009-11-09 13:45:29 UTC (rev 96169)
+++ projects/ejb3/trunk/core/pom.xml 2009-11-09 13:49:05 UTC (rev 96170)
@@ -428,7 +428,7 @@
<dependency>
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-proxy-impl</artifactId>
- <version>1.0.5</version>
+ <version>1.0.6-SNAPSHOT</version>
</dependency>
<dependency>
Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java 2009-11-09 13:45:29 UTC (rev 96169)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java 2009-11-09 13:49:05 UTC (rev 96170)
@@ -201,6 +201,8 @@
private ComponentStack cachedConnectionManager;
+ private boolean resurrectMetaData = false;
+
/**
* @param name Advisor name
* @param manager Domain to get interceptor bindings from
@@ -885,6 +887,13 @@
}
}
*/
+
+ log.info("Current context class loader is " + Thread.currentThread().getContextClassLoader());
+ if(resurrectMetaData)
+ {
+ processMetadata();
+ resurrectMetaData = false;
+ }
}
/**
@@ -970,17 +979,18 @@
pool = null;
}
+ log.info("STOPPED EJB: " + beanClass.getName() + " ejbName: " + ejbName);
+ }
+
+ public void destroy() throws Exception
+ {
+ // Once enc is destroyed, the encInjectors are invalid as well.
injectors = new ArrayList<Injector>();
encInjectors = new HashMap<String, EncInjector>();
InitialContextFactory.close(enc, this.initialContextProperties);
enc = null;
- log.info("STOPPED EJB: " + beanClass.getName() + " ejbName: " + ejbName);
- }
-
- public void destroy() throws Exception
- {
encFactory.cleanupEnc(this);
// TODO: clean up BeanContainer?
@@ -991,6 +1001,9 @@
*/
// Restore to pre- create() state
// this.allowInvocations();
+
+ // EJBTHREE-1889: make the bean resurrectable
+ resurrectMetaData = true;
}
@SuppressWarnings("unchecked")
Modified: projects/ejb3/trunk/proxy-impl/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- projects/ejb3/trunk/proxy-impl/.settings/org.maven.ide.eclipse.prefs 2009-11-09 13:45:29 UTC (rev 96169)
+++ projects/ejb3/trunk/proxy-impl/.settings/org.maven.ide.eclipse.prefs 2009-11-09 13:49:05 UTC (rev 96170)
@@ -1,9 +1,11 @@
-#Tue May 13 09:03:29 CEST 2008
-activeProfiles=
+#Fri Nov 06 10:34:20 CET 2009
+activeProfiles=eclipse
eclipse.preferences.version=1
filterResources=false
+fullBuildGoals=process-test-resources
includeModules=false
resolveWorkspaceProjects=true
resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
useMavenFolders=false
version=1
Modified: projects/ejb3/trunk/proxy-impl/pom.xml
===================================================================
--- projects/ejb3/trunk/proxy-impl/pom.xml 2009-11-09 13:45:29 UTC (rev 96169)
+++ projects/ejb3/trunk/proxy-impl/pom.xml 2009-11-09 13:49:05 UTC (rev 96170)
@@ -7,7 +7,7 @@
<parent>
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-build</artifactId>
- <version>1.0.4</version>
+ <version>1.0.6</version>
</parent>
<!-- Model Version -->
@@ -69,6 +69,17 @@
</build>
+ <dependencyManagement>
+ <dependencies>
+ <!-- java.lang.NoSuchFieldError: m_map -->
+ <dependency>
+ <groupId>org.jboss.remoting</groupId>
+ <artifactId>jboss-remoting</artifactId>
+ <version>2.5.2</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
<!-- Dependencies -->
<dependencies>
Added: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/io/ObjectInputStream.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/io/ObjectInputStream.java (rev 0)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/io/ObjectInputStream.java 2009-11-09 13:49:05 UTC (rev 96170)
@@ -0,0 +1,135 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.impl.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectStreamClass;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+
+/**
+ * An ObjectInputStream that allows a custom class loader.
+ *
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ObjectInputStream extends java.io.ObjectInputStream
+{
+ /** table mapping primitive type names to corresponding class objects */
+ private static final HashMap<String, Class<?>> primClasses = new HashMap<String, Class<?>>(8, 1.0F);
+ static
+ {
+ primClasses.put("boolean", boolean.class);
+ primClasses.put("byte", byte.class);
+ primClasses.put("char", char.class);
+ primClasses.put("short", short.class);
+ primClasses.put("int", int.class);
+ primClasses.put("long", long.class);
+ primClasses.put("float", float.class);
+ primClasses.put("double", double.class);
+ primClasses.put("void", void.class);
+ }
+
+ private ClassLoader classLoader;
+
+ /**
+ * @param in
+ * @throws IOException
+ */
+ public ObjectInputStream(InputStream in, ClassLoader classLoader) throws IOException
+ {
+ super(in);
+
+ assert classLoader != null : "classLoader is null";
+
+ this.classLoader = classLoader;
+ }
+
+ protected ClassLoader getClassLoader()
+ {
+ return classLoader;
+ }
+
+ @Override
+ protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException
+ {
+ String name = desc.getName();
+ try
+ {
+ return Class.forName(name, false, getClassLoader());
+ }
+ catch (ClassNotFoundException ex)
+ {
+ Class<?> cl = primClasses.get(name);
+ if (cl != null)
+ {
+ return cl;
+ }
+ else
+ {
+ throw ex;
+ }
+ }
+ }
+
+ @Override
+ protected Class<?> resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException
+ {
+ ClassLoader latestLoader = getClassLoader();
+ ClassLoader nonPublicLoader = null;
+ boolean hasNonPublicInterface = false;
+
+ // define proxy in class loader of non-public interface(s), if any
+ Class<?>[] classObjs = new Class[interfaces.length];
+ for (int i = 0; i < interfaces.length; i++)
+ {
+ Class<?> cl = Class.forName(interfaces[i], false, latestLoader);
+ if ((cl.getModifiers() & Modifier.PUBLIC) == 0)
+ {
+ if (hasNonPublicInterface)
+ {
+ if (nonPublicLoader != cl.getClassLoader())
+ {
+ throw new IllegalAccessError("conflicting non-public interface class loaders");
+ }
+ }
+ else
+ {
+ nonPublicLoader = cl.getClassLoader();
+ hasNonPublicInterface = true;
+ }
+ }
+ classObjs[i] = cl;
+ }
+ try
+ {
+ return Proxy.getProxyClass(hasNonPublicInterface ? nonPublicLoader : latestLoader, classObjs);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new ClassNotFoundException(null, e);
+ }
+ }
+
+}
Modified: projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/objectfactory/ProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/objectfactory/ProxyObjectFactory.java 2009-11-09 13:45:29 UTC (rev 96169)
+++ projects/ejb3/trunk/proxy-impl/src/main/java/org/jboss/ejb3/proxy/impl/objectfactory/ProxyObjectFactory.java 2009-11-09 13:49:05 UTC (rev 96170)
@@ -21,6 +21,10 @@
*/
package org.jboss.ejb3.proxy.impl.objectfactory;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
@@ -35,7 +39,6 @@
import javax.naming.Context;
import javax.naming.Name;
-import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
import javax.naming.RefAddr;
import javax.naming.Reference;
@@ -48,6 +51,7 @@
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
import org.jboss.ejb3.common.registrar.spi.NotBoundException;
import org.jboss.ejb3.proxy.impl.factory.ProxyFactory;
+import org.jboss.ejb3.proxy.impl.io.ObjectInputStream;
import org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase;
import org.jboss.ejb3.proxy.impl.remoting.IsLocalProxyFactoryInterceptor;
import org.jboss.logging.Logger;
@@ -157,6 +161,16 @@
Object proxy = this.getProxy(proxyFactory, name, refAddrs);
assert proxy != null : "Proxy returned from " + proxyFactory + " was null.";
+ // EJBTHREE-1889: if the lookup has been performed locally on a remote (business)
+ // interface that's defined in the current TCL, then the proxy must implement
+ // that TCL defined interface.
+ if(!isLocal) // a remote view?
+ {
+ // redefine in TCL
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ proxy = redefineObjectInClassLoader(proxy, tcl);
+ }
+
// Return the Proxy
return proxy;
}
@@ -321,6 +335,21 @@
}
+ private Object redefineObjectInClassLoader(Object obj, ClassLoader target) throws ClassNotFoundException, IOException
+ {
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(bout);
+ out.writeObject(obj);
+ out.flush();
+ out.close();
+
+ ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
+ ObjectInputStream in = new ObjectInputStream(bin, target);
+ Object result = in.readObject();
+ in.close();
+ return result;
+ }
+
/**
* If the specified proxy has been defined outside of this naming Context's
* ClassLoader, it must be reconstructed using the TCL so we avoid CCE. This
Modified: projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/ejbthree1517/ReturnStaticValueInterceptor.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/ejbthree1517/ReturnStaticValueInterceptor.java 2009-11-09 13:45:29 UTC (rev 96169)
+++ projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/ejbthree1517/ReturnStaticValueInterceptor.java 2009-11-09 13:49:05 UTC (rev 96170)
@@ -21,6 +21,8 @@
*/
package org.jboss.ejb3.test.proxy.impl.ejbthree1517;
+import java.io.Serializable;
+
import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.logging.Logger;
@@ -34,8 +36,10 @@
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
*/
-public class ReturnStaticValueInterceptor implements Interceptor
+public class ReturnStaticValueInterceptor implements Interceptor, Serializable
{
+ // To be able to cross the wire to a client, the interceptor must be serializable.
+ private static final long serialVersionUID = 1L;
// --------------------------------------------------------------------------------||
// Class Members ------------------------------------------------------------------||
@@ -43,7 +47,7 @@
private static final Logger log = Logger.getLogger(ReturnStaticValueInterceptor.class);
- public static final String RETURN_VALUE = "ALR is better than Carlo.";
+ public static final String RETURN_VALUE = "ALR is better than Carlo, if only he had tried his interceptor really remotely. :-)";
// --------------------------------------------------------------------------------||
// Required Implementations -------------------------------------------------------||
Added: projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/ejbthree1889/RedefiningClassLoader.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/ejbthree1889/RedefiningClassLoader.java (rev 0)
+++ projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/ejbthree1889/RedefiningClassLoader.java 2009-11-09 13:49:05 UTC (rev 96170)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.impl.ejbthree1889;
+
+import java.net.URLClassLoader;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * A sneaky class loader that takes all the credit for loading a class. :-)
+ *
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class RedefiningClassLoader extends URLClassLoader
+{
+ private URLClassLoader master;
+ private Set<String> classNames = new HashSet<String>();
+
+ public RedefiningClassLoader(URLClassLoader master, Class<?>... classes)
+ {
+ super(master.getURLs(), null);
+
+ this.master = master;
+ for(Class<?> cls : classes)
+ classNames.add(cls.getName());
+ }
+
+ @Override
+ protected Class<?> findClass(String name) throws ClassNotFoundException
+ {
+ if(classNames.contains(name))
+ return super.findClass(name);
+ return master.loadClass(name);
+ }
+
+ @Override
+ protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
+ {
+ // First, check if the class has already been loaded
+ Class<?> c = findLoadedClass(name);
+ if (c == null)
+ {
+ if(classNames.contains(name))
+ c = findClass(name);
+ else
+ return super.loadClass(name, resolve);
+ }
+ if (resolve)
+ {
+ resolveClass(c);
+ }
+ return c;
+ }
+}
Added: projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/ejbthree1889/unit/RemoteServiceTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/ejbthree1889/unit/RemoteServiceTestCase.java (rev 0)
+++ projects/ejb3/trunk/proxy-impl/src/test/java/org/jboss/ejb3/test/proxy/impl/ejbthree1889/unit/RemoteServiceTestCase.java 2009-11-09 13:49:05 UTC (rev 96170)
@@ -0,0 +1,136 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.impl.ejbthree1889.unit;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Method;
+import java.net.URLClassLoader;
+import java.util.UUID;
+
+import javax.naming.InitialContext;
+
+import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.test.proxy.impl.common.SessionTestCaseBase;
+import org.jboss.ejb3.test.proxy.impl.common.Utils;
+import org.jboss.ejb3.test.proxy.impl.common.container.ServiceContainer;
+import org.jboss.ejb3.test.proxy.impl.common.ejb.service.MyService;
+import org.jboss.ejb3.test.proxy.impl.common.ejb.service.MyServiceBean;
+import org.jboss.ejb3.test.proxy.impl.common.ejb.service.MyServiceRemoteBusiness;
+import org.jboss.ejb3.test.proxy.impl.ejbthree1889.RedefiningClassLoader;
+import org.jboss.util.LRUCachePolicy;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import sun.corba.Bridge;
+
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class RemoteServiceTestCase extends SessionTestCaseBase
+{
+ @AfterClass
+ public static void afterClass()
+ {
+ if(bootstrap != null)
+ bootstrap.shutdown();
+ bootstrap = null;
+ }
+
+ @BeforeClass
+ public static void beforeClass() throws Throwable
+ {
+ System.err.println(LRUCachePolicy.class.getProtectionDomain().getCodeSource());
+
+ setUpBeforeClass();
+
+ bootstrap.deploy(SessionTestCaseBase.class);
+
+ URLClassLoader master = (URLClassLoader) Thread.currentThread().getContextClassLoader();
+ ClassLoader cl = new RedefiningClassLoader(master, MyServiceBean.class, MyService.class, MyServiceRemoteBusiness.class);
+ Thread.currentThread().setContextClassLoader(cl);
+ try
+ {
+ Class<?> beanClass = cl.loadClass(MyServiceBean.class.getName());
+
+ ServiceContainer container = Utils.createService(beanClass);
+
+ Ejb3RegistrarLocator.locateRegistrar().bind(container.getName(), container);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(master);
+ }
+ }
+
+ @Test
+ public void test1() throws Exception
+ {
+ InitialContext ctx = new InitialContext();
+ System.err.println(" " + MyServiceRemoteBusiness.class.getClassLoader());
+ //MyServiceRemoteBusiness bean = (MyServiceRemoteBusiness) ctx.lookup("MyServiceBean/remote");
+ Object obj = ctx.lookup("MyServiceBean/remote");
+ System.err.println(" latestUserDefinedLoader = " + Bridge.get().getLatestUserDefinedLoader());
+ System.err.println(" " + obj.getClass().getInterfaces()[0].getClassLoader());
+ MyServiceRemoteBusiness bean = (MyServiceRemoteBusiness) obj;
+ UUID uuid = bean.getUuid();
+ assertNotNull(uuid);
+ }
+
+ @Test
+ public void testDifferentClassLoader() throws Exception
+ {
+ URLClassLoader master = (URLClassLoader) Thread.currentThread().getContextClassLoader();
+ ClassLoader cl = new RedefiningClassLoader(master, MyServiceRemoteBusiness.class, MyService.class, RemoteServiceTestCase.class);
+ Thread.currentThread().setContextClassLoader(cl);
+ try
+ {
+ System.err.println("X latestUserDefinedLoader = " + Bridge.get().getLatestUserDefinedLoader());
+ // setup a proper call stack class loader
+ Class<?> testClass = cl.loadClass(RemoteServiceTestCase.class.getName());
+ assertEquals(cl, testClass.getClassLoader());
+ Method testMethod = testClass.getMethod("test1");
+ Object obj = testClass.newInstance();
+ testMethod.invoke(obj);
+
+ Class<?> intf = cl.loadClass(MyServiceRemoteBusiness.class.getName());
+ InitialContext ctx = new InitialContext();
+ Method method = intf.getMethod("getUuid");
+ System.err.println(method.getDeclaringClass().getClassLoader());
+ Object bean = ctx.lookup("MyServiceBean/remote");
+ System.err.println(bean.getClass().getInterfaces()[0].getClassLoader());
+ //assertTrue(bean.getClass().isAssignableFrom(intf));
+ assertTrue(intf.isAssignableFrom(bean.getClass()));
+ UUID uuid = (UUID) method.invoke(bean);
+ assertNotNull(uuid);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(master);
+ }
+ }
+}
Modified: projects/ejb3/trunk/testsuite/build-test.xml
===================================================================
--- projects/ejb3/trunk/testsuite/build-test.xml 2009-11-09 13:45:29 UTC (rev 96169)
+++ projects/ejb3/trunk/testsuite/build-test.xml 2009-11-09 13:49:05 UTC (rev 96170)
@@ -2451,6 +2451,25 @@
<build-simple-jar name="ejbthree1852"/>
</target>
+ <target name="ejbthree1889">
+ <mkdir dir="${build.lib}"/>
+
+ <jar jarfile="${build.lib}/ejbthree1889a.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/ejb3/test/ejbthree1889/a/*.class"/>
+ </fileset>
+ <fileset dir="${resources}/test/ejbthree1889/a"/>
+ </jar>
+
+ <jar jarfile="${build.lib}/ejbthree1889b.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/ejb3/test/ejbthree1889/a/EJBTestARemote.class"/>
+ <include name="org/jboss/ejb3/test/ejbthree1889/b/*.class"/>
+ </fileset>
+ <fileset dir="${resources}/test/ejbthree1889/b"/>
+ </jar>
+ </target>
+
<target name="jbas4489"
description="Builds a simple jar files."
>
@@ -4244,6 +4263,7 @@
ejbthree1146, ejbthree1148, ejbthree1154, ejbthree1157, ejbthree1222, ejbthree1271, ejbthree1339,
ejbthree1504, ejbthree1530, ejbthree1624, ejbthree1647,ejbthree1738,
ejbthree1852,
+ ejbthree1889,
jaxws, jbas4489, epcpropagation, aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency,
securitydomain, enventry, security5,
jms/managed, naming, bmt, jca/inflowmdb, pool, jms, security, reference21_30, factory, dd/web, txexceptions,
@@ -5078,6 +5098,9 @@
<param name="test" value="ejbthree1852"/>
</antcall>
<antcall target="test" inheritRefs="true">
+ <param name="test" value="ejbthree1889"/>
+ </antcall>
+ <antcall target="test" inheritRefs="true">
<param name="test" value="statelesscreation"/>
</antcall>
<antcall target="test" inheritRefs="true">
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/a/EJBTestARemote.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/a/EJBTestARemote.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/a/EJBTestARemote.java 2009-11-09 13:49:05 UTC (rev 96170)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejbthree1889.a;
+
+import javax.ejb.Remote;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Remote
+public interface EJBTestARemote
+{
+ String sayHello();
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/a/EJBTestAService.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/a/EJBTestAService.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/a/EJBTestAService.java 2009-11-09 13:49:05 UTC (rev 96170)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejbthree1889.a;
+
+import org.jboss.ejb3.annotation.Service;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Service(objectName="ejbthree1889:service=EJBTestA")
+public class EJBTestAService implements EJBTestARemote
+{
+ private static final Logger log = Logger.getLogger(EJBTestAService.class);
+
+ public String sayHello()
+ {
+ return "Hello from A";
+ }
+
+ public void start()
+ {
+ log.info("EJBTestA starting...");
+ }
+
+ public void stop()
+ {
+ log.info("EJBTestA stopping...");
+ }
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/b/EJBTestBRemote.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/b/EJBTestBRemote.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/b/EJBTestBRemote.java 2009-11-09 13:49:05 UTC (rev 96170)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejbthree1889.b;
+
+import javax.ejb.Remote;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Remote
+public interface EJBTestBRemote
+{
+ String sayHello();
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/b/EJBTestBService.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/b/EJBTestBService.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/b/EJBTestBService.java 2009-11-09 13:49:05 UTC (rev 96170)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejbthree1889.b;
+
+import javax.ejb.EJB;
+
+import org.jboss.ejb3.annotation.Service;
+import org.jboss.ejb3.test.ejbthree1889.a.EJBTestARemote;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Service(objectName="ejbthree1889:service=EJBTestB")
+public class EJBTestBService implements EJBTestBRemote
+{
+ private static final Logger log = Logger.getLogger(EJBTestBService.class);
+
+ // since we're injecting something outside of our scope we need to specify mappedName
+ @EJB(mappedName="EJBTestAService/remote")
+ private EJBTestARemote testA;
+
+ public String sayHello()
+ {
+ return testA.sayHello();
+ }
+
+ public void start()
+ {
+ log.info("EJBTestB starting...");
+ }
+
+ public void stop()
+ {
+ log.info("EJBTestB stopping...");
+ }
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/unit/RedeployServiceTestCase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/unit/RedeployServiceTestCase.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1889/unit/RedeployServiceTestCase.java 2009-11-09 13:49:05 UTC (rev 96170)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejbthree1889.unit;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.common.EJB3TestCase;
+import org.jboss.ejb3.test.ejbthree1889.b.EJBTestBRemote;
+
+/**
+ * When a service is redeployed its consumers should be restarted and keep on functioning.
+ *
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class RedeployServiceTestCase extends EJB3TestCase
+{
+ public RedeployServiceTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(RedeployServiceTestCase.class, "ejbthree1889a.jar,ejbthree1889b.jar");
+ }
+
+ public void testRedeployA() throws Exception
+ {
+ // all is deployed, so all should be well
+ EJBTestBRemote testB = lookup("EJBTestBService/remote", EJBTestBRemote.class);
+
+ String result = testB.sayHello();
+
+ assertEquals("Hello from A", result);
+
+ redeploy("ejbthree1889a.jar");
+
+ result = testB.sayHello();
+
+ assertEquals("Hello from A", result);
+ }
+}
Added: projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1889/a/META-INF/jboss.xml
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1889/a/META-INF/jboss.xml (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1889/a/META-INF/jboss.xml 2009-11-09 13:49:05 UTC (rev 96170)
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<jboss
+ xmlns="http://www.jboss.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee
+ http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
+ version="3.0">
+ <loader-repository>
+ jboss.ejb3.test:test=ejbthree1889a
+ <loader-repository-config>
+ java2ParentDelegaton=false
+ </loader-repository-config>
+ </loader-repository>
+</jboss>
Added: projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1889/b/META-INF/jboss.xml
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1889/b/META-INF/jboss.xml (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1889/b/META-INF/jboss.xml 2009-11-09 13:49:05 UTC (rev 96170)
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<jboss
+ xmlns="http://www.jboss.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee
+ http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
+ version="3.0">
+ <loader-repository>
+ jboss.ejb3.test:test=ejbthree1889b
+ <loader-repository-config>
+ java2ParentDelegaton=false
+ </loader-repository-config>
+ </loader-repository>
+</jboss>
More information about the jboss-cvs-commits
mailing list