001: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012: // POSSIBILITY OF SUCH DAMAGE.
013: //
014: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015: package com.metaboss.enterprise.spi.tyreximpl;
016:
017: import javax.transaction.SystemException;
018: import javax.transaction.xa.Xid;
019:
020: import org.apache.commons.logging.Log;
021: import org.apache.commons.logging.LogFactory;
022:
023: import tyrex.tm.Journal;
024:
025: /** Implement tyrex's Transaction Journal based on local file in the current working directory */
026: public class JournalImpl extends Journal {
027: private static final Log sLogger = LogFactory
028: .getLog(JournalImpl.class);
029:
030: /** Creates journal with specified name */
031: public static Journal createJournal(String pJournalName)
032: throws SystemException {
033: return new JournalImpl();
034: }
035:
036: /**
037: * Records the outcome of transaction preparation. The decision code
038: * indicates whether the transaction is read-only, requires commit or
039: * has rolled back.
040: * <p>
041: * This method is called to record the outcome after preparing a
042: * transaction. It must record a decision to commit or rollback the
043: * transaction. This method may be skipped if the transaction is
044: * identified as read-only or for local transactions.
045: * <p>
046: * If this method is called, {@link #commit commit} or {@link #rollback
047: * rollback} must follow.
048: * <p>
049: * Valid values for the decision are <tt>XAResource.XA_OK</tt>,
050: * <tt>XAResource.XA_RDONLY</tt>, or any of the heuristic codes
051: * defined by <tt>XAException.XA_HEUR*</tt>.
052: *
053: * @param xid The transaction identifier
054: * @param decision The outcome of the prepare stage
055: * @throw SystemException An error occured while performing this operation
056: */
057: public void prepare(Xid xid, int decision) throws SystemException {
058: sLogger.debug("Received request to journal prepare");
059: }
060:
061: /**
062: * Records a transaction commit.
063: * <p>
064: * This method is called when completing two-phase commit of a transaction
065: * branch. This method may be skipped if the transaction is identified as
066: * read-only or is a local transaction.
067: * <p>
068: * If this method is called, {@link #forget forget} must follow.
069: * <p>
070: * If the transaction has properly committed, the heuristic decision will
071: * be <tt>XAResource.XA_HEURCOM</tt>. Otherwise, use any of the heuristic
072: * codes defined by <tt>XAException.XA_HEUR*</tt>.
073: *
074: * @param xid The transaction identifier
075: * @param decision The heuristic decision
076: * @throw SystemException An error occured while performing this opetion
077: */
078: public void commit(Xid xid, int decision) throws SystemException {
079: sLogger.debug("Received request to journal commit");
080: }
081:
082: /**
083: * Records a transaction rollback.
084: * <p>
085: * This method is called when completing two-phase commit of a transaction
086: * branch. This method may be skipped for local transactions.
087: * <p>
088: * If this method is called, {@link #forget forget} must follow.
089: *
090: * @param xid The transaction identifier
091: * @throw SystemException An error occured while performing this operation
092: */
093: public void rollback(Xid xid) throws SystemException {
094: sLogger.debug("Received request to journal rollback");
095: }
096:
097: /**
098: * Forgets a heuristically complete transaction.
099: * <p>
100: * This method is called when completing two-phase commit to discard the
101: * transaction and close the transaction chain.
102: *
103: * @param xid The transaction identifier
104: * @throw SystemException An error occured while performing this operation
105: */
106: public void forget(Xid xid) throws SystemException {
107: sLogger.debug("Received request to journal forget");
108: }
109:
110: /**
111: * Determines whether the transaction is open.
112: * <p>
113: * The transaction is open if any record was written on behalf
114: * of that transaction. The transaction must be closed explicitly
115: * by calling {@link #forget forget}. If the transaction is not
116: * open, there is no need to call {@link #forget forget}.
117: *
118: * @param xid The transaction identifier
119: * @return True if the transaction is open and must be closed
120: * @throw SystemException An error occured while performing this
121: * operation
122: */
123: /*
124: public abstract boolean isOpen( Xid xid )
125: throws SystemException;
126: */
127:
128: /**
129: * Called to initiate recovery. This method will return information
130: * about all transactions that are subject to recovery.
131: * <p>
132: * A recoverable transaction is a transaction that has been processed
133: * through two-phase commit but has not been completed. This method
134: * will return the heuristic decision for the transaction as reached
135: * by the transaction manager.
136: * <p>
137: * Transactions that have been completed are generally not returned
138: * by this method. In addition it is possible that resource managers
139: * will return additional transaction branchs for which the transaction
140: * manager has not reached any heuristic decision.
141: *
142: * @return An array of zero of more recoverable transactions
143: * @throw SystemException An error occured while performing this operation
144: */
145: public Journal.RecoveredTransaction[] recover()
146: throws SystemException {
147: sLogger.debug("Received request to recover");
148: return new Journal.RecoveredTransaction[0];
149: }
150:
151: /**
152: * Called to close the journal and release any resources held by the
153: * journal.
154: *
155: * @throw SystemException An error occured while performing this operation
156: */
157: public void close() throws SystemException {
158: sLogger.debug("Received request to close journal");
159: }
160: }
|