[jboss-cvs] JBossAS SVN: r95827 - in branches/Branch_5_x: component-matrix and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 30 10:09:25 EDT 2009
Author: wolfc
Date: 2009-10-30 10:09:24 -0400 (Fri, 30 Oct 2009)
New Revision: 95827
Added:
branches/Branch_5_x/ejb3/src/main/org/jboss/as/jpa/builder/
branches/Branch_5_x/ejb3/src/main/org/jboss/as/jpa/builder/JPA2CEMFBuilder.java
Modified:
branches/Branch_5_x/build/build-distr.xml
branches/Branch_5_x/build/build.xml
branches/Branch_5_x/component-matrix/pom.xml
branches/Branch_5_x/ejb3/.classpath
branches/Branch_5_x/ejb3/build.xml
branches/Branch_5_x/ejb3/src/resources/META-INF/jpa-deployers-jboss-beans.xml
Log:
JBAS-7241: install validation-api in client, using jpa 2 components and created JPA2CEMFBuilder
Modified: branches/Branch_5_x/build/build-distr.xml
===================================================================
--- branches/Branch_5_x/build/build-distr.xml 2009-10-30 13:44:32 UTC (rev 95826)
+++ branches/Branch_5_x/build/build-distr.xml 2009-10-30 14:09:24 UTC (rev 95827)
@@ -216,6 +216,7 @@
<fileset dir="${jboss.jboss.ejb3.proxy.spi.lib}" includes="*-client.jar" excludes="*sources.jar"/>
<fileset dir="${jboss.jboss.ejb3.proxy.clustered.lib}" includes="*-client.jar" excludes="*sources.jar"/>
<fileset dir="${jboss.jboss.ejb3.security.lib}" includes="*-client.jar" excludes="*sources.jar"/>
+ <fileset dir="${validation.api.lib}" includes="*.jar" excludes="*sources.jar"/>
</copy>
</target>
Modified: branches/Branch_5_x/build/build.xml
===================================================================
--- branches/Branch_5_x/build/build.xml 2009-10-30 13:44:32 UTC (rev 95826)
+++ branches/Branch_5_x/build/build.xml 2009-10-30 14:09:24 UTC (rev 95827)
@@ -930,6 +930,7 @@
<include name="jbossjts.jar"/>
<include name="jbossjts-integration.jar"/>
<include name="jboss-profileservice-client.jar"/>
+ <include name="validation-api.jar"/>
<include name="weld-api.jar"/>
<!-- client excludes -->
<exclude name="jbossws-native-client.jar"/>
Modified: branches/Branch_5_x/component-matrix/pom.xml
===================================================================
--- branches/Branch_5_x/component-matrix/pom.xml 2009-10-30 13:44:32 UTC (rev 95826)
+++ branches/Branch_5_x/component-matrix/pom.xml 2009-10-30 14:09:24 UTC (rev 95827)
@@ -35,7 +35,7 @@
<version.jacorb>2.3.1jboss.patch01-brew</version.jacorb>
<version.javassist>3.11.0.GA</version.javassist>
<version.javax.faces>2.0.1-FCS</version.javax.faces>
- <version.javax.validation>1.0.CR5</version.javax.validation>
+ <version.javax.validation>1.0.0.GA</version.javax.validation>
<version.jboss.jaxr>2.0.1</version.jboss.jaxr>
<version.jboss.jbossts>4.6.1.GA</version.jboss.jbossts>
<version.jaxws.api>2.1</version.jaxws.api>
@@ -53,7 +53,7 @@
<version.org.hibernate.commons.annotations>3.2.0.Beta1</version.org.hibernate.commons.annotations>
<version.org.hibernate.java-persistence>2.0.Beta-20090815</version.org.hibernate.java-persistence>
<version.org.hibernate.entity.manager>3.5.0.Beta-1</version.org.hibernate.entity.manager>
- <version.org.hibernate.validator>4.0.0.CR1</version.org.hibernate.validator>
+ <version.org.hibernate.validator>4.0.0.GA</version.org.hibernate.validator>
<version.org.hibernate>3.5.0.Beta-1</version.org.hibernate>
<version.org.jboss.aop>2.1.6.GA</version.org.jboss.aop>
<version.org.jboss.aspects.currentinvocation>1.0.0.GA</version.org.jboss.aspects.currentinvocation>
@@ -90,7 +90,7 @@
<version.org.jboss.jbossxb>2.0.1.GA</version.org.jboss.jbossxb>
<version.org.jboss.jopr>1.3.2-SNAPSHOT</version.org.jboss.jopr>
<version.org.jboss.jpa.deployers>1.0.1-20091014.133942-1</version.org.jboss.jpa.deployers>
- <version.org.jboss.jpa.impl>1.0.0-20091014.155826-1</version.org.jboss.jpa.impl>
+ <version.org.jboss.jpa.impl>2.0.0-20091028.074512-3</version.org.jboss.jpa.impl>
<version.org.jboss.jpa.spi>1.0.0-20091014.133355-1</version.org.jboss.jpa.spi>
<version.org.jboss.logbridge>1.0.0.GA</version.org.jboss.logbridge>
<version.org.jboss.logmanager>1.1.0.GA</version.org.jboss.logmanager>
Modified: branches/Branch_5_x/ejb3/.classpath
===================================================================
--- branches/Branch_5_x/ejb3/.classpath 2009-10-30 13:44:32 UTC (rev 95826)
+++ branches/Branch_5_x/ejb3/.classpath 2009-10-30 14:09:24 UTC (rev 95827)
@@ -27,5 +27,8 @@
<classpathentry kind="lib" path="/thirdparty/jboss/jboss-mdr/lib/jboss-mdr.jar" sourcepath="/thirdparty/jboss/jboss-mdr/lib/jboss-mdr-sources.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/jboss-reflect/lib/jboss-reflect.jar" sourcepath="/thirdparty/jboss/jboss-reflect/lib/jboss-reflect-sources.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-kernel.jar" sourcepath="/thirdparty/jboss/microcontainer/lib/jboss-kernel-sources.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jboss/jboss-jpa-impl/lib/jboss-jpa-impl.jar" sourcepath="/thirdparty/jboss/jboss-jpa-impl/lib/jboss-jpa-impl-sources.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jboss/jboss-jpa-spi/lib/jboss-jpa-spi.jar" sourcepath="/thirdparty/jboss/jboss-jpa-spi/lib/jboss-jpa-spi-sources.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/validation-api/lib/validation-api.jar" sourcepath="/thirdparty/validation-api/lib/validation-api-sources.jar"/>
<classpathentry kind="output" path="output/eclipse-classes"/>
</classpath>
Modified: branches/Branch_5_x/ejb3/build.xml
===================================================================
--- branches/Branch_5_x/ejb3/build.xml 2009-10-30 13:44:32 UTC (rev 95826)
+++ branches/Branch_5_x/ejb3/build.xml 2009-10-30 14:09:24 UTC (rev 95827)
@@ -130,7 +130,7 @@
<path refid="jboss.jboss.reflect.classpath" />
<path refid="jboss.jboss.ejb3.endpoint.classpath" />
<path refid="jboss.jboss.ejb3.endpoint.deployer.classpath" />
-
+ <path refid="validation.api.classpath"/>
</path>
<!-- ======= -->
Added: branches/Branch_5_x/ejb3/src/main/org/jboss/as/jpa/builder/JPA2CEMFBuilder.java
===================================================================
--- branches/Branch_5_x/ejb3/src/main/org/jboss/as/jpa/builder/JPA2CEMFBuilder.java (rev 0)
+++ branches/Branch_5_x/ejb3/src/main/org/jboss/as/jpa/builder/JPA2CEMFBuilder.java 2009-10-30 14:09:24 UTC (rev 95827)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.as.jpa.builder;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.spi.PersistenceProvider;
+import javax.persistence.spi.PersistenceUnitInfo;
+import javax.validation.Validation;
+import javax.validation.ValidatorFactory;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.jpa.builder.CEMFBuilder;
+import org.jboss.jpa.impl.JPAConstants;
+
+/**
+ * Create a container managed entity manager factory with bean validation enabled.
+ *
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class JPA2CEMFBuilder implements CEMFBuilder
+{
+ public EntityManagerFactory build(DeploymentUnit deploymentUnit, PersistenceUnitInfo persistenceUnitInfo)
+ {
+ try
+ {
+ Class<?> providerClass = Thread.currentThread().getContextClassLoader().loadClass(persistenceUnitInfo.getPersistenceProviderClassName());
+
+ PersistenceProvider pp = (PersistenceProvider) providerClass.newInstance();
+ Map<Object, Object> properties = new HashMap<Object, Object>(1);
+ // FIXME: get it from JNDI or the deployer
+ ValidatorFactory beanValidationFactory = Validation.buildDefaultValidatorFactory();
+ properties.put(JPAConstants.BEAN_VALIDATION_FACTORY, beanValidationFactory);
+ EntityManagerFactory cemf = pp.createContainerEntityManagerFactory(persistenceUnitInfo, properties);
+ return cemf;
+ }
+ catch(ClassNotFoundException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch (InstantiationException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Modified: branches/Branch_5_x/ejb3/src/resources/META-INF/jpa-deployers-jboss-beans.xml
===================================================================
--- branches/Branch_5_x/ejb3/src/resources/META-INF/jpa-deployers-jboss-beans.xml 2009-10-30 13:44:32 UTC (rev 95826)
+++ branches/Branch_5_x/ejb3/src/resources/META-INF/jpa-deployers-jboss-beans.xml 2009-10-30 14:09:24 UTC (rev 95827)
@@ -3,9 +3,9 @@
vi:ts=3:sw=3:expandtab
-->
<deployment xmlns="urn:jboss:bean-deployer:2.0">
- <!-- Install the default CEMFBuilder, this will build a JPA 1 compliant
- container entity manager factory. -->
- <bean name="CEMFBuilder" class="org.jboss.jpa.builder.DefaultCEMFBuilder"/>
+ <!-- Install the JPA 2 CEMFBuilder, this will build a container entity manager factory with
+ bean validation enabled. -->
+ <bean name="CEMFBuilder" class="org.jboss.as.jpa.builder.JPA2CEMFBuilder"/>
<bean name="DataSourceDependencyResolver" class="org.jboss.as.jpa.resolvers.JBossASDataSourceDependencyResolver"/>
More information about the jboss-cvs-commits
mailing list