KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > transaction > manager > GeronimoTransactionManagerGBean


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.transaction.manager;
19
20 import java.util.ArrayList JavaDoc;
21 import java.util.Collection JavaDoc;
22 import java.util.List JavaDoc;
23 import javax.transaction.xa.XAException JavaDoc;
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 /**
33  * Used to provide the GBean metadata for the GeronimoTransactionManager class
34  *
35  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
36  */

37 public class GeronimoTransactionManagerGBean extends GeronimoTransactionManager {
38
39     /**
40      * TODO NOTE!!! this should be called in an unspecified transaction context, but we cannot enforce this restriction!
41      */

42     public GeronimoTransactionManagerGBean(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog, Collection JavaDoc resourceManagers) throws XAException JavaDoc {
43         super(defaultTransactionTimeoutSeconds == 0 ? DEFAULT_TIMEOUT : defaultTransactionTimeoutSeconds,
44                 xidFactory,
45                 transactionLog,
46                 resourceManagers);
47     }
48
49
50     /**
51      * We can track as resources are added into the geronimo kernel.
52      *
53      * @param resourceManagers
54      * @return the original list of resources.
55      */

56     protected List JavaDoc watchResourceManagers(Collection JavaDoc resourceManagers) {
57         if( resourceManagers instanceof ReferenceCollection ) {
58             List JavaDoc copy;
59             synchronized (resourceManagers) {
60                 copy = new ArrayList JavaDoc(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