KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > tm > TransactionManagerService


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.tm;
23
24 import javax.management.ObjectName JavaDoc;
25 import javax.transaction.TransactionManager JavaDoc;
26
27 import org.jboss.system.ServiceMBeanSupport;
28 import org.jboss.tm.integrity.TransactionIntegrityFactory;
29 import org.jboss.tm.recovery.RecoveryLogger;
30 import org.jboss.tm.recovery.RecoveryLoggerInstance;
31
32 /**
33  * This is a JMX service which manages the TransactionManager.
34  * The service creates it and binds a Reference to it into JNDI.
35  *
36  * @see TxManager
37  * @author <a HREF="mailto:rickard.oberg@telkel.com">Rickard Oberg</a>
38  * @author <a HREF="mailto:osh@sparre.dk">Ole Husgaard</a>
39  * @author <a HREF="mailto:toby.allsopp@peace.com">Toby Allsopp</a>
40  * @author <a HREF="reverbel@ime.usp.br">Francisco Reverbel</a>
41  * @version $Revision: 37459 $
42  *
43  * @jmx.mbean extends="org.jboss.system.ServiceMBean"
44  */

45 public class TransactionManagerService
46       extends ServiceMBeanSupport
47       implements TransactionManagerServiceMBean
48 {
49    private ObjectName JavaDoc xidFactory;
50
51    private TransactionManagerInitializer initializer = new TransactionManagerInitializer();
52    
53    // Constants -----------------------------------------------------
54
public static String JavaDoc JNDI_NAME = "java:/TransactionManager";
55    public static String JavaDoc JNDI_IMPORTER = "java:/TransactionPropagationContextImporter";
56    public static String JavaDoc JNDI_EXPORTER = "java:/TransactionPropagationContextExporter";
57
58    protected void startService()
59          throws Exception JavaDoc
60    {
61       XidFactoryMBean xidFactoryObj = (XidFactoryMBean) getServer().getAttribute(xidFactory, "Instance");
62       initializer.setXidFactory(xidFactoryObj);
63       initializer.start();
64    }
65
66    protected void stopService()
67    {
68       initializer.stop();
69    }
70
71    /**
72     * Set the Recover logger
73     *
74     * @param recoveryLogger
75     * @jmx:managed-attribute
76     */

77    public void setRecoveryLogger(RecoveryLoggerInstance recoveryLogger)
78    {
79       initializer.setRecoveryLogger(recoveryLogger.getInstance());
80    }
81
82    /**
83     * Set the Transaction integrity factory
84     *
85     * @param factory the factory
86     */

87    public void setTransactionIntegrityFactory(TransactionIntegrityFactory factory)
88    {
89       initializer.setTransactionIntegrityFactory(factory);
90    }
91
92    /**
93     * mbean get-set pair for field xidFactory
94     * Get the value of xidFactory
95     * @return value of xidFactory
96     *
97     * @jmx:managed-attribute
98     */

99    public ObjectName JavaDoc getXidFactory()
100    {
101       return xidFactory;
102    }
103
104    /**
105     * Set the value of xidFactory
106     * @param xidFactory Value to assign to xidFactory
107     *
108     * @jmx:managed-attribute
109     */

110    public void setXidFactory(ObjectName JavaDoc xidFactory)
111    {
112       this.xidFactory = xidFactory;
113    }
114
115    public void setRecoveryLogger(RecoveryLogger recoveryLogger)
116    {
117       initializer.setRecoveryLogger(recoveryLogger);
118    }
119
120    public boolean getGlobalIdsEnabled()
121    {
122       return initializer.getGlobalIdsEnabled();
123    }
124
125    public void setGlobalIdsEnabled(boolean newValue)
126    {
127       initializer.setGlobalIdsEnabled(newValue);
128    }
129
130    public boolean isInterruptThreads()
131    {
132       return initializer.isInterruptThreads();
133    }
134
135    public void setInterruptThreads(boolean interruptThreads)
136    {
137       initializer.setInterruptThreads(interruptThreads);
138    }
139
140    public int getTransactionTimeout()
141    {
142       return initializer.getTransactionTimeout();
143    }
144
145    public void setTransactionTimeout(int timeout)
146    {
147       initializer.setTransactionTimeout(timeout);
148    }
149
150    public int getCompletionRetryLimit()
151    {
152       return initializer.getCompletionRetryLimit();
153    }
154
155    public void setCompletionRetryLimit(int limit)
156    {
157       initializer.setCompletionRetryLimit(limit);
158    }
159    
160    public int getCompletionRetryTimeout()
161    {
162       return initializer.getCompletionRetryTimeout();
163    }
164
165    public void setCompletionRetryTimeout(int timeout)
166    {
167       initializer.setCompletionRetryTimeout(timeout);
168    }
169    
170    public int getXARetryTimeout()
171    {
172       return initializer.getXARetryTimeout();
173    }
174
175    public void setXARetryTimeout(int timeout)
176    {
177       initializer.setXARetryTimeout(timeout);
178    }
179
180    public int getPreparedTimeout()
181    {
182       return initializer.getPreparedTimeout();
183    }
184
185    public void setPreparedTimeout(int timeout)
186    {
187       initializer.setPreparedTimeout(timeout);
188    }
189    
190    public boolean isRootBranchRemembersHeuristicDecisions()
191    {
192       return initializer.isRootBranchRemembersHeuristicDecisions();
193    }
194
195    public void setRootBranchRemembersHeuristicDecisions(boolean newValue)
196    {
197       initializer.setRootBranchRemembersHeuristicDecisions(newValue);
198    }
199
200    public boolean isReportHeuristicHazardAsHeuristicMixed()
201    {
202       return initializer.isReportHeuristicHazardAsHeuristicMixed();
203    }
204
205    public void setReportHeuristicHazardAsHeuristicMixed(boolean newValue)
206    {
207       initializer.setReportHeuristicHazardAsHeuristicMixed(newValue);
208    }
209
210    public TransactionManager JavaDoc getTransactionManager()
211    {
212       return initializer.getTransactionManager();
213    }
214
215    public JBossXATerminator getXATerminator()
216    {
217       return initializer.getXATerminator();
218    }
219
220    public long getTransactionCount()
221    {
222       return initializer.getTransactionCount();
223    }
224
225    public long getCommitCount()
226    {
227       return initializer.getCommitCount();
228    }
229
230    public long getRollbackCount()
231    {
232       return initializer.getRollbackCount();
233    }
234
235    public String JavaDoc listInDoubtTransactions()
236    {
237       return initializer.listInDoubtTransactions();
238    }
239    
240    public void heuristicallyCommit(long localTransactionId)
241    {
242       initializer.heuristicallyCommit(localTransactionId);
243    }
244    
245    public void heuristicallyCommitAll()
246    {
247       initializer.heuristicallyCommitAll();
248    }
249    
250    public void heuristicallyRollback(long localTransactionId)
251    {
252       initializer.heuristicallyRollback(localTransactionId);
253    }
254    
255    public void heuristicallyRollbackAll()
256    {
257       initializer.heuristicallyRollbackAll();
258    }
259    
260    public String JavaDoc listHeuristicallyCompletedTransactions()
261    {
262       return initializer.listHeuristicallyCompletedTransactions();
263    }
264    
265    public void forget(long localTransactionId)
266    {
267       initializer.forget(localTransactionId);
268    }
269    
270    public void forgetAll()
271    {
272       initializer.forgetAll();
273    }
274    
275    public void registerXAExceptionFormatter(Class JavaDoc clazz, XAExceptionFormatter formatter)
276    {
277       initializer.registerXAExceptionFormatter(clazz, formatter);
278    }
279
280    public void unregisterXAExceptionFormatter(Class JavaDoc clazz)
281    {
282       initializer.unregisterXAExceptionFormatter(clazz);
283    }
284 }
285
Popular Tags