[jboss-cvs] JBossAS SVN: r82773 - in projects/ejb3/trunk: testsuite and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jan 12 10:17:47 EST 2009


Author: jaikiran
Date: 2009-01-12 10:17:47 -0500 (Mon, 12 Jan 2009)
New Revision: 82773

Added:
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/StatelessOne.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/StatelessOneImpl.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/StatelessTwo.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/StatelessTwoImpl.java
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/unit/
   projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/unit/ResourceHandlerTestCase.java
   projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1671/
   projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1671/META-INF/
   projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1671/META-INF/application.xml
   projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1671/META-INF/jboss-app.xml
Modified:
   projects/ejb3/trunk/core/src/main/java/org/jboss/injection/ResourceHandler.java
   projects/ejb3/trunk/testsuite/build-test.xml
Log:
EJBTHREE-1671 ResourceHandler was using an incorrect classloader to inject a @Resource. Fixed it to use the classloader of the container

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/injection/ResourceHandler.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/injection/ResourceHandler.java	2009-01-12 14:49:33 UTC (rev 82772)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/injection/ResourceHandler.java	2009-01-12 15:17:47 UTC (rev 82773)
@@ -203,7 +203,8 @@
          {
             if(resTypeName != null)
             {
-               Class<?> resType = Class.forName(resTypeName);
+               // EJBTHREE-1671 : The resType class should be loaded through the container's classloader
+               Class<?> resType = Class.forName(resTypeName,false,container.getClassloader());
                if(EJBContext.class.isAssignableFrom(resType))
                {
                   InjectorFactory<?> factory = new InjectorFactory<EJBContextPropertyInjector>()

Modified: projects/ejb3/trunk/testsuite/build-test.xml
===================================================================
--- projects/ejb3/trunk/testsuite/build-test.xml	2009-01-12 14:49:33 UTC (rev 82772)
+++ projects/ejb3/trunk/testsuite/build-test.xml	2009-01-12 15:17:47 UTC (rev 82773)
@@ -270,6 +270,11 @@
       <jvmarg value="-Djgroups.udp.ip_ttl=${jbosstest.udp.ip_ttl}" />
       <jvmarg value="-Djboss.messaging.ServerPeerID=1" />
    </server>
+  	
+    <!-- ejbthree1671 -->
+    <server name="ejbthree1671" host="${node0}">
+      <jvmarg value="${ejb3.jboss.jvmargs}" />
+    </server>
 
   </server:config>
 
@@ -4184,6 +4189,31 @@
          </fileset>
       </jar>
    </target>
+	
+	
+	<target name="ejbthree1671"
+	      description="Builds the ear and jar file(s) needed for testing EJBTHREE-1671."
+	      >
+
+	    <mkdir dir="${build.lib}"/>
+		<!--  First build the jar file containing the EJBs -->
+		<jar jarfile="${build.lib}/ejbthree1671.jar">
+	         <fileset dir="${build.classes}">
+	            <include name="org/jboss/ejb3/test/ejbthree1671/*.class"/>
+	         </fileset>
+		</jar>
+		<!--  Now build the EAR and include the EJB jar and the application.xml and jboss-app.xml -->
+		<jar jarfile="${build.lib}/ejbthree1671.ear">
+         	<fileset dir="${build.lib}">
+            	<include name="ejbthree1671.jar"/>
+         	</fileset>
+         	<fileset dir="${resources}/test/ejbthree1671">
+            	<include name="META-INF/application.xml"/>
+            	<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,
@@ -4212,7 +4242,7 @@
       timer, benchmark, entity, joininheritance, singletable, tableperclass, dependent, mdb, manytomany, regression,
       composite, composite2, entitycallback, relationships, ssl, ssladvanced, clusteredsession, strictpool, jacc,
       localcall, interceptors, interceptors2, interceptors3, iiop, clientinterceptor,
-      statelesscreation, changexml, externalrefscoped, singleton"/>
+      statelesscreation, changexml, externalrefscoped, singleton, ejbthree1671"/>
 
    <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/ejbthree1671/StatelessOne.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/StatelessOne.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/StatelessOne.java	2009-01-12 15:17:47 UTC (rev 82773)
@@ -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.ejbthree1671;
+
+/**
+ * StatelessOne
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface StatelessOne
+{
+   void doNothing();
+}

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/StatelessOneImpl.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/StatelessOneImpl.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/StatelessOneImpl.java	2009-01-12 15:17:47 UTC (rev 82773)
@@ -0,0 +1,80 @@
+/*
+ * 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.ejbthree1671;
+
+
+import javax.annotation.Resource;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.sql.DataSource;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.logging.Logger;
+
+/**
+ * StatelessOneImpl
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Stateless
+ at Remote (StatelessOne.class)
+ at RemoteBinding(jndiBinding=StatelessOneImpl.JNDI_NAME)
+public class StatelessOneImpl implements StatelessOne
+{
+   /**
+    * Logger
+    */
+   private static Logger logger = Logger.getLogger(StatelessOneImpl.class);
+   
+   /**
+    * Exposing this through the bean implementation, exposes the
+    * impl to the client. But we are just doing some tests, so 
+    * doesn't matter
+    * 
+    * JNDI Name
+    */
+   public static final String JNDI_NAME = "Anything";
+   
+   // Inject application specific type @Resource
+   @Resource (mappedName=StatelessTwoImpl.JNDI_NAME)
+   private StatelessTwo statelessTwo;
+   
+   // Ideally, we should have created and deployed our own datasource for this testcase
+   // to avoid depending on DefaultDS. But because of deployment ordering issues 
+   // (datasource gets deployed after EJB, when datasource is packaged and deployed through
+   // jboss-app.xml), let's just rely on the DefaultDS, which we assume will be available
+   @Resource (mappedName="java:/DefaultDS")
+   private DataSource dataSource;
+   
+   /**
+    * @see StatelessOne#doNothing()
+    */
+   public void doNothing()
+   {
+      // let's atleast do something, now that we are here ;)
+      statelessTwo.add(2, 3);
+      logger.info("Datasource has been injected, class = " + dataSource.getClass());
+      
+   }
+
+}

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/StatelessTwo.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/StatelessTwo.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/StatelessTwo.java	2009-01-12 15:17:47 UTC (rev 82773)
@@ -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.ejbthree1671;
+
+/**
+ * StatelessTwo
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public interface StatelessTwo
+{
+   int add(int a, int b);
+}

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/StatelessTwoImpl.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/StatelessTwoImpl.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/StatelessTwoImpl.java	2009-01-12 15:17:47 UTC (rev 82773)
@@ -0,0 +1,58 @@
+/*
+ * 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.ejbthree1671;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+
+/**
+ * StatelessTwoImpl
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Stateless
+ at Remote(StatelessTwo.class)
+ at RemoteBinding(jndiBinding = StatelessTwoImpl.JNDI_NAME)
+public class StatelessTwoImpl implements StatelessTwo
+{
+
+   /**
+    * Exposing this through the bean implementation, exposes the
+    * impl to the client. But we are just doing some tests, so 
+    * doesn't matter
+    * 
+    * JNDI Name
+    */
+   public static final String JNDI_NAME = "DoesNotMatter";
+
+   /**
+    * @see StatelessTwo#add(int, int)
+    */
+   public int add(int a, int b)
+   {
+      return a + b;
+   }
+
+}

Added: projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/unit/ResourceHandlerTestCase.java
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/unit/ResourceHandlerTestCase.java	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/java/org/jboss/ejb3/test/ejbthree1671/unit/ResourceHandlerTestCase.java	2009-01-12 15:17:47 UTC (rev 82773)
@@ -0,0 +1,88 @@
+/*
+ * 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.ejbthree1671.unit;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.ejbthree1671.StatelessOne;
+import org.jboss.ejb3.test.ejbthree1671.StatelessOneImpl;
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * ResourceHandlerTestCase
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class ResourceHandlerTestCase extends JBossTestCase
+{
+
+   /**
+    * Logger
+    */
+   private static Logger logger = Logger.getLogger(ResourceHandlerTestCase.class);
+
+   /**
+    * Constructor
+    * @param name
+    */
+   public ResourceHandlerTestCase(String name)
+   {
+      super(name);
+
+   }
+
+   /**
+    * 
+    * @return
+    * @throws Exception
+    */
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(ResourceHandlerTestCase.class, "ejbthree1671.ear");
+   }
+
+   /**
+    * A lookup and bean method invocation should be enough to
+    * ensure that the bean was deployed successfully
+    * 
+    * @throws Throwable
+    */
+   public void testResourceInjectionOfApplicationSpecificType() throws Throwable
+   {
+      Context ctx = new InitialContext();
+      logger.debug("Looking up the bean with jndi-name " + StatelessOneImpl.JNDI_NAME);
+
+      StatelessOne statelessOne = (StatelessOne) ctx.lookup(StatelessOneImpl.JNDI_NAME);
+      logger
+            .info("Bean successfully returned from JNDI, which effectively means the application was successfully deployed");
+
+      logger.debug("Now invoking a method on the returned bean");
+      statelessOne.doNothing();
+      logger.info("Successfully invoked a method on the bean");
+   }
+
+}

Added: projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1671/META-INF/application.xml
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1671/META-INF/application.xml	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1671/META-INF/application.xml	2009-01-12 15:17:47 UTC (rev 82773)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<application>
+   <display-name>EJBTHREE-1671 Resource injection of application specific type</display-name>
+   <module>
+      <ejb>ejbthree1671.jar</ejb>
+   </module>
+</application>

Added: projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1671/META-INF/jboss-app.xml
===================================================================
--- projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1671/META-INF/jboss-app.xml	                        (rev 0)
+++ projects/ejb3/trunk/testsuite/src/test/resources/test/ejbthree1671/META-INF/jboss-app.xml	2009-01-12 15:17:47 UTC (rev 82773)
@@ -0,0 +1,10 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<jboss-app>
+   <loader-repository>
+      jboss.ejb3.test:classloader=EJBTHREE-1671-classloader
+      <loader-repository-config>
+         java2ParentDelegation=false
+      </loader-repository-config>
+   </loader-repository>
+   
+</jboss-app>




More information about the jboss-cvs-commits mailing list