001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: JTAResource.java 6487 2005-03-30 17:20:15Z tonyortiz $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.jtm;
025:
026: // JOnAS imports
027: import org.objectweb.jonas.management.j2eemanagement.J2EEResource;
028: import org.objectweb.jonas.management.ReconfiguredProp;
029:
030: import javax.transaction.xa.Xid;
031:
032: /**
033: * MBean class for JTAResource Management
034: * @author Eric Hardesty JSR 77 (J2EE Management Standard)
035: */
036: public class JTAResource extends J2EEResource {
037:
038: /**
039: * Service name as used to label configuration properties
040: */
041: public static final String SERVICE_NAME = "jtm";
042:
043: // Transaction Service configuration properties
044: /**
045: * name of the 'timeout' configuration parameter
046: */
047: static final String TIMEOUT = "jonas.service.jtm.timeout";
048:
049: /**
050: * Value used as sequence number by reconfiguration notifications
051: */
052: private long sequenceNumber = 0;
053:
054: /**
055: * Transactions time-out
056: */
057: private Integer timeOut;
058:
059: /**
060: * JTM port number
061: */
062: private Integer portNumber;
063:
064: /**
065: * JTM host name
066: */
067: private String hostName;
068:
069: /**
070: * true if JTM is local, false if remote
071: */
072: private Boolean localJtm;
073:
074: /**
075: * Managed JTM
076: */
077: private TransactionServiceImpl jtm;
078:
079: /**
080: * JTA Resource constructor
081: * @param objectName String conformant to a JTAResource OBJECT_NAME in JSR77
082: * @param jtm Managed JTM
083: * @param timeOut transactions time-out
084: * @param localJtm true if JTM is local, false if remote
085: * @param portNumber JTM port number
086: * @param hostName JTM host name
087: */
088: public JTAResource(String objectName, TransactionServiceImpl jtm,
089: Integer timeOut, Boolean localJtm, Integer portNumber,
090: String hostName) {
091: super (objectName);
092: this .jtm = jtm;
093: this .timeOut = timeOut;
094: this .localJtm = localJtm;
095: this .portNumber = portNumber;
096: this .hostName = hostName;
097: }
098:
099: /**
100: * @return Returns the timeOut.
101: */
102: public Integer getTimeOut() {
103: return timeOut;
104: }
105:
106: /**
107: * @param timeOut The timeOut to set.
108: */
109: public void setTimeOut(Integer timeOut) {
110: this .timeOut = timeOut;
111: jtm.setTimeout(timeOut.intValue());
112: // Send a notification containing the new value of this property to the
113: // listner MBean
114: sendReconfigNotification(++sequenceNumber, SERVICE_NAME,
115: new ReconfiguredProp(TIMEOUT, timeOut.toString()));
116: }
117:
118: /**
119: * @return true if JTM is local, false if remote
120: */
121: public Boolean isLocalJtm() {
122: return localJtm;
123: }
124:
125: /**
126: * @return JTM port number
127: */
128: public Integer getPortNumber() {
129: return portNumber;
130: }
131:
132: /**
133: * @return JTM host name
134: */
135: public String 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 getTotalBegunTransactions() {
150: return new Integer(jtm.getTotalBegunTransactions());
151: }
152:
153: /**
154: * @return Returns the totalCommittedTransactions.
155: */
156: public Integer getTotalCommittedTransactions() {
157: return new Integer(jtm.getTotalCommittedTransactions());
158: }
159:
160: /**
161: * @return Returns the totalCurrentTransactions.
162: */
163: public Integer getTotalCurrentTransactions() {
164: return new Integer(jtm.getTotalCurrentTransactions());
165: }
166:
167: /**
168: * @return Returns the totalExpiredTransactions.
169: */
170: public Integer getTotalExpiredTransactions() {
171: return new Integer(jtm.getTotalExpiredTransactions());
172: }
173:
174: /**
175: * @return Returns the totalRolledbackTransactions.
176: */
177: public Integer getTotalRolledbackTransactions() {
178: return new Integer(jtm.getTotalRolledbackTransactions());
179: }
180:
181: /**
182: * Reset all transaction counters
183: */
184: public void resetAllCounters() {
185: jtm.resetAllTxTotalCounters();
186: }
187:
188: /**
189: * @return Returns all active Xids.
190: */
191: public Xid[] getAllActiveXids() {
192: return jtm.getAllActiveXids();
193: }
194:
195: /**
196: * @return Returns all active Transactions.
197: */
198: public String[] getAllActiveTx() {
199: String[] mysArray;
200:
201: mysArray = jtm.getAllActiveTx();
202: return mysArray;
203: }
204:
205: /**
206: * @return Returns all Transactions that require administrator recovery action.
207: */
208: public String[] getAllRecoveryTx() {
209: String[] mysArray;
210:
211: mysArray = jtm.getAllRecoveryTx();
212: return mysArray;
213: }
214:
215: /**
216: * @return Returns all XAResources that require administrator recovery action.
217: */
218: public String[] getAllXAResource(String xatx) {
219: String[] mysArray;
220: mysArray = jtm.getAllXAResource(xatx);
221: return mysArray;
222: }
223:
224: /**
225: * @return Returns all XAResources that require administrator recovery action.
226: */
227: public int commitXAResource(String xatx) {
228: int commiterror;
229: commiterror = jtm.commitXAResource(xatx);
230: return commiterror;
231: }
232:
233: /**
234: * @return Returns all XAResources that require administrator recovery action.
235: */
236: public int rollbackXAResource(String xatx) {
237: int rollbackerror;
238: rollbackerror = jtm.rollbackXAResource(xatx);
239: return rollbackerror;
240: }
241:
242: /**
243: * @return Returns all XAResources that require administrator recovery action.
244: */
245: public int forgetXAResource(String xatx) {
246: int forgeterror;
247: forgeterror = jtm.forgetXAResource(xatx);
248: return forgeterror;
249: }
250: }
|