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