[seam-commits] Seam SVN: r13721 - in modules/persistence/trunk: impl/src/main/java/org/jboss/seam/persistence and 6 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon Sep 6 05:48:22 EDT 2010
Author: swd847
Date: 2010-09-06 05:48:22 -0400 (Mon, 06 Sep 2010)
New Revision: 13721
Added:
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/JNDIManagedPersistenceContextTest.java
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/util/
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/util/JNDIManagedPersistenceContextProvider.java
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
modules/persistence/trunk/pom.xml
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/EntityInjectionTestBase.java
modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/HibernateSearchTestBase.java
modules/persistence/trunk/tests-jboss/pom.xml
modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/EntityInjectionTest.java
modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence-orm.xml
modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence.xml
Log:
SEAMPERSIST-9 Allow SMPC to be defined using @Resource
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java 2010-09-04 21:08:22 UTC (rev 13720)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java 2010-09-06 09:48:22 UTC (rev 13721)
@@ -27,6 +27,7 @@
import java.util.List;
import java.util.Set;
+import javax.annotation.Resource;
import javax.enterprise.context.Dependent;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.Alternative;
@@ -95,7 +96,7 @@
{
// look for a seam managed persistence unit declaration on EE resource
// producer fields
- if (f.isAnnotationPresent(SeamManaged.class) && f.isAnnotationPresent(PersistenceUnit.class) && f.isAnnotationPresent(Produces.class) && EntityManagerFactory.class.isAssignableFrom(f.getJavaMember().getType()))
+ if (f.isAnnotationPresent(SeamManaged.class) && (f.isAnnotationPresent(PersistenceUnit.class) || f.isAnnotationPresent(Resource.class)) && f.isAnnotationPresent(Produces.class) && EntityManagerFactory.class.isAssignableFrom(f.getJavaMember().getType()))
{
if (modifiedType == null)
{
@@ -127,6 +128,7 @@
modifiedType.removeFromField(f.getJavaMember(), scope);
}
registerManagedPersistenceContext(qualifiers, scope, f.isAnnotationPresent(Alternative.class), manager, event.getAnnotatedType().getJavaClass().getClassLoader(), f);
+ log.info("Configuring Seam Managed Persistence Context from producer field " + f.getDeclaringType().getJavaClass().getName() + "." + f.getJavaMember().getName() + " with qualifiers " + qualifiers);
}
// now look for producer methods that produce an EntityManagerFactory.
// This allows the user to manually configure an EntityManagerFactory
@@ -167,6 +169,7 @@
modifiedType.removeFromMethod(m.getJavaMember(), scope);
modifiedType.addToMethod(m.getJavaMember(), ApplicationScopedLiteral.INSTANCE);
registerManagedPersistenceContext(qualifiers, scope, m.isAnnotationPresent(Alternative.class), manager, event.getAnnotatedType().getJavaClass().getClassLoader(), m);
+ log.info("Configuring Seam Managed Persistence Context from producer method " + m.getDeclaringType().getJavaClass().getName() + "." + m.getJavaMember().getName() + " with qualifiers " + qualifiers);
}
}
Modified: modules/persistence/trunk/pom.xml
===================================================================
--- modules/persistence/trunk/pom.xml 2010-09-04 21:08:22 UTC (rev 13720)
+++ modules/persistence/trunk/pom.xml 2010-09-06 09:48:22 UTC (rev 13721)
@@ -37,7 +37,7 @@
<jboss-javaee6-spec.version>1.0.0.Beta4</jboss-javaee6-spec.version>
<weld.extensions.version>1.0.0-SNAPSHOT</weld.extensions.version>
<hibernate.search.version>3.2.1.Final</hibernate.search.version>
- <arquillian.version>1.0.0.Alpha3</arquillian.version>
+ <arquillian.version>1.0.0.Alpha4</arquillian.version>
<jboss.server.manager.version>1.0.3.GA</jboss.server.manager.version>
<jboss-as-client.version>6.0.0.20100721-M4</jboss-as-client.version>
</properties>
Modified: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/EntityInjectionTestBase.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/EntityInjectionTestBase.java 2010-09-04 21:08:22 UTC (rev 13720)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/EntityInjectionTestBase.java 2010-09-06 09:48:22 UTC (rev 13721)
@@ -34,7 +34,6 @@
import org.jboss.seam.persistence.transaction.SeamTransaction;
import org.jboss.seam.transactions.test.util.HelloService;
import org.jboss.seam.transactions.test.util.Hotel;
-import org.jboss.seam.transactions.test.util.IndexedHotel;
import org.jboss.seam.transactions.test.util.ManagedPersistenceContextProvider;
import org.junit.Assert;
import org.junit.Test;
Modified: modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/HibernateSearchTestBase.java
===================================================================
--- modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/HibernateSearchTestBase.java 2010-09-04 21:08:22 UTC (rev 13720)
+++ modules/persistence/trunk/tests-base/src/main/java/org/jboss/seam/persistence/test/HibernateSearchTestBase.java 2010-09-06 09:48:22 UTC (rev 13721)
@@ -40,12 +40,11 @@
import org.junit.Assert;
import org.junit.Test;
-
public class HibernateSearchTestBase
{
public static Class<?>[] getTestClasses()
{
- return new Class[] { HibernateSearchTestBase.class, IndexedHotel.class, ManagedPersistenceContextProvider.class, HelloService.class };
+ return new Class[] { IndexedHotel.class, ManagedPersistenceContextProvider.class, HelloService.class, HibernateSearchTestBase.class };
}
@Inject
Modified: modules/persistence/trunk/tests-jboss/pom.xml
===================================================================
--- modules/persistence/trunk/tests-jboss/pom.xml 2010-09-04 21:08:22 UTC (rev 13720)
+++ modules/persistence/trunk/tests-jboss/pom.xml 2010-09-06 09:48:22 UTC (rev 13721)
@@ -33,6 +33,11 @@
</dependency>
<dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<scope>provided</scope>
@@ -142,7 +147,6 @@
<skip>true</skip>
</configuration>
</plugin>
-
</plugins>
</build>
Modified: modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/EntityInjectionTest.java
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/EntityInjectionTest.java 2010-09-04 21:08:22 UTC (rev 13720)
+++ modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/EntityInjectionTest.java 2010-09-06 09:48:22 UTC (rev 13721)
@@ -48,6 +48,7 @@
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
+
war.addClasses(getTestClasses());
war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
war.addWebResource("META-INF/persistence-orm.xml", "classes/META-INF/persistence.xml");
Added: modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/JNDIManagedPersistenceContextTest.java
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/JNDIManagedPersistenceContextTest.java (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/test/jboss/JNDIManagedPersistenceContextTest.java 2010-09-06 09:48:22 UTC (rev 13721)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.seam.persistence.test.jboss;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.test.ManagedPersistenceContextTestBase;
+import org.jboss.seam.persistence.transaction.test.util.JNDIManagedPersistenceContextProvider;
+import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.HelloService;
+import org.jboss.seam.transactions.test.util.Hotel;
+import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class JNDIManagedPersistenceContextTest extends ManagedPersistenceContextTestBase
+{
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_IMPL));
+ war.addClasses(new Class[] { ManagedPersistenceContextTestBase.class, Hotel.class, JNDIManagedPersistenceContextProvider.class, HelloService.class });
+ war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
+ war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
+ return war;
+ }
+}
Added: modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/util/JNDIManagedPersistenceContextProvider.java
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/util/JNDIManagedPersistenceContextProvider.java (rev 0)
+++ modules/persistence/trunk/tests-jboss/src/test/java/org/jboss/seam/persistence/transaction/test/util/JNDIManagedPersistenceContextProvider.java 2010-09-06 09:48:22 UTC (rev 13721)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.seam.persistence.transaction.test.util;
+
+import javax.annotation.Resource;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
+import javax.persistence.EntityManagerFactory;
+
+import org.jboss.seam.persistence.SeamManaged;
+
+public class JNDIManagedPersistenceContextProvider
+{
+ @Resource(mappedName = "java:EntityManagerFactory")
+ @RequestScoped
+ @Produces
+ @SeamManaged
+ EntityManagerFactory emf;
+}
Modified: modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence-orm.xml
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence-orm.xml 2010-09-04 21:08:22 UTC (rev 13720)
+++ modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence-orm.xml 2010-09-06 09:48:22 UTC (rev 13721)
@@ -15,13 +15,6 @@
<properties>
<!-- Properties for Hibernate (default provider for JBoss AS) -->
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
- <property name="hibernate.show_sql" value="true"/>
- <!-- Only format when you need to debug, because it slows things down -->
- <property name="hibernate.format_sql" value="false"/>
-
- <!-- Properties for EclipseLink (default provider for GlassFish) -->
- <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
- <property name="eclipselink.logging.level" value="FINE"/>
</properties>
</persistence-unit>
</persistence>
Modified: modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence.xml
===================================================================
--- modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence.xml 2010-09-04 21:08:22 UTC (rev 13720)
+++ modules/persistence/trunk/tests-jboss/src/test/resources/META-INF/persistence.xml 2010-09-06 09:48:22 UTC (rev 13721)
@@ -21,6 +21,7 @@
<!-- Properties for EclipseLink (default provider for GlassFish) -->
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.logging.level" value="FINE"/>
+ <property name="jboss.entity.manager.factory.jndi.name" value="java:EntityManagerFactory"/>
</properties>
</persistence-unit>
</persistence>
More information about the seam-commits
mailing list