KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > transaction > XAResourceWrapper


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.transaction;
25
26 import javax.sql.*;
27 import javax.transaction.xa.*;
28 import javax.security.auth.Subject JavaDoc;
29 import javax.resource.spi.ManagedConnection JavaDoc;
30
31 import com.sun.enterprise.util.i18n.StringManager;
32
33 /**
34  * Wrappers over XAResources extend from this class. This class simply implements the
35  * the standard XAResource interface. In addition it holds the XAConnection which is
36  * set by XARecoveryManager and is used by deriving classes to implement workarounds.
37  * An example of class extending from this is OracleXARescource.
38  *
39  * @author <a HREF="mailto:bala.dutt@sun.com">Bala Dutt</a>
40  * @version 1.0
41  */

42 public abstract class XAResourceWrapper implements XAResource
43 {
44
45     /// Sting Manager for Localization
46
private static StringManager sm = StringManager.getManager(XAResourceWrapper.class);
47
48     protected ManagedConnection JavaDoc m_xacon;
49     protected Subject JavaDoc subject;
50     public void init(ManagedConnection JavaDoc xacon,Subject JavaDoc subject){
51         m_xacon=xacon;
52         this.subject = subject;
53     }
54     public void end(Xid xid, int i) throws XAException{
55         throw new XAException(sm.getString("transaction.for_recovery_only"));
56     }
57     public void forget(Xid xid) throws XAException{
58         throw new XAException(sm.getString("transaction.for_recovery_only"));
59     }
60     public int getTransactionTimeout() throws XAException{
61         throw new XAException(sm.getString("transaction.for_recovery_only"));
62     }
63     public boolean isSameRM(XAResource xaresource) throws XAException
64     {
65         throw new XAException(sm.getString("transaction.for_recovery_only"));
66     }
67     public int prepare(Xid xid) throws XAException{
68         throw new XAException(sm.getString("transaction.for_recovery_only"));
69     }
70     public boolean setTransactionTimeout(int i) throws XAException {
71         throw new XAException(sm.getString("transaction.for_recovery_only"));
72     }
73     public void start(Xid xid, int i) throws XAException{
74         throw new XAException(sm.getString("transaction.for_recovery_only"));
75     }
76
77     public abstract Xid[] recover(int flag) throws XAException;
78
79     public abstract void commit(Xid xid, boolean flag) throws XAException;
80
81     public abstract void rollback(Xid xid) throws XAException;
82
83     /**
84     public Xid[] recover(int flag) throws XAException {
85         throw new XAException("This is to be implemented by sub classes");
86     }
87     public void commit(Xid xid, boolean flag) throws XAException{
88         throw new XAException("This is to be implemented by sub classes");
89     }
90     public void rollback(Xid xid) throws XAException{
91         throw new XAException("This is to be implemented by sub classes");
92     }
93     */

94 }
95
Popular Tags