Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 46447 invoked from network); 23 Aug 2006 20:37:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 23 Aug 2006 20:37:40 -0000 Received: (qmail 21213 invoked by uid 500); 23 Aug 2006 20:37:39 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 21175 invoked by uid 500); 23 Aug 2006 20:37:38 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 21124 invoked by uid 99); 23 Aug 2006 20:37:38 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Aug 2006 13:37:38 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Aug 2006 13:37:36 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 7DD4E1A981A; Wed, 23 Aug 2006 13:37:16 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: scm@geronimo.apache.org From: djencks@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060823203716.7DD4E1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 @@ - + 4.0.0 @@ -25,12 +26,12 @@ org.apache.geronimo.modules modules 1.2-SNAPSHOT - ../pom.xml + - geronimo-transaction - Geronimo :: Transaction - + geronimo-transaction-jta11 + Geronimo :: Transaction JTA 11 + scm:svn:http://svn.apache.org/repos/asf/geronimo/trunk/modules/transaction - scm:svn:https://${maven.username}@svn.apache.org/repos/asf/geronimo/trunk/modules/transaction + + scm:svn:https://${maven.username}@svn.apache.org/repos/asf/geronimo/trunk/modules/transaction http://svn.apache.org/viewvc/geronimo/trunk/modules/transaction - + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + + - + org.apache.geronimo.modules @@ -68,9 +83,25 @@ + org.apache.geronimo.modules + geronimo-transaction + ${pom.version} + + + org.apache.geronimo.specs - geronimo-jta_1.0.1B_spec + geronimo-jta_1.1_spec + 1.0-SNAPSHOT + + org.apache.geronimo.specs + geronimo-jpa_3.0_spec + 1.0-SNAPSHOT + + + + + org.apache.geronimo.specs @@ -91,8 +122,8 @@ org.objectweb.howl howl - + - + 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 merge(T t) { + return getEntityManager(transactionScoped).merge(t); + } + + public void remove(Object o) { + getEntityManager(transactionScoped).remove(o); + } + + public T find(Class aClass, Object o) { + return getEntityManager(false).find(aClass, o); + } + + public T getReference(Class 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