001: /*
002: * Copyright (c) 1998-2003 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: * Free SoftwareFoundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028:
029: package javax.transaction.xa;
030:
031: /**
032: * The interface for a transaction resource.
033: */
034: public interface XAResource {
035: // end a recovery scan
036: public final static int TMENDRSCAN = 0x00800000;
037: // disassociates the transaction and mark rollback-only
038: public final static int TMFAIL = 0x20000000;
039: // join existing branch
040: public final static int TMJOIN = 0x00200000;
041: // no flags
042: public final static int TMNOFLAGS = 0x00000000;
043: // using one-phase
044: public final static int TMONEPHASE = 0x40000000;
045: // resuming suspended branch
046: public final static int TMRESUME = 0x08000000;
047: // start a recovery scan
048: public final static int TMSTARTRSCAN = 0x01000000;
049: // disassociate from transaction branch
050: public final static int TMSUCCESS = 0x04000000;
051: // suspend from transaction branch
052: public final static int TMSUSPEND = 0x02000000;
053:
054: public final static int XA_OK = 0;
055: public final static int XA_RDONLY = 3;
056:
057: /**
058: * Returns true if the specified resource has the same RM.
059: */
060: public boolean isSameRM(XAResource xa) throws XAException;
061:
062: /**
063: * Sets the transaction timeout in seconds.
064: */
065: public boolean setTransactionTimeout(int timeout)
066: throws XAException;
067:
068: /**
069: * Gets the transaction timeout in seconds.
070: */
071: public int getTransactionTimeout() throws XAException;
072:
073: /**
074: * Called when the resource is associated with a transaction.
075: */
076: public void start(Xid xid, int flags) throws XAException;
077:
078: /**
079: * Called when the resource is is done with a transaction.
080: */
081: public void end(Xid xid, int flags) throws XAException;
082:
083: /**
084: * Called to start the first phase of the commit.
085: */
086: public int prepare(Xid xid) throws XAException;
087:
088: /**
089: * Called to commit.
090: */
091: public void commit(Xid xid, boolean onePhase) throws XAException;
092:
093: /**
094: * Called to roll back.
095: */
096: public void rollback(Xid xid) throws XAException;
097:
098: /**
099: * Called to forget an Xid that had a heuristic commit.
100: */
101: public void forget(Xid xid) throws XAException;
102:
103: /**
104: * Called to find Xid's that need recovery.
105: */
106: public Xid[] recover(int flag) throws XAException;
107: }
|