geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r434167 - in /geronimo/sandbox/jee5-jta: ./ transaction/ transaction/src/java/org/apache/geronimo/transaction/ transaction/src/java/org/apache/geronimo/transaction/jpa/ transaction/src/java/org/apache/geronimo/transaction/jta11/ transaction...
Date Wed, 23 Aug 2006 20:37:15 GMT
Author: djencks
Date: Wed Aug 23 13:37:14 2006
New Revision: 434167

URL: http://svn.apache.org/viewvc?rev=434167&view=rev
Log:
switch to extending the j2ee 1.4 classes

Added:
    geronimo/sandbox/jee5-jta/
    geronimo/sandbox/jee5-jta/transaction/
      - copied from r433180, geronimo/trunk/modules/transaction/
    geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jpa/
    geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jpa/CMPEntityManager.java
  (with props)
    geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jta11/
    geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11.java
  (with props)
    geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11GBean.java
  (with props)
Removed:
    geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/GeronimoUserTransaction.java
    geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/log/
    geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/manager/
    geronimo/sandbox/jee5-jta/transaction/src/test/org/apache/geronimo/transaction/
Modified:
    geronimo/sandbox/jee5-jta/transaction/pom.xml

Modified: geronimo/sandbox/jee5-jta/transaction/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jee5-jta/transaction/pom.xml?rev=434167&r1=433180&r2=434167&view=diff
==============================================================================
--- geronimo/sandbox/jee5-jta/transaction/pom.xml (original)
+++ geronimo/sandbox/jee5-jta/transaction/pom.xml Wed Aug 23 13:37:14 2006
@@ -17,7 +17,8 @@
 
 <!-- $Rev$ $Date$ -->
 
-<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">
+<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">
 
     <modelVersion>4.0.0</modelVersion>
 
@@ -25,12 +26,12 @@
         <groupId>org.apache.geronimo.modules</groupId>
         <artifactId>modules</artifactId>
         <version>1.2-SNAPSHOT</version>
-        <relativePath>../pom.xml</relativePath>
+        <!--<relativePath>../pom.xml</relativePath>-->
     </parent>
 
-    <artifactId>geronimo-transaction</artifactId>
-    <name>Geronimo :: Transaction</name>
-    
+    <artifactId>geronimo-transaction-jta11</artifactId>
+    <name>Geronimo :: Transaction JTA 11</name>
+
     <!--
     
     HACK: Need to explicitly configure SCM for this module since its artifactId
@@ -41,12 +42,26 @@
     -->
     <scm>
         <connection>scm:svn:http://svn.apache.org/repos/asf/geronimo/trunk/modules/transaction</connection>
-        <developerConnection>scm:svn:https://${maven.username}@svn.apache.org/repos/asf/geronimo/trunk/modules/transaction</developerConnection>
+        <developerConnection>
+            scm:svn:https://${maven.username}@svn.apache.org/repos/asf/geronimo/trunk/modules/transaction</developerConnection>
         <url>http://svn.apache.org/viewvc/geronimo/trunk/modules/transaction</url>
     </scm>
-    
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.5</source>
+                    <target>1.5</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
     <dependencies>
-    
+
         <!-- temp, for ServerInfo. Remove when it is moved to Kernel-->
         <dependency>
             <groupId>org.apache.geronimo.modules</groupId>
@@ -68,9 +83,25 @@
         </dependency>
 
         <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-transaction</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+
+        <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-jta_1.0.1B_spec</artifactId>
+            <artifactId>geronimo-jta_1.1_spec</artifactId>
+            <version>1.0-SNAPSHOT</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jpa_3.0_spec</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <!--<dependency>-->
+        <!--<groupId>org.apache.geronimo.specs</groupId>-->
+        <!--<artifactId>geronimo-jta_1.0.1B_spec</artifactId>-->
+        <!--</dependency>-->
 
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
@@ -91,8 +122,8 @@
             <groupId>org.objectweb.howl</groupId>
             <artifactId>howl</artifactId>
         </dependency>
-        
+
     </dependencies>
-    
+
 </project>
 

Added: geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jpa/CMPEntityManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jpa/CMPEntityManager.java?rev=434167&view=auto
==============================================================================
--- geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jpa/CMPEntityManager.java
(added)
+++ geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jpa/CMPEntityManager.java
Wed Aug 23 13:37:14 2006
@@ -0,0 +1,184 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.transaction.jpa;
+
+import java.util.Map;
+
+import javax.persistence.EntityManager;
+import javax.persistence.FlushModeType;
+import javax.persistence.LockModeType;
+import javax.persistence.Query;
+import javax.persistence.EntityTransaction;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.TransactionRequiredException;
+import javax.transaction.Status;
+
+import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
+import org.apache.geronimo.transaction.manager.TransactionImpl;
+import org.apache.geronimo.transaction.manager.Closeable;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class CMPEntityManager implements EntityManager {
+
+    private final TransactionManagerImpl transactionManager;
+    private final String persistenceUnit;
+    private final EntityManagerFactory entityManagerFactory;
+    private final Map entityManagerProperties;
+    private final boolean transactionScoped;
+
+    public CMPEntityManager(TransactionManagerImpl transactionManager, String persistenceUnit,
EntityManagerFactory entityManagerFactory, Map entityManagerProperties, boolean transactionScoped)
{
+        this.transactionManager = transactionManager;
+        this.persistenceUnit = persistenceUnit;
+        this.entityManagerFactory = entityManagerFactory;
+        this.entityManagerProperties = entityManagerProperties;
+        this.transactionScoped = transactionScoped;
+    }
+
+    private EntityManager getEntityManager(boolean activeRequired) {
+        TransactionImpl transaction = (TransactionImpl) transactionManager.getTransaction();
+        if (transaction == null || (activeRequired && transaction.getStatus() !=
Status.STATUS_ACTIVE)) {
+            throw new TransactionRequiredException("No active transaction");
+        }
+        EntityManagerWrapper entityManagerWrapper = (EntityManagerWrapper) transaction.getEntityManager(persistenceUnit);
+        if (entityManagerWrapper == null) {
+            EntityManager entityManager;
+            if (entityManagerProperties == null) {
+                entityManager = entityManagerFactory.createEntityManager();
+            } else {
+                entityManager = entityManagerFactory.createEntityManager(entityManagerProperties);
+            }
+            entityManagerWrapper =new EntityManagerWrapper(entityManager, transactionScoped);
+            transaction.setEntityManager(persistenceUnit, entityManagerWrapper);
+        }
+        return entityManagerWrapper.getEntityManager();
+    }
+
+
+    public void persist(Object o) {
+        getEntityManager(transactionScoped).persist(o);
+    }
+
+    public <T>T merge(T t) {
+        return getEntityManager(transactionScoped).merge(t);
+    }
+
+    public void remove(Object o) {
+        getEntityManager(transactionScoped).remove(o);
+    }
+
+    public <T>T find(Class<T> aClass, Object o) {
+        return getEntityManager(false).find(aClass, o);
+    }
+
+    public <T>T getReference(Class<T> aClass, Object o) {
+        return getEntityManager(false).getReference(aClass, o);
+    }
+
+    public void flush() {
+        getEntityManager(false).flush();
+    }
+
+    public void setFlushMode(FlushModeType flushModeType) {
+        getEntityManager(false).setFlushMode(flushModeType);
+    }
+
+    public FlushModeType getFlushMode() {
+        return getEntityManager(false).getFlushMode();
+    }
+
+    public void lock(Object o, LockModeType lockModeType) {
+        getEntityManager(false).lock(o, lockModeType);
+    }
+
+    public void refresh(Object o) {
+        getEntityManager(transactionScoped).refresh(o);
+    }
+
+    public void clear() {
+        getEntityManager(false).clear();
+    }
+
+    public boolean contains(Object o) {
+        return getEntityManager(false).contains(o);
+    }
+
+    public Query createQuery(String s) {
+        return getEntityManager(false).createQuery(s);
+    }
+
+    public Query createNamedQuery(String s) {
+        return getEntityManager(false).createNamedQuery(s);
+    }
+
+    public Query createNativeQuery(String s) {
+        return getEntityManager(false).createNativeQuery(s);
+    }
+
+    public Query createNativeQuery(String s, Class aClass) {
+        return getEntityManager(false).createNativeQuery(s, aClass);
+    }
+
+    public Query createNativeQuery(String s, String s1) {
+        return getEntityManager(false).createNativeQuery(s, s1);
+    }
+
+    public void close() {
+        throw new IllegalStateException("You cannot call close on a Container Managed Entity
Manager");
+    }
+
+    public boolean isOpen() {
+        return getEntityManager(false).isOpen();
+    }
+
+    public EntityTransaction getTransaction() {
+        return getEntityManager(false).getTransaction();
+    }
+
+    public void joinTransaction() {
+        getEntityManager(false).joinTransaction();
+    }
+
+    public Object getDelegate() {
+        return getEntityManager(false).getDelegate();
+    }
+
+    private static class EntityManagerWrapper implements Closeable {
+        private final EntityManager entityManager;
+        private final boolean transactionScoped;
+
+        public EntityManagerWrapper(EntityManager entityManager, boolean transactionScoped)
{
+            if (entityManager == null) {
+                throw new IllegalArgumentException("Need a non-null entity manager");
+            }
+            this.entityManager = entityManager;
+            this.transactionScoped = transactionScoped;
+        }
+
+        public void close() {
+            if (transactionScoped) {
+                entityManager.close();
+            }
+        }
+
+        public EntityManager getEntityManager() {
+            return entityManager;
+        }
+    }
+}

Propchange: geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jpa/CMPEntityManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jpa/CMPEntityManager.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jpa/CMPEntityManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11.java?rev=434167&view=auto
==============================================================================
--- geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11.java
(added)
+++ geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11.java
Wed Aug 23 13:37:14 2006
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.transaction.jta11;
+
+import java.util.Collection;
+
+import javax.transaction.TransactionSynchronizationRegistry;
+import javax.transaction.xa.XAException;
+
+import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
+import org.apache.geronimo.transaction.manager.TransactionLog;
+import org.apache.geronimo.transaction.manager.XidFactory;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class GeronimoTransactionManagerJTA11 extends GeronimoTransactionManager implements
TransactionSynchronizationRegistry {
+    public GeronimoTransactionManagerJTA11() throws XAException {
+    }
+
+    public GeronimoTransactionManagerJTA11(int defaultTransactionTimeoutSeconds) throws XAException
{
+        super(defaultTransactionTimeoutSeconds);
+    }
+
+    public GeronimoTransactionManagerJTA11(int defaultTransactionTimeoutSeconds, TransactionLog
transactionLog) throws XAException {
+        super(defaultTransactionTimeoutSeconds, transactionLog);
+    }
+
+    public GeronimoTransactionManagerJTA11(int defaultTransactionTimeoutSeconds, XidFactory
xidFactory, TransactionLog transactionLog, Collection resourceManagers) throws XAException
{
+        super(defaultTransactionTimeoutSeconds, xidFactory, transactionLog, resourceManagers);
+    }
+
+}

Propchange: geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11GBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11GBean.java?rev=434167&view=auto
==============================================================================
--- geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11GBean.java
(added)
+++ geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11GBean.java
Wed Aug 23 13:37:14 2006
@@ -0,0 +1,96 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.transaction.jta11;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.ArrayList;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.TransactionSynchronizationRegistry;
+
+import org.apache.geronimo.transaction.manager.XidFactory;
+import org.apache.geronimo.transaction.manager.TransactionLog;
+import org.apache.geronimo.transaction.manager.ResourceManager;
+import org.apache.geronimo.transaction.manager.TransactionManagerImplGBean;
+import org.apache.geronimo.transaction.jta11.GeronimoTransactionManagerJTA11;
+import org.apache.geronimo.gbean.ReferenceCollection;
+import org.apache.geronimo.gbean.ReferenceCollectionListener;
+import org.apache.geronimo.gbean.ReferenceCollectionEvent;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class GeronimoTransactionManagerJTA11GBean extends GeronimoTransactionManagerJTA11
{
+    /**
+     * TODO NOTE!!! this should be called in an unspecified transaction context, but we cannot
enforce this restriction!
+     */
+    public GeronimoTransactionManagerJTA11GBean(int defaultTransactionTimeoutSeconds, XidFactory
xidFactory, TransactionLog transactionLog, Collection resourceManagers) throws XAException
{
+        super(defaultTransactionTimeoutSeconds == 0 ? DEFAULT_TIMEOUT : defaultTransactionTimeoutSeconds,
+                xidFactory,
+                transactionLog,
+                resourceManagers);
+    }
+
+
+    /**
+     * We can track as resources are added into the geronimo kernel.
+     *
+     * @param resourceManagers
+     * @return the original list of resources.
+     */
+    protected List watchResourceManagers(Collection resourceManagers) {
+        if( resourceManagers instanceof ReferenceCollection ) {
+            List copy;
+            synchronized (resourceManagers) {
+                copy = new ArrayList(resourceManagers);
+                    ((ReferenceCollection)resourceManagers).addReferenceCollectionListener(new
ReferenceCollectionListener() {
+                    public void memberAdded(ReferenceCollectionEvent event) {
+                        ResourceManager resourceManager = (ResourceManager) event.getMember();
+                        recoverResourceManager(resourceManager);
+                    }
+
+                    public void memberRemoved(ReferenceCollectionEvent event) {
+                    }
+
+                });
+            }
+            return copy;
+        } else {
+            return super.watchResourceManagers(resourceManagers);
+        }
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(GeronimoTransactionManagerJTA11GBean.class,
+                TransactionManagerImplGBean.GBEAN_INFO,
+                NameFactory.TRANSACTION_MANAGER);
+        infoBuilder.addInterface(TransactionSynchronizationRegistry.class);
+
+        GBEAN_INFO = infoBuilder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Propchange: geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11GBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11GBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/jee5-jta/transaction/src/java/org/apache/geronimo/transaction/jta11/GeronimoTransactionManagerJTA11GBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message