[jboss-cvs] JBossAS SVN: r94177 - in projects/ejb3/trunk: core/src/main/java/org/jboss/ejb3/interceptor and 10 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Sep 30 15:02:31 EDT 2009
Author: jaikiran
Date: 2009-09-30 15:02:30 -0400 (Wed, 30 Sep 2009)
New Revision: 94177
Added:
projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/interceptor/EJB3TCCLInterceptor.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/QuartzIntegratedMDB.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/ResultTracker.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/SimpleSLSBean.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/StatelessRemote.java
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/unit/
projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/unit/EJBInvocationClassLoaderTestCase.java
projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1876/
projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1876/META-INF/
projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1876/META-INF/jboss-app.xml
Modified:
projects/ejb3/trunk/as-int/pom.xml
projects/ejb3/trunk/core/src/main/resources/ejb3-interceptors-aop.xml
projects/ejb3/trunk/ejb3/pom.xml
projects/ejb3/trunk/plugin/pom.xml
projects/ejb3/trunk/testsuite/build-test.xml
Log:
EJBTHREE-1876 Set the TCCL to EJBContainer's classloader during an EJB invocation
Modified: projects/ejb3/trunk/as-int/pom.xml
===================================================================
--- projects/ejb3/trunk/as-int/pom.xml 2009-09-30 18:42:38 UTC (rev 94176)
+++ projects/ejb3/trunk/as-int/pom.xml 2009-09-30 19:02:30 UTC (rev 94177)
@@ -29,7 +29,7 @@
into the AS
-->
- <version.org.jboss.ejb3_jboss.ejb3>1.1.18</version.org.jboss.ejb3_jboss.ejb3>
+ <version.org.jboss.ejb3_jboss.ejb3>1.1.19-SNAPSHOT</version.org.jboss.ejb3_jboss.ejb3>
<version.org.jboss.ejb3_jboss.ejb3.metrics.deployer>1.0.1</version.org.jboss.ejb3_jboss.ejb3.metrics.deployer>
<version.org.jboss.ejb3_mc.int>1.0.1</version.org.jboss.ejb3_mc.int>
Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/interceptor/EJB3TCCLInterceptor.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/interceptor/EJB3TCCLInterceptor.java (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/interceptor/EJB3TCCLInterceptor.java 2009-09-30 19:02:30 UTC (rev 94177)
@@ -0,0 +1,95 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.interceptor;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.EJBContainerInvocation;
+
+/**
+ * EJB3TCCLInterceptor
+ *
+ * {@link Interceptor} responsible for setting the correct Thread context classloader (TCCL)
+ * during the EJB invocation. The {@link EJBContainer}'s classloader is set as the
+ * TCCL for the duration of this invocation. The TCCL is then reset to the original
+ * classloader.
+ *
+ * Note: The TCCL switch happens from the point when this interceptor is invoked. So
+ * ideally, this interceptor should be the first in the chain of the AOP interceptors
+ * during the EJB invocation
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+// TODO : This interceptor can be moved out of "core", but that isn't too
+// straightforward right now because the container's classloader can
+// only be obtained from EJBContainer and would effectively mean a dependency on
+// ejb3-core. There's a way to avoid this by introducing a new interface which exposes
+// the container's classloader and this interface is then implemented by the EJBContainer.
+// The other component can then rely on this new interface to get hold of the classloader.
+// But overall, that approach isn't straightforward at this point and probably not worth the
+// efforts.
+public class EJB3TCCLInterceptor implements Interceptor
+{
+
+ /**
+ * Returns the name of the interceptor
+ * @see Interceptor#getName()
+ */
+ public String getName()
+ {
+ return this.getClass().getName();
+ }
+
+ /**
+ * Sets the TCCL to the classloader of the container so
+ * that the invocation happens in the context of the
+ * container's classloader. Finally upon return resets
+ * the TCCL to the previous classloader.
+ */
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ assert invocation instanceof EJBContainerInvocation : "Unexpected invocation type " + invocation.getClass()
+ + " - expected " + EJBContainerInvocation.class;
+
+ // get hold of the EJBContainer from the invocation
+ EJBContainer ejbContainer = EJBContainer.getEJBContainer(invocation.getAdvisor());
+
+ ClassLoader ejbContainerClassloader = ejbContainer.getClassloader();
+ ClassLoader previousClassLoader = Thread.currentThread().getContextClassLoader();
+ // TODO: Review for security manager privileged blocks
+ try
+ {
+ // Set the TCCL to the EJBContainer's classloader
+ Thread.currentThread().setContextClassLoader(ejbContainerClassloader);
+ // move on
+ return invocation.invokeNext();
+ }
+ finally
+ {
+ // reset to original TCCL
+ Thread.currentThread().setContextClassLoader(previousClassLoader);
+ }
+ }
+
+}
Modified: projects/ejb3/trunk/core/src/main/resources/ejb3-interceptors-aop.xml
===================================================================
--- projects/ejb3/trunk/core/src/main/resources/ejb3-interceptors-aop.xml 2009-09-30 18:42:38 UTC (rev 94176)
+++ projects/ejb3/trunk/core/src/main/resources/ejb3-interceptors-aop.xml 2009-09-30 19:02:30 UTC (rev 94177)
@@ -69,7 +69,7 @@
<interceptor class="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor" scope="PER_VM"/>
<interceptor class="org.jboss.ejb3.BlockContainerShutdownInterceptor" scope="PER_VM"/>
<interceptor factory="org.jboss.ejb3.connectionmanager.CachedConnectionInterceptorFactory" scope="PER_CLASS"/>
-
+ <interceptor class="org.jboss.ejb3.interceptor.EJB3TCCLInterceptor" scope="PER_VM"/>
<!--
INTERCEPTORS
-->
@@ -129,6 +129,7 @@
</stack>
<bind pointcut="execution(public * *->*(..))">
+ <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3TCCLInterceptor"/>
<interceptor-ref name="org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor"/>
<interceptor-ref name="org.jboss.ejb3.BlockContainerShutdownInterceptor"/>
</bind>
Modified: projects/ejb3/trunk/ejb3/pom.xml
===================================================================
--- projects/ejb3/trunk/ejb3/pom.xml 2009-09-30 18:42:38 UTC (rev 94176)
+++ projects/ejb3/trunk/ejb3/pom.xml 2009-09-30 19:02:30 UTC (rev 94177)
@@ -35,7 +35,7 @@
into the AS
-->
- <version.org.jboss.ejb3_core>1.1.18</version.org.jboss.ejb3_core>
+ <version.org.jboss.ejb3_core>1.1.19-SNAPSHOT</version.org.jboss.ejb3_core>
<version.org.jboss.ejb3_deployers>1.0.0</version.org.jboss.ejb3_deployers>
</properties>
Modified: projects/ejb3/trunk/plugin/pom.xml
===================================================================
--- projects/ejb3/trunk/plugin/pom.xml 2009-09-30 18:42:38 UTC (rev 94176)
+++ projects/ejb3/trunk/plugin/pom.xml 2009-09-30 19:02:30 UTC (rev 94177)
@@ -63,7 +63,7 @@
<dependency>
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-as-int</artifactId>
- <version>1.1.18</version>
+ <version>1.1.19-SNAPSHOT</version>
<optional>true</optional>
</dependency>
@@ -79,7 +79,7 @@
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-core</artifactId>
<classifier>client</classifier>
- <version>1.1.18</version>
+ <version>1.1.19-SNAPSHOT</version>
<optional>true</optional>
</dependency>
Modified: projects/ejb3/trunk/testsuite/build-test.xml
===================================================================
--- projects/ejb3/trunk/testsuite/build-test.xml 2009-09-30 18:42:38 UTC (rev 94176)
+++ projects/ejb3/trunk/testsuite/build-test.xml 2009-09-30 19:02:30 UTC (rev 94177)
@@ -4351,6 +4351,29 @@
</jar>
</target>
+ <target name="ejbthree1876"
+ description="Builds the ear and jar file(s) needed for testing EJBTHREE-1876."
+ >
+
+ <mkdir dir="${build.lib}"/>
+ <!-- First build the jar file containing the EJBs -->
+ <jar jarfile="${build.lib}/ejbthree1876.jar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/ejb3/test/ejbthree1876/*.class"/>
+ </fileset>
+
+ </jar>
+ <!-- Now build the EAR and include the EJB jar and the queue-service.xml -->
+ <jar jarfile="${build.lib}/ejbthree1876.ear">
+ <fileset dir="${build.lib}">
+ <include name="ejbthree1876.jar"/>
+ </fileset>
+ <fileset dir="${resources}/test/ejbthree1876">
+ <include name="META-INF/jboss-app.xml"/>
+ </fileset>
+ </jar>
+ </target>
+
<target name="jars" depends="statefulproxyfactoryoverride, removedislocal, statelesscreation, defaultremotebindings, localfromremote, clusteredjms, entityoptimisticlocking, concurrentnaming, propertyreplacement, persistenceunits, appclient, tck5sec, invalidtxmdb, descriptortypo, libdeployment, homeinterface, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader,
concurrent,
circulardependency, jsp, timerdependency, servicedependency, stateless14, webservices, ear, ejbthree440,
@@ -4381,7 +4404,7 @@
composite, composite2, entitycallback, relationships, ssl, ssladvanced, clusteredsession, strictpool, jacc,
localcall, interceptors, interceptors2, interceptors3, iiop, clientinterceptor,
statelesscreation, changexml, externalrefscoped, singleton, ejbthree1671, ejbthree1677, ejbthree1629,
- ejbthree1807, ejbthree1346, ejbthree1823, ejbthree1858"/>
+ ejbthree1807, ejbthree1346, ejbthree1823, ejbthree1858, ejbthree1876"/>
<target name="test" depends="init" if="test"
description="Execute all tests in the given test directory.">
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/QuartzIntegratedMDB.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/QuartzIntegratedMDB.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/QuartzIntegratedMDB.java 2009-09-30 19:02:30 UTC (rev 94177)
@@ -0,0 +1,82 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.ejbthree1876;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.EJB;
+import javax.ejb.MessageDriven;
+
+import org.jboss.ejb3.annotation.ResourceAdapter;
+import org.jboss.ejb3.test.ejbthree1876.unit.EJBInvocationClassLoaderTestCase;
+import org.jboss.logging.Logger;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+/**
+ * QuartzIntegratedMDB
+ *
+ * MDB used in test case for EJBTHREE-1876 {@link EJBInvocationClassLoaderTestCase}
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at MessageDriven(activationConfig =
+{@ActivationConfigProperty(propertyName = "cronTrigger", propertyValue = "*/2 * * * * ?")})
+ at ResourceAdapter("quartz-ra.rar")
+public class QuartzIntegratedMDB implements Job
+{
+
+ /**
+ * Logger
+ */
+ private static Logger logger = Logger.getLogger(QuartzIntegratedMDB.class);
+
+ /**
+ * Bean
+ */
+ @EJB
+ private StatelessRemote bean;
+
+ /**
+ * Uses the injected bean to invoke an method on it
+ */
+ public void execute(JobExecutionContext jobContext) throws JobExecutionException
+ {
+ logger.info("Job " + jobContext + " at " + System.currentTimeMillis());
+ try
+ {
+ // just call the bean
+ bean.doNothing();
+ logger.debug("Bean successfully invoked in MDB");
+ // worked fine, so set a state in a singleton
+ ResultTracker.getInstance().setPassed();
+ }
+ catch (Exception e)
+ {
+ logger.error("Exception in MDB: ", e);
+ ResultTracker.getInstance().setException(e);
+ }
+
+ }
+
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/ResultTracker.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/ResultTracker.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/ResultTracker.java 2009-09-30 19:02:30 UTC (rev 94177)
@@ -0,0 +1,83 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.ejbthree1876;
+
+/**
+ * ResultTracker
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class ResultTracker
+{
+ public static enum Result
+ {
+ SUCCESS, FAILURE;
+ }
+
+ private Result result = Result.FAILURE;
+
+ private static ResultTracker instance;
+
+ private Exception failureCause;
+
+ public static synchronized ResultTracker getInstance()
+ {
+ if (instance == null)
+ {
+ instance = new ResultTracker();
+ }
+ return instance;
+ }
+
+ private ResultTracker()
+ {
+
+ }
+
+ public Result getResult()
+ {
+ return this.result;
+ }
+
+ public void setFailed()
+ {
+ this.result = Result.FAILURE;
+ }
+
+ public void setPassed()
+ {
+ this.result = Result.SUCCESS;
+ this.failureCause = null;
+ }
+
+ public void setException(Exception e)
+ {
+ this.result = Result.FAILURE;
+ this.failureCause = e;
+ }
+
+ public Exception getFailureCause()
+ {
+ return this.failureCause;
+ }
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/SimpleSLSBean.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/SimpleSLSBean.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/SimpleSLSBean.java 2009-09-30 19:02:30 UTC (rev 94177)
@@ -0,0 +1,83 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.ejbthree1876;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.test.ejbthree1876.ResultTracker.Result;
+
+/**
+ * SimpleSLSBean
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Stateless
+ at Remote(StatelessRemote.class)
+ at RemoteBinding(jndiBinding = SimpleSLSBean.JNDI_NAME)
+public class SimpleSLSBean implements StatelessRemote
+{
+
+ public static final String JNDI_NAME = "SimpleBean";
+
+ public void doNothing()
+ {
+ // As suggested by the method name, do nothing!
+
+ }
+
+ public void setException(Exception e)
+ {
+ // just delegate to the singleton result tracker
+ ResultTracker.getInstance().setException(e);
+
+ }
+
+ public void setFailed()
+ {
+ // just delegate to the singleton result tracker
+ ResultTracker.getInstance().setFailed();
+
+ }
+
+ public void setPassed()
+ {
+ // just delegate to the singleton result tracker
+ ResultTracker.getInstance().setPassed();
+
+ }
+
+ public Result getResult()
+ {
+ // just delegate to the singleton result tracker
+ return ResultTracker.getInstance().getResult();
+ }
+
+ public Exception getFailureCause()
+ {
+ // just delegate to the singleton result tracker
+ return ResultTracker.getInstance().getFailureCause();
+ }
+
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/StatelessRemote.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/StatelessRemote.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/StatelessRemote.java 2009-09-30 19:02:30 UTC (rev 94177)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.ejbthree1876;
+
+import org.jboss.ejb3.test.ejbthree1876.ResultTracker.Result;
+
+/**
+ * StatelessLocal
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface StatelessRemote
+{
+
+ void doNothing();
+
+ void setPassed();
+
+ void setFailed();
+
+ void setException(Exception e);
+
+ Result getResult();
+
+ Exception getFailureCause();
+}
Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/unit/EJBInvocationClassLoaderTestCase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/unit/EJBInvocationClassLoaderTestCase.java (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1876/unit/EJBInvocationClassLoaderTestCase.java 2009-09-30 19:02:30 UTC (rev 94177)
@@ -0,0 +1,103 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.ejbthree1876.unit;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.ejbthree1876.ResultTracker;
+import org.jboss.ejb3.test.ejbthree1876.SimpleSLSBean;
+import org.jboss.ejb3.test.ejbthree1876.StatelessRemote;
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * EJBInvocationClassLoaderTestCase
+ *
+ * Test case to test the fix for EJBTHREE-1876 issue (also JBAS-6314)
+ *
+ * The issue involved a Quartz integrated MDB, in a isolated deployment, which when
+ * using a injected bean would throw CNFE for the bean/bean-interfaces.
+ * The real issue was because the Quartz scheduler thread did not have the
+ * correct classloader while working with the EJB containers and other
+ * components. More details here http://www.jboss.org/index.html?module=bb&op=viewtopic&t=159011
+ *
+ *
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class EJBInvocationClassLoaderTestCase extends JBossTestCase
+{
+
+ private static Logger logger = Logger.getLogger(EJBInvocationClassLoaderTestCase.class);
+
+ /**
+ * Constructor
+ * @param name
+ */
+ public EJBInvocationClassLoaderTestCase(String name)
+ {
+ super(name);
+
+ }
+
+ /**
+ *
+ * @return
+ * @throws Exception
+ */
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(EJBInvocationClassLoaderTestCase.class, "ejbthree1876.ear");
+ }
+
+ /**
+ * Ensure that the MDB is able to invoke a method on an injected bean. The MDB
+ * is configured to receive timed invocations from a Quartz scheduler. On each
+ * invocation, the MDB uses an injected SLSB to invoke a method on that bean.
+ * The result (success/failure) is stored on a server side {@link ResultTracker}
+ * which is then accessed through the same SLSB in this testcase.
+ *
+ * @throws Exception
+ */
+ public void testBeanInvocationThroughMDB() throws Exception
+ {
+ // ensure that the deployment went off fine
+ serverFound();
+ logger.debug("Successfully deployed the ejbthree1876.ear");
+
+ // upon deployment, the MDB will be invoked by the quartz scheduler
+ // every 2 seconds. So let's atleast wait for 3 seconds before testing
+ // whether the MDB has been invoked. If the MDB was invoked, it internally
+ // we call a quick SLSB method and then set a state for success/failure.
+ // We just have to check the state here
+ Thread.sleep(3000);
+ Context ctx = new InitialContext();
+ StatelessRemote bean = (StatelessRemote) ctx.lookup(SimpleSLSBean.JNDI_NAME);
+ assertNull("Exception occured while invoking injected bean's method from MDB", bean.getFailureCause());
+ assertEquals("MDB could not invoke the injected bean's method", ResultTracker.Result.SUCCESS, bean.getResult());
+ }
+
+}
Added: projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1876/META-INF/jboss-app.xml
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1876/META-INF/jboss-app.xml (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1876/META-INF/jboss-app.xml 2009-09-30 19:02:30 UTC (rev 94177)
@@ -0,0 +1,10 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!DOCTYPE jboss-app
+ PUBLIC "-//JBoss//DTD J2EE Application 1.3V2//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-app_3_2.dtd">
+
+<jboss-app>
+ <loader-repository>
+ jboss.ejb3.test:loader=ejbthree1876
+ </loader-repository>
+</jboss-app>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list