KickJava   Java API By Example, From Geeks To Geeks.

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


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 //Source File Name: SybaseXAResource.java
25

26 package com.sun.enterprise.transaction;
27
28 import javax.transaction.xa.*;
29 import javax.resource.ResourceException JavaDoc;
30
31 import com.sun.enterprise.util.i18n.StringManager;
32
33 /**
34  * XA Resource wrapper class for sybase XA Resource with jConnect 5.2.
35  *
36  * @author <a HREF="mailto:bala.dutt@sun.com">Bala Dutt</a>
37  * @version 1.0
38  */

39 public class SybaseXAResource extends XAResourceWrapper
40 {
41
42
43     // Sting Manager for Localization
44
private static StringManager sm = StringManager.getManager(SybaseXAResource.class);
45   /**
46    * Returns xids list for recovery depending on flags. Sybase XA Resource ignores the flags
47    * for XAResource recover call. This method takes care for the fault. Allows the recover call
48    * only for TMSTARTRSCAN, for other values of flags just returns null.
49    *
50    * @param flag an <code>int</code> value
51    * @return a <code>Xid[]</code> value
52    * @exception XAException if an error occurs
53    */

54   public Xid[] recover(int flag) throws XAException {
55         try{
56             if(flag==XAResource.TMSTARTRSCAN)
57                 return m_xacon.getXAResource().recover(flag);
58         }catch(ResourceException JavaDoc e){
59             //a bad xa connection given...
60
// throw new XAException("sybase XA resource wrapper : Could not connect : sqlexception was "+e);
61
throw new XAException(sm.getString("transaction.sybase_xa_wrapper_connection_failed",e));
62         }
63         return null;
64     }
65     public void commit(Xid xid, boolean flag) throws XAException{
66         try{
67             m_xacon.getXAResource().commit(xid, flag);
68         }catch(ResourceException JavaDoc e){
69             //a bad xa connection given...
70
throw new XAException(sm.getString("transaction.sybase_xa_wrapper_connection_failed",e));
71             // throw new XAException("sybase XA resource wrapper :Could not connect : sqlexception was "+e);
72
}
73     }
74     public void rollback(Xid xid) throws XAException{
75         try{
76             m_xacon.getXAResource().rollback(xid);
77         }catch(ResourceException JavaDoc e){
78             //a bad xa connection given...
79
throw new XAException(sm.getString("transaction.sybase_xa_wrapper_connection_failed",e));
80             // throw new XAException("sybase XA resource wrapper :Could not connect : sqlexception was "+e);
81
}
82     }
83 }
84
Popular Tags