[jboss-cvs] JBossAS SVN: r111992 - in trunk: ejb3/src/resources/META-INF and 9 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Aug 10 16:54:27 EDT 2011
Author: alesj
Date: 2011-08-10 16:54:27 -0400 (Wed, 10 Aug 2011)
New Revision: 111992
Added:
trunk/testsuite/src/main/org/jboss/test/jpa/servlet/MultipleServlet.java
trunk/testsuite/src/main/org/jboss/test/jpa/support/ITestEntity.java
trunk/testsuite/src/main/org/jboss/test/jpa/support/TestEntityCopy.java
trunk/testsuite/src/main/org/jboss/test/jpa/test/WebMultipleJPAUnitTestCase.java
trunk/testsuite/src/resources/jpa/webmultiple/
trunk/testsuite/src/resources/jpa/webmultiple/WEB-INF/
trunk/testsuite/src/resources/jpa/webmultiple/WEB-INF/classes/
trunk/testsuite/src/resources/jpa/webmultiple/WEB-INF/classes/META-INF/
trunk/testsuite/src/resources/jpa/webmultiple/WEB-INF/classes/META-INF/persistence.xml
trunk/testsuite/src/resources/jpa/webmultiple/WEB-INF/jboss-web.xml
trunk/testsuite/src/resources/jpa/webmultiple/web.xml
Removed:
trunk/ejb3/src/main/java/org/jboss/ejb3/deployers/PersistenceUnitParsingDeployer.java
Modified:
trunk/ejb3/src/resources/META-INF/jpa-deployers-jboss-beans.xml
trunk/testsuite/imports/sections/jpa.xml
trunk/testsuite/src/main/org/jboss/test/jpa/support/TestEntity.java
Log:
[JBAS-9155]; allow multiple persistence.xml files + test this.
Deleted: trunk/ejb3/src/main/java/org/jboss/ejb3/deployers/PersistenceUnitParsingDeployer.java
===================================================================
--- trunk/ejb3/src/main/java/org/jboss/ejb3/deployers/PersistenceUnitParsingDeployer.java 2011-08-10 20:15:11 UTC (rev 111991)
+++ trunk/ejb3/src/main/java/org/jboss/ejb3/deployers/PersistenceUnitParsingDeployer.java 2011-08-10 20:54:27 UTC (rev 111992)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, 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.deployers;
-
-import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
-import org.jboss.metadata.jpa.spec.PersistenceMetaData;
-
-/**
- * Find and parse persistence.xml.
- *
- * In a jar:
- * META-INF/persistence.xml
- *
- * In a war (JPA 6.2):
- * WEB-INF/classes/META-INF/persistence.xml
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- * @version $Revision$
- */
-public class PersistenceUnitParsingDeployer extends SchemaResolverDeployer<PersistenceMetaData>
-{
- public PersistenceUnitParsingDeployer()
- {
- super(PersistenceMetaData.class);
- setName("persistence.xml");
- setRegisterWithJBossXB(true);
- }
-}
Modified: trunk/ejb3/src/resources/META-INF/jpa-deployers-jboss-beans.xml
===================================================================
--- trunk/ejb3/src/resources/META-INF/jpa-deployers-jboss-beans.xml 2011-08-10 20:15:11 UTC (rev 111991)
+++ trunk/ejb3/src/resources/META-INF/jpa-deployers-jboss-beans.xml 2011-08-10 20:54:27 UTC (rev 111992)
@@ -25,6 +25,8 @@
<bean name="XPCResolver" class="org.jboss.ejb3.stateful.EJB3XPCResolver"/>
<bean name="PersistenceParsingDeployer" class="org.jboss.jpa.deployers.PersistenceParsingDeployer">
+ <property name="suffix">persistence.xml</property>
+ <property name="allowMultipleFiles">true</property>
<property name="filter">
<bean class="org.jboss.deployers.spi.structure.MetaDataTypeFilter">
<constructor factoryClass="org.jboss.deployment.MetaDataTypeFilterFactory" factoryMethod="getAll"/>
Modified: trunk/testsuite/imports/sections/jpa.xml
===================================================================
--- trunk/testsuite/imports/sections/jpa.xml 2011-08-10 20:15:11 UTC (rev 111991)
+++ trunk/testsuite/imports/sections/jpa.xml 2011-08-10 20:54:27 UTC (rev 111992)
@@ -11,6 +11,7 @@
<classes dir="${build.classes}">
<include name="org/jboss/test/jpa/servlet/TestServlet.class"/>
<include name="org/jboss/test/jpa/support/TestEntity.class"/>
+ <include name="org/jboss/test/jpa/support/ITestEntity.class"/>
</classes>
</war>
@@ -29,6 +30,7 @@
</fileset>
<fileset dir="${build.classes}">
<include name="org/jboss/test/jpa/support/TestEntity.class"/>
+ <include name="org/jboss/test/jpa/support/ITestEntity.class"/>
</fileset>
</jar>
@@ -45,6 +47,20 @@
</lib>
</war>
+ <war warfile="${build.lib}/test-jpa-webmultiple.war"
+ webxml="${build.resources}/jpa/webmultiple/web.xml">
+ <webinf dir="${build.resources}/jpa/webmultiple/WEB-INF">
+ <include name="**"/>
+ </webinf>
+ <classes dir="${build.classes}">
+ <include name="org/jboss/test/jpa/servlet/MultipleServlet.class"/>
+ <include name="org/jboss/test/jpa/support/TestEntityCopy.class"/>
+ </classes>
+ <lib dir="${build.lib}">
+ <include name="test-jpa-weblibs.jar"/>
+ </lib>
+ </war>
+
<jar destfile="${build.lib}/test-jpa-weblibs.ear">
<fileset dir="${build.resources}/jpa/weblibs/ear">
<include name="META-INF/**"/>
Copied: trunk/testsuite/src/main/org/jboss/test/jpa/servlet/MultipleServlet.java (from rev 111937, trunk/testsuite/src/main/org/jboss/test/jpa/servlet/TestServlet.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jpa/servlet/MultipleServlet.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/jpa/servlet/MultipleServlet.java 2011-08-10 20:54:27 UTC (rev 111992)
@@ -0,0 +1,118 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* 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.test.jpa.servlet;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.lang.reflect.Constructor;
+import javax.annotation.Resource;
+import javax.naming.InitialContext;
+import javax.persistence.EntityManager;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.transaction.UserTransaction;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.jpa.support.ITestEntity;
+import org.jboss.test.jpa.support.TestEntity;
+import org.jboss.test.jpa.support.TestEntityCopy;
+
+/**
+ * MultipleServlet.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class MultipleServlet extends HttpServlet
+{
+ /**
+ * The serialVersionUID
+ */
+ private static final long serialVersionUID = -5539196377086639503L;
+
+ private Logger log = Logger.getLogger(MultipleServlet.class);
+
+ @Resource
+ private UserTransaction ut;
+
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
+ {
+ try
+ {
+ StringBuilder out = new StringBuilder();
+
+ handleJPA(req, "java:comp/env/persistence/em0", "Wo", out, TestEntity.class);
+ handleJPA(req, "java:comp/env/persistence/em1", "rld", out, TestEntityCopy.class);
+
+ if (out.length() > 0)
+ {
+ resp.setContentType("text/plain");
+ PrintWriter writer = resp.getWriter();
+ writer.print(out.toString());
+ writer.close();
+ }
+ }
+ catch (Exception e)
+ {
+ throw new ServletException("Error", e);
+ }
+ }
+
+ protected void handleJPA(HttpServletRequest req, String name, String msg, StringBuilder out, Class<? extends ITestEntity> clazz) throws Exception
+ {
+ ut.begin();
+ try
+ {
+ InitialContext ctx = new InitialContext();
+
+ EntityManager em = (EntityManager) ctx.lookup(name);
+ handleRequest(req, em, msg, out, clazz);
+ }
+ catch (Exception e)
+ {
+ log.error("Error in servlet", e);
+ ut.setRollbackOnly();
+ throw e;
+ }
+ finally
+ {
+ ut.commit();
+ }
+ }
+
+ protected void handleRequest(HttpServletRequest req, EntityManager em, String text, StringBuilder out, Class<? extends ITestEntity> clazz) throws Exception
+ {
+ String mode = req.getParameter("mode");
+ if ("Write".equals(mode))
+ {
+ Constructor ctor = clazz.getConstructor(String.class, String.class);
+ ITestEntity test = (ITestEntity) ctor.newInstance("Hello", text);
+ em.persist(test);
+ }
+ else
+ {
+ ITestEntity test = em.find(clazz, "Hello");
+ out.append(test.getDescription());
+ }
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/jpa/support/ITestEntity.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jpa/support/ITestEntity.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/jpa/support/ITestEntity.java 2011-08-10 20:54:27 UTC (rev 111992)
@@ -0,0 +1,31 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* 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.test.jpa.support;
+
+/**
+ * ITestEntity.
+ *
+ */
+public interface ITestEntity
+{
+ String getDescription();
+}
Modified: trunk/testsuite/src/main/org/jboss/test/jpa/support/TestEntity.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jpa/support/TestEntity.java 2011-08-10 20:15:11 UTC (rev 111991)
+++ trunk/testsuite/src/main/org/jboss/test/jpa/support/TestEntity.java 2011-08-10 20:54:27 UTC (rev 111992)
@@ -31,7 +31,7 @@
* @version $Revision$
*/
@Entity
-public class TestEntity
+public class TestEntity implements ITestEntity
{
@Id private String name;
Copied: trunk/testsuite/src/main/org/jboss/test/jpa/support/TestEntityCopy.java (from rev 111937, trunk/testsuite/src/main/org/jboss/test/jpa/support/TestEntity.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jpa/support/TestEntityCopy.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/jpa/support/TestEntityCopy.java 2011-08-10 20:54:27 UTC (rev 111992)
@@ -0,0 +1,71 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* 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.test.jpa.support;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+/**
+ * TestEntity.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision$
+ */
+ at Entity
+public class TestEntityCopy implements ITestEntity
+{
+ @Id private String name;
+
+ private String description;
+
+ public TestEntityCopy()
+ {
+ }
+
+ public TestEntityCopy(String name, String description)
+ {
+ setName(name);
+ setDescription(description);
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+
+}
Copied: trunk/testsuite/src/main/org/jboss/test/jpa/test/WebMultipleJPAUnitTestCase.java (from rev 111937, trunk/testsuite/src/main/org/jboss/test/jpa/test/WebLibsJPAUnitTestCase.java)
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jpa/test/WebMultipleJPAUnitTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/jpa/test/WebMultipleJPAUnitTestCase.java 2011-08-10 20:54:27 UTC (rev 111992)
@@ -0,0 +1,42 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* 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.test.jpa.test;
+
+import junit.framework.Test;
+
+/**
+ * WebMultipleJPAUnitTestCase.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class WebMultipleJPAUnitTestCase extends AbstractWebJPATest
+{
+ public WebMultipleJPAUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(WebMultipleJPAUnitTestCase.class, "test-jpa-webmultiple.war");
+ }
+}
Added: trunk/testsuite/src/resources/jpa/webmultiple/WEB-INF/classes/META-INF/persistence.xml
===================================================================
--- trunk/testsuite/src/resources/jpa/webmultiple/WEB-INF/classes/META-INF/persistence.xml (rev 0)
+++ trunk/testsuite/src/resources/jpa/webmultiple/WEB-INF/classes/META-INF/persistence.xml 2011-08-10 20:54:27 UTC (rev 111992)
@@ -0,0 +1,15 @@
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+
+ <persistence-unit name="test-copy">
+ <jta-data-source>java:/DefaultDS</jta-data-source>
+ <class>org.jboss.test.jpa.support.TestEntityCopy</class>
+ <properties>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ </properties>
+ </persistence-unit>
+
+</persistence>
Copied: trunk/testsuite/src/resources/jpa/webmultiple/WEB-INF/jboss-web.xml (from rev 111937, trunk/testsuite/src/resources/jpa/webclasses/WEB-INF/jboss-web.xml)
===================================================================
--- trunk/testsuite/src/resources/jpa/webmultiple/WEB-INF/jboss-web.xml (rev 0)
+++ trunk/testsuite/src/resources/jpa/webmultiple/WEB-INF/jboss-web.xml 2011-08-10 20:54:27 UTC (rev 111992)
@@ -0,0 +1,7 @@
+<!DOCTYPE jboss-web
+ PUBLIC "-//JBoss//DTD Web Application 2.3V2//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">
+
+<jboss-web>
+ <context-root>jpa-test</context-root>
+</jboss-web>
Copied: trunk/testsuite/src/resources/jpa/webmultiple/web.xml (from rev 111937, trunk/testsuite/src/resources/jpa/weblibs/web.xml)
===================================================================
--- trunk/testsuite/src/resources/jpa/webmultiple/web.xml (rev 0)
+++ trunk/testsuite/src/resources/jpa/webmultiple/web.xml 2011-08-10 20:54:27 UTC (rev 111992)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app version="2.5"
+ 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/web-app_2_5.xsd"
+>
+ <display-name>jpa test</display-name>
+
+ <servlet>
+ <servlet-name>TestServlet</servlet-name>
+ <servlet-class>org.jboss.test.jpa.servlet.MultipleServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TestServlet</servlet-name>
+ <url-pattern>/Test</url-pattern>
+ </servlet-mapping>
+
+ <persistence-context-ref>
+ <persistence-context-ref-name>persistence/em0</persistence-context-ref-name>
+ <persistence-unit-name>test</persistence-unit-name>
+ </persistence-context-ref>
+
+ <persistence-context-ref>
+ <persistence-context-ref-name>persistence/em1</persistence-context-ref-name>
+ <persistence-unit-name>test-copy</persistence-unit-name>
+ </persistence-context-ref>
+
+</web-app>
More information about the jboss-cvs-commits
mailing list