01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: */package org.apache.geronimo.transaction.manager;
17:
18: import javax.management.j2ee.statistics.Stats;
19: import javax.transaction.xa.XAException;
20: import org.apache.geronimo.management.stats.JTAStatsImpl;
21: import org.apache.geronimo.management.StatisticsProvider;
22:
23: import org.apache.geronimo.gbean.GBeanInfo;
24: import org.apache.geronimo.gbean.GBeanInfoBuilder;
25: import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
26:
27: /**
28: * Used to provide the GBean metadata for the GeronimoTransactionManager class
29: *
30: * @version $Rev: 585537 $ $Date: 2007-10-17 08:31:04 -0700 (Wed, 17 Oct 2007) $
31: */
32: public class GeronimoTransactionManagerGBean extends
33: GeronimoTransactionManager implements StatisticsProvider {
34:
35: JTAStatsImpl stats = new JTAStatsImpl();
36:
37: /**
38: * TODO NOTE!!! this should be called in an unspecified transaction context, but we cannot enforce this restriction!
39: */
40: public GeronimoTransactionManagerGBean(
41: int defaultTransactionTimeoutSeconds,
42: XidFactory xidFactory, TransactionLog transactionLog)
43: throws XAException {
44: super (defaultTransactionTimeoutSeconds == 0 ? DEFAULT_TIMEOUT
45: : defaultTransactionTimeoutSeconds, xidFactory,
46: transactionLog);
47: stats.setStartTime();
48: }
49:
50: public void resetStats() {
51: stats.setStartTime();
52: super .resetStatistics();
53: }
54:
55: public Stats getStats() {
56: try {
57: stats.getActiveCountImpl().setCount(super .getActiveCount());
58: } catch (Exception e) {
59:
60: }
61: stats.getCommittedCountImpl().setCount(super .getTotalCommits());
62: stats.getRolledbackCountImpl().setCount(
63: super .getTotalRollbacks());
64: stats.setLastSampleTime();
65: return stats;
66: }
67:
68: public boolean isStateManageable() {
69: return false;
70: }
71:
72: public boolean isStatisticsProvider() {
73: return true;
74: }
75:
76: public boolean isEventProvider() {
77: return false;
78: }
79:
80: public static final GBeanInfo GBEAN_INFO;
81:
82: static {
83: GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(
84: GeronimoTransactionManagerGBean.class,
85: TransactionManagerImplGBean.GBEAN_INFO,
86: NameFactory.JTA_RESOURCE);
87: GBEAN_INFO = infoFactory.getBeanInfo();
88: }
89:
90: public static GBeanInfo getGBeanInfo() {
91: return GBEAN_INFO;
92: }
93:
94: }
|