[jboss-cvs] JBossAS SVN: r103575 - in branches/JBPAPP_4_2_0_GA_CP/ejb3: src/main/org/jboss/ejb3 and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Apr 6 10:22:27 EDT 2010


Author: wolfc
Date: 2010-04-06 10:22:26 -0400 (Tue, 06 Apr 2010)
New Revision: 103575

Added:
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/jbpapp4057/
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/jbpapp4057/META-INF/
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/jbpapp4057/META-INF/application.xml
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/jbpapp4057/META-INF/persistence.xml
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/jbpapp4057/session/
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/jbpapp4057/session/ejb-jar.xml
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/jbpapp4057/
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/jbpapp4057/unit/
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/jbpapp4057/unit/AbsoluteJarFileUnitTestCase.java
Modified:
   branches/JBPAPP_4_2_0_GA_CP/ejb3/build-test.xml
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/JmxDeploymentUnit.java
Log:
JBPAPP-4057: fixed path resolution

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/build-test.xml
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/build-test.xml	2010-04-06 14:03:07 UTC (rev 103574)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/build-test.xml	2010-04-06 14:22:26 UTC (rev 103575)
@@ -2319,6 +2319,24 @@
       <build-simple-jar name="jbpapp2811"/>
    </target>
 
+   <target name="jbpapp4057"
+      description="Builds all jar files."
+      depends="compile-classes,ejbthree724">
+
+      <mkdir dir="${build.lib}"/>
+
+      <jar jarfile="${build.lib}/jbpapp4057-session.jar">
+         <fileset dir="${build.classes}" includes="org/jboss/ejb3/test/ejbthree724/MyStateless*.class"/>
+         <zipfileset dir="${build.resources}/test/jbpapp4057/session" includes="*" prefix="META-INF"/>
+      </jar>
+
+      <jar jarfile="${build.lib}/jbpapp4057.ear">
+         <fileset dir="${build.resources}/test/jbpapp4057" includes="META-INF/*"/>
+         <zipfileset dir="${build.lib}" includes="ejbthree724-persistence.jar" prefix="lib"/>
+         <fileset dir="${build.lib}" includes="jbpapp4057-session.jar"/>
+      </jar>
+   </target>
+
 	<target name="jaxws"
       description="Builds a simple jar."
       depends="compile-classes">
@@ -4136,6 +4154,7 @@
       jbpapp2260,
       jbpapp2290,
       jbpapp2811,
+      jbpapp4057,
       jbas4489, epcpropagation, jaccpropagation, 
       aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency, jaxws,
       pkg, securitydomain, enventry, externalpersistenceunit,
@@ -4834,6 +4853,9 @@
       <antcall target="test" inheritRefs="true">
          <param name="test" value="jbpapp2811"/>
       </antcall>
+      <antcall target="test" inheritRefs="true">
+         <param name="test" value="jbpapp4057"/>
+      </antcall>
 	</target>
 
 	<target name="entity-tests" depends="init" description="Execute all tests">

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/JmxDeploymentUnit.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/JmxDeploymentUnit.java	2010-04-06 14:03:07 UTC (rev 103574)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/JmxDeploymentUnit.java	2010-04-06 14:22:26 UTC (rev 103575)
@@ -85,26 +85,19 @@
       {
          try
          {
-            if (jar.startsWith(".."))
+            if (getUrl() == null)
+               throw new RuntimeException("relative <jar-file> not allowed when standalone deployment unit is used");
+            URL baseURL = getUrl();
+            // a nasty hack to enable loading within an EAR
+            // if it does not appear to be a reference to a directory and we want something inside the jar
+            if(!baseURL.toString().endsWith("/") && !jar.startsWith("../") && baseURL.getProtocol().equals("file"))
             {
-               if (getUrl() == null)
-                  throw new RuntimeException("relative <jar-file> not allowed when standalone deployment unit is used");
-               String base = getUrl().toString();
-               jar = jar.replaceAll("\\.\\./", "+");
-               int idx = jar.lastIndexOf('+');
-               jar = jar.substring(idx + 1);
-               for (int i = 0; i < idx + 1; i++)
-               {
-                  int slash = base.lastIndexOf('/');
-                  base = base.substring(0, slash + 1);
-               }
-               url = new URL(base + jar.substring(idx));
+               baseURL = new URL("jar:" + baseURL.toString() + "!/");
             }
-            else
-            {
-               File fp = new File(jar);
-               url = fp.toURL();
-            }
+            if(jar.startsWith("../") && !Boolean.getBoolean("JBPAPP-4057"))
+               jar = jar.substring(3);
+            log.debug("base = " + getUrl() + ", jar = " + jar);
+            return new URL(baseURL, jar);
          }
          catch (MalformedURLException e1)
          {

Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/jbpapp4057/META-INF/application.xml
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/jbpapp4057/META-INF/application.xml	                        (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/jbpapp4057/META-INF/application.xml	2010-04-06 14:22:26 UTC (rev 103575)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE application PUBLIC
+   "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
+   "http://java.sun.com/dtd/application_1_3.dtd">
+
+<application>
+   <display-name>JBPAPP-4057 Test</display-name>
+
+   <!--
+   <module>
+      <ejb>lib/ejbthree724-persistence.jar</ejb>
+   </module>
+   -->
+   <module>
+      <ejb>ejbthree724-session.jar</ejb>
+   </module>
+</application>

Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/jbpapp4057/META-INF/persistence.xml
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/jbpapp4057/META-INF/persistence.xml	                        (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/jbpapp4057/META-INF/persistence.xml	2010-04-06 14:22:26 UTC (rev 103575)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence>
+   <persistence-unit name="manager1">
+      <jta-data-source>java:/DefaultDS</jta-data-source>
+      <jar-file>./lib/ejbthree724-persistence.jar</jar-file>
+      <properties>
+         <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+      </properties>
+   </persistence-unit>
+</persistence>

Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/jbpapp4057/session/ejb-jar.xml
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/jbpapp4057/session/ejb-jar.xml	                        (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/resources/test/jbpapp4057/session/ejb-jar.xml	2010-04-06 14:22:26 UTC (rev 103575)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+   version="3.0">
+   <enterprise-beans>
+      <session>
+         <ejb-name>MyStatelessBean</ejb-name>
+         <persistence-context-ref>
+            <persistence-context-ref-name>org.jboss.ejb3.test.ejbthree724.MyStatelessBean/em</persistence-context-ref-name>
+            <persistence-unit-name>manager1</persistence-unit-name>
+         </persistence-context-ref>
+      </session>
+   </enterprise-beans>
+</ejb-jar>
\ No newline at end of file

Added: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/jbpapp4057/unit/AbsoluteJarFileUnitTestCase.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/jbpapp4057/unit/AbsoluteJarFileUnitTestCase.java	                        (rev 0)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/test/org/jboss/ejb3/test/jbpapp4057/unit/AbsoluteJarFileUnitTestCase.java	2010-04-06 14:22:26 UTC (rev 103575)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.jbpapp4057.unit;
+
+import junit.framework.Test;
+import org.jboss.ejb3.test.ejbthree724.MyStateless;
+import org.jboss.ejb3.test.ejbthree724.Person;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class AbsoluteJarFileUnitTestCase extends JBossTestCase
+{
+   public AbsoluteJarFileUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testRelativeJarFileBeanAccess() throws Exception
+   {
+      Person p = new Person("Heiko");
+
+      MyStateless bean = (MyStateless) getInitialContext().lookup("jbpapp4057/MyStatelessBean/remote");
+
+      bean.save(p);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(AbsoluteJarFileUnitTestCase.class, "jbpapp4057.ear");
+   }
+}




More information about the jboss-cvs-commits mailing list