KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtm > JTAResource


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: JTAResource.java,v 1.5 2005/03/30 17:19:12 tonyortiz Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jtm;
27
28 // JOnAS imports
29
import org.objectweb.jonas.management.j2eemanagement.J2EEResource;
30 import org.objectweb.jonas.management.ReconfiguredProp;
31
32 import javax.transaction.xa.Xid JavaDoc;
33
34 /**
35  * MBean class for JTAResource Management
36  * @author Eric Hardesty JSR 77 (J2EE Management Standard)
37  */

38 public class JTAResource extends J2EEResource {
39
40     /**
41      * Service name as used to label configuration properties
42      */

43     public static final String JavaDoc SERVICE_NAME = "jtm";
44
45     // Transaction Service configuration properties
46
/**
47      * name of the 'timeout' configuration parameter
48      */

49     static final String JavaDoc TIMEOUT = "jonas.service.jtm.timeout";
50
51     /**
52      * Value used as sequence number by reconfiguration notifications
53      */

54     private long sequenceNumber = 0;
55
56     /**
57      * Transactions time-out
58      */

59     private Integer JavaDoc timeOut;
60
61     /**
62      * JTM port number
63      */

64     private Integer JavaDoc portNumber;
65
66     /**
67      * JTM host name
68      */

69     private String JavaDoc hostName;
70
71     /**
72      * true if JTM is local, false if remote
73      */

74     private Boolean JavaDoc localJtm;
75
76     /**
77      * Managed JTM
78      */

79     private TransactionServiceImpl jtm;
80
81     /**
82      * JTA Resource constructor
83      * @param objectName String conformant to a JTAResource OBJECT_NAME in JSR77
84      * @param jtm Managed JTM
85      * @param timeOut transactions time-out
86      * @param localJtm true if JTM is local, false if remote
87      * @param portNumber JTM port number
88      * @param hostName JTM host name
89      */

90     public JTAResource(String JavaDoc objectName, TransactionServiceImpl jtm, Integer JavaDoc timeOut, Boolean JavaDoc localJtm,
91             Integer JavaDoc portNumber, String JavaDoc hostName) {
92         super(objectName);
93         this.jtm = jtm;
94         this.timeOut = timeOut;
95         this.localJtm = localJtm;
96         this.portNumber = portNumber;
97         this.hostName = hostName;
98     }
99
100     /**
101      * @return Returns the timeOut.
102      */

103     public Integer JavaDoc getTimeOut() {
104         return timeOut;
105     }
106
107     /**
108      * @param timeOut The timeOut to set.
109      */

110     public void setTimeOut(Integer JavaDoc timeOut) {
111         this.timeOut = timeOut;
112         jtm.setTimeout(timeOut.intValue());
113         // Send a notification containing the new value of this property to the
114
// listner MBean
115
sendReconfigNotification(++sequenceNumber, SERVICE_NAME, new ReconfiguredProp(TIMEOUT, timeOut.toString()));
116     }
117
118     /**
119      * @return true if JTM is local, false if remote
120      */

121     public Boolean JavaDoc isLocalJtm() {
122         return localJtm;
123     }
124
125     /**
126      * @return JTM port number
127      */

128     public Integer JavaDoc getPortNumber() {
129         return portNumber;
130     }
131
132     /**
133      * @return JTM host name
134      */

135     public String JavaDoc getHostName() {
136         return hostName;
137     }
138
139     /**
140      * Save updated configuration
141      */

142     public void saveConfig() {
143         sendSaveNotification(++sequenceNumber, SERVICE_NAME);
144     }
145
146     /**
147      * @return Returns the totalBegunTransactions.
148      */

149     public Integer JavaDoc getTotalBegunTransactions() {
150         return new Integer JavaDoc(jtm.getTotalBegunTransactions());
151     }
152     /**
153      * @return Returns the totalCommittedTransactions.
154      */

155     public Integer JavaDoc getTotalCommittedTransactions() {
156         return new Integer JavaDoc(jtm.getTotalCommittedTransactions());
157     }
158     /**
159      * @return Returns the totalCurrentTransactions.
160      */

161     public Integer JavaDoc getTotalCurrentTransactions() {
162         return new Integer JavaDoc(jtm.getTotalCurrentTransactions());
163     }
164     /**
165      * @return Returns the totalExpiredTransactions.
166      */

167     public Integer JavaDoc getTotalExpiredTransactions() {
168         return new Integer JavaDoc(jtm.getTotalExpiredTransactions());
169     }
170     /**
171      * @return Returns the totalRolledbackTransactions.
172      */

173     public Integer JavaDoc getTotalRolledbackTransactions() {
174         return new Integer JavaDoc(jtm.getTotalRolledbackTransactions());
175     }
176     /**
177      * Reset all transaction counters
178      */

179     public void resetAllCounters() {
180         jtm.resetAllTxTotalCounters();
181     }
182
183     /**
184      * @return Returns all active Xids.
185      */

186     public Xid JavaDoc[] getAllActiveXids() {
187         return jtm.getAllActiveXids();
188     }
189
190     /**
191      * @return Returns all active Transactions.
192      */

193     public String JavaDoc [] getAllActiveTx() {
194         String JavaDoc [] mysArray;
195
196         mysArray = jtm.getAllActiveTx();
197         return mysArray;
198     }
199
200     /**
201      * @return Returns all Transactions that require administrator recovery action.
202      */

203     public String JavaDoc [] getAllRecoveryTx() {
204         String JavaDoc [] mysArray;
205
206         mysArray = jtm.getAllRecoveryTx();
207         return mysArray;
208     }
209
210     /**
211      * @return Returns all XAResources that require administrator recovery action.
212      */

213     public String JavaDoc [] getAllXAResource(String JavaDoc xatx) {
214         String JavaDoc [] mysArray;
215         mysArray = jtm.getAllXAResource(xatx);
216         return mysArray;
217     }
218     
219     /**
220      * @return Returns all XAResources that require administrator recovery action.
221      */

222     public int commitXAResource(String JavaDoc xatx) {
223         int commiterror;
224         commiterror = jtm.commitXAResource(xatx);
225         return commiterror;
226     }
227     
228     /**
229      * @return Returns all XAResources that require administrator recovery action.
230      */

231     public int rollbackXAResource(String JavaDoc xatx) {
232         int rollbackerror;
233         rollbackerror = jtm.rollbackXAResource(xatx);
234         return rollbackerror;
235     }
236     
237     /**
238      * @return Returns all XAResources that require administrator recovery action.
239      */

240     public int forgetXAResource(String JavaDoc xatx) {
241         int forgeterror;
242         forgeterror = jtm.forgetXAResource(xatx);
243         return forgeterror;
244     }
245 }
Popular Tags