1 17 18 package org.apache.geronimo.transaction.jta11; 19 20 import java.util.Collection ; 21 import java.util.List ; 22 import java.util.ArrayList ; 23 24 import javax.transaction.xa.XAException ; 25 import javax.transaction.TransactionSynchronizationRegistry ; 26 27 import org.apache.geronimo.transaction.manager.XidFactory; 28 import org.apache.geronimo.transaction.manager.TransactionLog; 29 import org.apache.geronimo.transaction.manager.ResourceManager; 30 import org.apache.geronimo.transaction.manager.TransactionManagerImplGBean; 31 import org.apache.geronimo.transaction.jta11.GeronimoTransactionManagerJTA11; 32 import org.apache.geronimo.gbean.ReferenceCollection; 33 import org.apache.geronimo.gbean.ReferenceCollectionListener; 34 import org.apache.geronimo.gbean.ReferenceCollectionEvent; 35 import org.apache.geronimo.gbean.GBeanInfo; 36 import org.apache.geronimo.gbean.GBeanInfoBuilder; 37 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory; 38 39 42 public class GeronimoTransactionManagerJTA11GBean extends GeronimoTransactionManagerJTA11 { 43 46 public GeronimoTransactionManagerJTA11GBean(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog, Collection resourceManagers) throws XAException { 47 super(defaultTransactionTimeoutSeconds == 0 ? DEFAULT_TIMEOUT : defaultTransactionTimeoutSeconds, 48 xidFactory, 49 transactionLog, 50 resourceManagers); 51 } 52 53 54 60 protected List watchResourceManagers(Collection resourceManagers) { 61 if( resourceManagers instanceof ReferenceCollection ) { 62 List copy; 63 synchronized (resourceManagers) { 64 copy = new ArrayList (resourceManagers); 65 ((ReferenceCollection)resourceManagers).addReferenceCollectionListener(new ReferenceCollectionListener() { 66 public void memberAdded(ReferenceCollectionEvent event) { 67 ResourceManager resourceManager = (ResourceManager) event.getMember(); 68 recoverResourceManager(resourceManager); 69 } 70 71 public void memberRemoved(ReferenceCollectionEvent event) { 72 } 73 74 }); 75 } 76 return copy; 77 } else { 78 return super.watchResourceManagers(resourceManagers); 79 } 80 } 81 82 public static final GBeanInfo GBEAN_INFO; 83 84 static { 85 GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(GeronimoTransactionManagerJTA11GBean.class, 86 TransactionManagerImplGBean.GBEAN_INFO, 87 NameFactory.TRANSACTION_MANAGER); 88 infoBuilder.addInterface(TransactionSynchronizationRegistry .class); 89 90 GBEAN_INFO = infoBuilder.getBeanInfo(); 91 } 92 93 public static GBeanInfo getGBeanInfo() { 94 return GBEAN_INFO; 95 } 96 } 97 | Popular Tags |