[jboss-cvs] JBossAS SVN: r94522 - in projects/jpa/trunk: impl and 26 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 8 11:11:01 EDT 2009


Author: wolfc
Date: 2009-10-08 11:11:00 -0400 (Thu, 08 Oct 2009)
New Revision: 94522

Added:
   projects/jpa/trunk/impl/
   projects/jpa/trunk/impl/.classpath
   projects/jpa/trunk/impl/.project
   projects/jpa/trunk/impl/.settings/
   projects/jpa/trunk/impl/.settings/org.eclipse.jdt.core.prefs
   projects/jpa/trunk/impl/.settings/org.maven.ide.eclipse.prefs
   projects/jpa/trunk/impl/pom.xml
   projects/jpa/trunk/impl/src/
   projects/jpa/trunk/impl/src/main/
   projects/jpa/trunk/impl/src/main/java/
   projects/jpa/trunk/impl/src/main/java/org/
   projects/jpa/trunk/impl/src/main/java/org/jboss/
   projects/jpa/trunk/impl/src/main/java/org/jboss/jpa/
   projects/jpa/trunk/impl/src/main/java/org/jboss/jpa/impl/
   projects/jpa/trunk/impl/src/main/java/org/jboss/jpa/impl/tx/
   projects/jpa/trunk/impl/src/main/java/org/jboss/jpa/impl/tx/TransactionScopedEntityManager.java
   projects/jpa/trunk/impl/src/test/
   projects/jpa/trunk/impl/src/test/java/
   projects/jpa/trunk/impl/src/test/java/org/
   projects/jpa/trunk/impl/src/test/java/org/jboss/
   projects/jpa/trunk/impl/src/test/java/org/jboss/jpa/
   projects/jpa/trunk/impl/src/test/java/org/jboss/jpa/impl/
   projects/jpa/trunk/impl/src/test/java/org/jboss/jpa/impl/helper/
   projects/jpa/trunk/impl/src/test/java/org/jboss/jpa/impl/helper/Creator.java
   projects/jpa/trunk/spi/
   projects/jpa/trunk/spi/.classpath
   projects/jpa/trunk/spi/.project
   projects/jpa/trunk/spi/.settings/
   projects/jpa/trunk/spi/.settings/org.eclipse.jdt.core.prefs
   projects/jpa/trunk/spi/.settings/org.maven.ide.eclipse.prefs
   projects/jpa/trunk/spi/pom.xml
   projects/jpa/trunk/spi/src/
   projects/jpa/trunk/spi/src/main/
   projects/jpa/trunk/spi/src/main/java/
   projects/jpa/trunk/spi/src/main/java/org/
   projects/jpa/trunk/spi/src/main/java/org/jboss/
   projects/jpa/trunk/spi/src/main/java/org/jboss/jpa/
   projects/jpa/trunk/spi/src/main/java/org/jboss/jpa/spi/
   projects/jpa/trunk/spi/src/main/java/org/jboss/jpa/spi/PersistenceUnit.java
   projects/jpa/trunk/spi/src/main/java/org/jboss/jpa/spi/PersistenceUnitRegistry.java
   projects/jpa/trunk/spi/src/main/java/org/jboss/jpa/spi/XPCResolver.java
   projects/jpa/trunk/spi/src/test/
   projects/jpa/trunk/spi/src/test/java/
Log:
JBJPA-15: created impl & spi modules


Property changes on: projects/jpa/trunk/impl
___________________________________________________________________
Name: svn:ignore
   + eclipse-target
target


Added: projects/jpa/trunk/impl/.classpath
===================================================================
--- projects/jpa/trunk/impl/.classpath	                        (rev 0)
+++ projects/jpa/trunk/impl/.classpath	2009-10-08 15:11:00 UTC (rev 94522)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="eclipse-target/classes" path="src/main/java"/>
+	<classpathentry kind="src" output="eclipse-target/tests-classes" path="src/test/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="eclipse-target/classes"/>
+</classpath>

Added: projects/jpa/trunk/impl/.project
===================================================================
--- projects/jpa/trunk/impl/.project	                        (rev 0)
+++ projects/jpa/trunk/impl/.project	2009-10-08 15:11:00 UTC (rev 94522)
@@ -0,0 +1,20 @@
+<projectDescription>
+  <name>jboss-jpa-impl</name>
+  <comment>The JBoss Container Managed JPA Implementation provides implementation
+    classes for the different JPA interfaces.</comment>
+  <projects/>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+    <!-- 
+    <buildCommand>
+      <name>org.maven.ide.eclipse.maven2Builder</name>
+    </buildCommand>
+    -->
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+    <nature>org.maven.ide.eclipse.maven2Nature</nature>
+  </natures>
+</projectDescription>
\ No newline at end of file

Added: projects/jpa/trunk/impl/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/jpa/trunk/impl/.settings/org.eclipse.jdt.core.prefs	                        (rev 0)
+++ projects/jpa/trunk/impl/.settings/org.eclipse.jdt.core.prefs	2009-10-08 15:11:00 UTC (rev 94522)
@@ -0,0 +1,5 @@
+#Thu Oct 08 11:29:25 CEST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5

Added: projects/jpa/trunk/impl/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- projects/jpa/trunk/impl/.settings/org.maven.ide.eclipse.prefs	                        (rev 0)
+++ projects/jpa/trunk/impl/.settings/org.maven.ide.eclipse.prefs	2009-10-08 15:11:00 UTC (rev 94522)
@@ -0,0 +1,9 @@
+#Thu Oct 08 11:29:51 CEST 2009
+activeProfiles=eclipse
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1

Added: projects/jpa/trunk/impl/pom.xml
===================================================================
--- projects/jpa/trunk/impl/pom.xml	                        (rev 0)
+++ projects/jpa/trunk/impl/pom.xml	2009-10-08 15:11:00 UTC (rev 94522)
@@ -0,0 +1,64 @@
+<!--
+  vi:ts=2:sw=2:expandtab
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.jboss.jpa</groupId>
+    <artifactId>jboss-jpa-build</artifactId>
+    <relativePath>../build/pom.xml</relativePath>
+    <version>1.0.0</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>jboss-jpa-impl</artifactId>
+  <version>1.0.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+  <name>JBoss Container Managed JPA Implementation</name>
+  <description>
+    The JBoss Container Managed JPA Implementation provides implementation
+    classes for the different JPA interfaces.
+  </description>
+  
+  <dependencies>
+  	<dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.4</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate-entitymanager</artifactId>
+      <version>3.4.0.GA</version>
+    </dependency>
+    <!-- 
+  	<dependency>
+      <groupId>org.hibernate.java-persistence</groupId>
+      <artifactId>jpa-api</artifactId>
+      <version>2.0.Beta-20090815</version>
+    </dependency>
+    -->
+    <dependency>
+      <groupId>org.jboss.integration</groupId>
+      <artifactId>jboss-transaction-spi</artifactId>
+      <version>5.0.3.GA</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.jpa</groupId>
+      <artifactId>jboss-jpa-spi</artifactId>
+      <version>1.0.0-SNAPSHOT</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.hibernate</groupId>
+          <artifactId>ejb3-persistence</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging-spi</artifactId>
+      <version>2.1.0.GA</version>
+    </dependency>
+  </dependencies>
+</project>

Copied: projects/jpa/trunk/impl/src/main/java/org/jboss/jpa/impl/tx/TransactionScopedEntityManager.java (from rev 94507, projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/tx/TransactionScopedEntityManager.java)
===================================================================
--- projects/jpa/trunk/impl/src/main/java/org/jboss/jpa/impl/tx/TransactionScopedEntityManager.java	                        (rev 0)
+++ projects/jpa/trunk/impl/src/main/java/org/jboss/jpa/impl/tx/TransactionScopedEntityManager.java	2009-10-08 15:11:00 UTC (rev 94522)
@@ -0,0 +1,244 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.jpa.impl.tx;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
+import javax.persistence.FlushModeType;
+import javax.persistence.LockModeType;
+import javax.persistence.Query;
+
+import org.hibernate.Session;
+import org.hibernate.ejb.HibernateEntityManager;
+import org.jboss.jpa.spi.PersistenceUnit;
+import org.jboss.jpa.spi.PersistenceUnitRegistry;
+import org.jboss.jpa.spi.XPCResolver;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+public class TransactionScopedEntityManager implements EntityManager, Externalizable
+{
+   private static final long serialVersionUID = 1L;
+   
+   private static final Logger log = Logger.getLogger(TransactionScopedEntityManager.class);
+   
+   private transient PersistenceUnit persistenceUnit;
+
+   public Session getHibernateSession()
+   {
+      EntityManager em = persistenceUnit.getTransactionScopedEntityManager();
+      if (em instanceof HibernateEntityManager)
+      {
+         return ((HibernateEntityManager) em).getSession();
+      }
+      throw new RuntimeException("ILLEGAL ACTION:  Not a Hibernate pe" +
+              "rsistence provider");
+   }
+
+   public TransactionScopedEntityManager(PersistenceUnit persistenceUnit)
+   {
+      if (persistenceUnit == null) throw new NullPointerException("persistenceUnit must not be null");
+      this.persistenceUnit = persistenceUnit;
+   }
+
+   public TransactionScopedEntityManager()
+   {
+   }
+
+   public void writeExternal(ObjectOutput out) throws IOException
+   {
+      out.writeUTF(persistenceUnit.getName());
+   }
+
+   public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+   {
+      String kernelName = in.readUTF();
+      persistenceUnit = PersistenceUnitRegistry.getPersistenceUnit(kernelName);
+      if ( persistenceUnit == null ) throw new IOException( "Unable to find persistence unit in registry: " + kernelName );
+   }
+
+   public Object getDelegate()
+   {
+      return getEntityManager().getDelegate();
+   }
+
+   public void joinTransaction()
+   {
+      persistenceUnit.verifyInTx();
+      getEntityManager().joinTransaction();
+   }
+
+   public void clear()
+   {
+      getEntityManager().clear();
+   }
+
+   public FlushModeType getFlushMode()
+   {
+      return getEntityManager().getFlushMode();
+   }
+
+   public void lock(Object entity, LockModeType lockMode)
+   {
+      persistenceUnit.verifyInTx();
+      getEntityManager().lock(entity, lockMode);
+   }
+
+   public <T> T getReference(Class<T> entityClass, Object primaryKey)
+   {
+      EntityManager em = getEntityManager();
+      if (!persistenceUnit.isInTx()) em.clear(); // em will be closed by interceptor
+      try
+      {
+         return em.getReference(entityClass, primaryKey);
+      }
+      finally
+      {
+         if (!persistenceUnit.isInTx()) em.clear(); // em will be closed by interceptor
+      }
+   }
+
+   public void setFlushMode(FlushModeType flushMode)
+   {
+      getEntityManager().setFlushMode(flushMode);
+   }
+
+   public Query createQuery(String ejbqlString)
+   {
+      EntityManager em = getEntityManager();
+      if (!persistenceUnit.isInTx()) em.clear(); // em will be closed by interceptor
+      return em.createQuery(ejbqlString);
+   }
+
+   public Query createNamedQuery(String name)
+   {
+      EntityManager em = getEntityManager();
+      if (!persistenceUnit.isInTx()) em.clear(); // em will be closed by interceptor
+      return em.createNamedQuery(name);
+   }
+
+   public Query createNativeQuery(String sqlString)
+   {
+      EntityManager em = getEntityManager();
+      if (!persistenceUnit.isInTx()) em.clear(); // em will be closed by interceptor
+      return em.createNativeQuery(sqlString);
+   }
+
+   public Query createNativeQuery(String sqlString, Class resultClass)
+   {
+      EntityManager em = getEntityManager();
+      if (!persistenceUnit.isInTx()) em.clear(); // em will be closed by interceptor
+      return em.createNativeQuery(sqlString, resultClass);
+   }
+
+   public Query createNativeQuery(String sqlString, String resultSetMapping)
+   {
+      EntityManager em = getEntityManager();
+      if (!persistenceUnit.isInTx()) em.clear(); // em will be closed by interceptor
+      return em.createNativeQuery(sqlString, resultSetMapping);
+   }
+
+   public <A> A find(Class<A> entityClass, Object primaryKey)
+   {
+      EntityManager em = getEntityManager();
+      if (!persistenceUnit.isInTx()) em.clear(); // em will be closed by interceptor
+      try
+      {
+         return em.find(entityClass, primaryKey);
+      }
+      finally
+      {
+         if (!persistenceUnit.isInTx()) em.clear(); // em will be closed by interceptor
+      }
+   }
+
+   public void persist(Object entity)
+   {
+      persistenceUnit.verifyInTx();
+      getEntityManager().persist(entity);
+   }
+
+   public <A> A merge(A entity)
+   {
+      persistenceUnit.verifyInTx();
+      return (A) getEntityManager().merge(entity);
+   }
+
+   public void remove(Object entity)
+   {
+      persistenceUnit.verifyInTx();
+      getEntityManager().remove(entity);
+   }
+
+   public void refresh(Object entity)
+   {
+      persistenceUnit.verifyInTx();
+      getEntityManager().refresh(entity);
+   }
+
+   public boolean contains(Object entity)
+   {
+      return getEntityManager().contains(entity);
+   }
+
+   public void flush()
+   {
+      persistenceUnit.verifyInTx();
+      getEntityManager().flush();
+   }
+
+   public void close()
+   {
+      throw new IllegalStateException("Illegal to call this method from injected, managed EntityManager");
+   }
+
+   public boolean isOpen()
+   {
+      throw new IllegalStateException("Illegal to call this method from injected, managed EntityManager");
+   }
+
+   public EntityTransaction getTransaction()
+   {
+      throw new IllegalStateException("Illegal to call this method from injected, managed EntityManager");
+   }
+   
+   protected EntityManager getEntityManager()
+   {
+      String kernelName = persistenceUnit.getName();
+      PersistenceUnit pu = PersistenceUnitRegistry.getPersistenceUnit(kernelName);
+      XPCResolver xpcResolver = pu.getXPCResolver();
+      EntityManager em = xpcResolver.getExtendedPersistenceContext(kernelName);
+      if(em != null)
+         return em;
+      
+      return persistenceUnit.getTransactionScopedEntityManager();
+   }
+
+}

Added: projects/jpa/trunk/impl/src/test/java/org/jboss/jpa/impl/helper/Creator.java
===================================================================
--- projects/jpa/trunk/impl/src/test/java/org/jboss/jpa/impl/helper/Creator.java	                        (rev 0)
+++ projects/jpa/trunk/impl/src/test/java/org/jboss/jpa/impl/helper/Creator.java	2009-10-08 15:11:00 UTC (rev 94522)
@@ -0,0 +1,74 @@
+/*
+ * 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.jpa.impl.helper;
+
+import java.io.PrintStream;
+import java.lang.reflect.Method;
+
+import javax.persistence.EntityManager;
+
+/**
+ * Creator of abstract class source code. Not really a test. :-)
+ * 
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class Creator
+{
+
+   /**
+    * @param args
+    */
+   public static void main(String[] args)
+   {
+      PrintStream out = System.out;
+      
+      out.println("// Generated using " + Creator.class.getName() + ", DO NOT EDIT");
+      out.println("package org.jboss.jpa.impl.tx;");
+      out.println("protected class AbstractTransactionScopedEntityManager implements EntityManager");
+      out.println("{");
+      
+      Class<EntityManager> cls = EntityManager.class;
+      
+      Method methods[] = cls.getMethods();
+      for(int i = 0; i < methods.length; i++)
+      {
+         out.println("\t" + methods[i]);
+         String returnType = methods[i].getReturnType().getName();
+         String methodName = methods[i].getName();
+         out.print("   public " + returnType + " " + methodName + "(");
+         Class<?> parameterTypes[] = methods[i].getParameterTypes();
+         for(int j = 0; j < parameterTypes.length; j++)
+         {
+            out.print(parameterTypes[j].getName());
+            out.print(" arg" + j);
+            if((j + 1) < parameterTypes.length)
+               out.print(", ");
+         }
+         out.println(")");
+         out.println("   {");
+         System.out.println(methods[i].getExceptionTypes());
+         out.println("   }");
+      }
+   }
+
+}


Property changes on: projects/jpa/trunk/spi
___________________________________________________________________
Name: svn:ignore
   + eclipse-target
target


Added: projects/jpa/trunk/spi/.classpath
===================================================================
--- projects/jpa/trunk/spi/.classpath	                        (rev 0)
+++ projects/jpa/trunk/spi/.classpath	2009-10-08 15:11:00 UTC (rev 94522)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="eclipse-target/classes" path="src/main/java"/>
+	<classpathentry kind="src" output="eclipse-target/tests-classes" path="src/test/java"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="eclipse-target/classes"/>
+</classpath>

Added: projects/jpa/trunk/spi/.project
===================================================================
--- projects/jpa/trunk/spi/.project	                        (rev 0)
+++ projects/jpa/trunk/spi/.project	2009-10-08 15:11:00 UTC (rev 94522)
@@ -0,0 +1,19 @@
+<projectDescription>
+  <name>jboss-jpa-spi</name>
+  <comment>The JBoss Container Managed JPA SPI.</comment>
+  <projects/>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+    <!-- 
+    <buildCommand>
+      <name>org.maven.ide.eclipse.maven2Builder</name>
+    </buildCommand>
+    -->
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+    <nature>org.maven.ide.eclipse.maven2Nature</nature>
+  </natures>
+</projectDescription>
\ No newline at end of file

Added: projects/jpa/trunk/spi/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/jpa/trunk/spi/.settings/org.eclipse.jdt.core.prefs	                        (rev 0)
+++ projects/jpa/trunk/spi/.settings/org.eclipse.jdt.core.prefs	2009-10-08 15:11:00 UTC (rev 94522)
@@ -0,0 +1,5 @@
+#Thu Oct 08 15:00:29 CEST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5

Added: projects/jpa/trunk/spi/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- projects/jpa/trunk/spi/.settings/org.maven.ide.eclipse.prefs	                        (rev 0)
+++ projects/jpa/trunk/spi/.settings/org.maven.ide.eclipse.prefs	2009-10-08 15:11:00 UTC (rev 94522)
@@ -0,0 +1,9 @@
+#Thu Oct 08 17:01:39 CEST 2009
+activeProfiles=eclipse
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1

Added: projects/jpa/trunk/spi/pom.xml
===================================================================
--- projects/jpa/trunk/spi/pom.xml	                        (rev 0)
+++ projects/jpa/trunk/spi/pom.xml	2009-10-08 15:11:00 UTC (rev 94522)
@@ -0,0 +1,40 @@
+<!--
+  vi:ts=2:sw=2:expandtab
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.jboss.jpa</groupId>
+    <artifactId>jboss-jpa-build</artifactId>
+    <relativePath>../build/pom.xml</relativePath>
+    <version>1.0.0</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>jboss-jpa-spi</artifactId>
+  <version>1.0.0-SNAPSHOT</version>
+  <packaging>jar</packaging>
+  <name>JBoss Container Managed JPA SPI</name>
+  <description>
+    The JBoss Container Managed JPA SPI.
+  </description>
+  
+  <dependencies>
+  	<dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.4</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>ejb3-persistence</artifactId>
+      <version>1.0.2.GA</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging-spi</artifactId>
+      <version>2.1.0.GA</version>
+    </dependency>
+  </dependencies>
+</project>

Copied: projects/jpa/trunk/spi/src/main/java/org/jboss/jpa/spi/PersistenceUnit.java (from rev 94507, projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/spi/PersistenceUnit.java)
===================================================================
--- projects/jpa/trunk/spi/src/main/java/org/jboss/jpa/spi/PersistenceUnit.java	                        (rev 0)
+++ projects/jpa/trunk/spi/src/main/java/org/jboss/jpa/spi/PersistenceUnit.java	2009-10-08 15:11:00 UTC (rev 94522)
@@ -0,0 +1,60 @@
+/*
+ * 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.jpa.spi;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+/**
+ * EJB 3 JPA 7.1.1. To create entity managers within a container
+ * there is a bean installed which conforms to this interface.
+ * 
+ * Only one EntityManagerFactory is permitted to be created for each deployed persistence unit configuration.
+ * 
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface PersistenceUnit
+{
+   /**
+    * Obtain the container entity manager factory.
+    * 
+    * @return an EntityManagerFactory
+    */
+   EntityManagerFactory getContainerEntityManagerFactory();
+   
+   String getName();
+   
+   EntityManager getTransactionScopedEntityManager();
+   
+   /**
+    * The extended persistence context resolver associated with
+    * this persistence unit.
+    * 
+    * @return the XPC resolver
+    */
+   XPCResolver getXPCResolver();
+   
+   boolean isInTx();
+   
+   void verifyInTx();
+}

Copied: projects/jpa/trunk/spi/src/main/java/org/jboss/jpa/spi/PersistenceUnitRegistry.java (from rev 94507, projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/spi/PersistenceUnitRegistry.java)
===================================================================
--- projects/jpa/trunk/spi/src/main/java/org/jboss/jpa/spi/PersistenceUnitRegistry.java	                        (rev 0)
+++ projects/jpa/trunk/spi/src/main/java/org/jboss/jpa/spi/PersistenceUnitRegistry.java	2009-10-08 15:11:00 UTC (rev 94522)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.jpa.spi;
+
+import java.util.Collection;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ * @version <tt>$Revision$</tt>
+ */
+public class PersistenceUnitRegistry
+{
+//   private static final Logger log = Logger.getLogger(PersistenceUnitRegistry.class);
+
+   private static ConcurrentHashMap<String, PersistenceUnit> persistenceUnits = new ConcurrentHashMap<String, PersistenceUnit>();
+
+   public static void register(PersistenceUnit container)
+   {
+      if (persistenceUnits.contains(container.getName())) throw new RuntimeException("Persistence Unit is already registered: " + container.getName());
+      persistenceUnits.put(container.getName(), container);
+   }
+
+   public static void unregister(PersistenceUnit container)
+   {
+      persistenceUnits.remove(container.getName());
+   }
+
+   public static PersistenceUnit getPersistenceUnit(String name)
+   {
+      return persistenceUnits.get(name);
+   }
+
+   public static Collection<PersistenceUnit> getPersistenceUnits()
+   {
+      return persistenceUnits.values();
+   }
+
+}

Copied: projects/jpa/trunk/spi/src/main/java/org/jboss/jpa/spi/XPCResolver.java (from rev 94507, projects/jpa/trunk/deployers/src/main/java/org/jboss/jpa/spi/XPCResolver.java)
===================================================================
--- projects/jpa/trunk/spi/src/main/java/org/jboss/jpa/spi/XPCResolver.java	                        (rev 0)
+++ projects/jpa/trunk/spi/src/main/java/org/jboss/jpa/spi/XPCResolver.java	2009-10-08 15:11:00 UTC (rev 94522)
@@ -0,0 +1,44 @@
+/*
+ * 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.jpa.spi;
+
+import javax.persistence.EntityManager;
+
+/**
+ * Query the current context for extended persistence contexts.
+ * 
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface XPCResolver
+{
+   /**
+    * Get an extended persistence context within the current context.
+    * 
+    * Note that the full kernel name must be specified to resolve ambiguity
+    * with persistence units in different modules.
+    * 
+    * @param kernelName the identification of the persistence context
+    * @return the extended persistence context or null
+    */
+   EntityManager getExtendedPersistenceContext(String kernelName);
+}




More information about the jboss-cvs-commits mailing list