KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > entity > transaction > DebugXaResource


1 /*
2  * $Id: DebugXaResource.java 6778 2006-02-20 05:13:55Z jonesde $
3  *
4  * Copyright 2004-2006 The Apache Software Foundation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
7  * use this file except in compliance with the License. You may obtain a copy of
8  * the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */

18 package org.ofbiz.entity.transaction;
19
20 import javax.transaction.xa.Xid JavaDoc;
21 import javax.transaction.xa.XAException JavaDoc;
22
23 import org.ofbiz.base.util.Debug;
24
25 /**
26  *
27  * @author <a HREF="mailto:jaz@ofbiz.org">Andy Zeneski</a>
28  * @version $Rev: 6778 $
29  * @since 3.1
30  */

31 public class DebugXaResource extends GenericXaResource {
32
33     public static final String JavaDoc module = DebugXaResource.class.getName();
34     public Exception JavaDoc ex = null;
35
36     public DebugXaResource(String JavaDoc info) {
37         this.ex = new Exception JavaDoc(info);
38     }
39     
40     public DebugXaResource() {
41         this.ex = new Exception JavaDoc();
42     }
43
44     public void commit(Xid JavaDoc xid, boolean onePhase) throws XAException JavaDoc {
45         TransactionUtil.debugResMap.remove(xid);
46         if (Debug.verboseOn()) Debug.logVerbose("Xid : " + xid.toString() + " cleared [commit]", module);
47     }
48
49     public void rollback(Xid JavaDoc xid) throws XAException JavaDoc {
50         TransactionUtil.debugResMap.remove(xid);
51         if (Debug.verboseOn()) Debug.logVerbose("Xid : " + xid.toString() + " cleared [rollback]", module);
52     }
53
54     public void enlist() throws XAException JavaDoc {
55         super.enlist();
56         TransactionUtil.debugResMap.put(xid, this);
57     }
58
59     public void log() {
60         Debug.log("Xid : " + xid, module);
61         Debug.log(ex, module);
62     }
63 }
64
Popular Tags