001: /*
002:
003: Derby - Class org.apache.derby.impl.store.raw.xact.InternalXact
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.store.raw.xact;
023:
024: import org.apache.derby.iapi.reference.SQLState;
025:
026: import org.apache.derby.iapi.store.raw.Transaction;
027:
028: import org.apache.derby.iapi.store.raw.log.LogFactory;
029:
030: import org.apache.derby.iapi.store.raw.data.DataFactory;
031:
032: import org.apache.derby.iapi.error.StandardException;
033:
034: import org.apache.derby.iapi.services.sanity.SanityManager;
035:
036: import java.io.ObjectInput;
037:
038: /**
039:
040: @see Xact
041:
042: */
043: public class InternalXact extends Xact {
044:
045: /*
046: ** Constructor
047: */
048:
049: protected InternalXact(XactFactory xactFactory,
050: LogFactory logFactory, DataFactory dataFactory) {
051: super (xactFactory, logFactory, dataFactory, false, null);
052:
053: // always want to hold latches & containers open past the commit/abort
054: setPostComplete();
055: }
056:
057: /*
058: ** Methods of Transaction
059: */
060:
061: /**
062: Savepoints are not supported in internal transactions.
063:
064: @exception StandardException A transaction exception is thrown to
065: disallow savepoints.
066:
067: @see Transaction#setSavePoint
068: */
069: public int setSavePoint(String name, Object kindOfSavepoint)
070: throws StandardException {
071: throw StandardException
072: .newException(SQLState.XACT_NOT_SUPPORTED_IN_INTERNAL_XACT);
073: }
074:
075: /*
076: ** Methods of RawTransaction
077: */
078: /**
079: Internal transactions don't allow logical operations.
080:
081: @exception StandardException A transaction exception is thrown to
082: disallow logical operations.
083:
084: @see org.apache.derby.iapi.store.raw.xact.RawTransaction#recoveryRollbackFirst
085: */
086:
087: public void checkLogicalOperationOK() throws StandardException {
088: throw StandardException
089: .newException(SQLState.XACT_NOT_SUPPORTED_IN_INTERNAL_XACT);
090: }
091:
092: /**
093: Yes, we do want to be rolled back first in recovery.
094:
095: @see org.apache.derby.iapi.store.raw.xact.RawTransaction#recoveryRollbackFirst
096: */
097: public boolean recoveryRollbackFirst() {
098: return true;
099: }
100:
101: /*
102: ** Implementation specific methods
103: */
104:
105: /**
106: * @param commitOrAbort to commit or abort
107: *
108: * @exception StandardException on error
109: */
110: protected void doComplete(Integer commitOrAbort)
111: throws StandardException {
112:
113: // release our latches on an abort
114: // keep everything on a commit
115: if (commitOrAbort.equals(ABORT))
116: super .doComplete(commitOrAbort);
117: }
118:
119: protected void setIdleState() {
120:
121: super .setIdleState();
122:
123: // Quiesce mode never denies an internal transaction from going active, don't
124: // have to worry about that
125: if (countObservers() != 0) {
126: try {
127: super .setActiveState();
128: } catch (StandardException se) {
129: if (SanityManager.DEBUG)
130: SanityManager.THROWASSERT("unexpected exception: "
131: + se);
132: }
133: }
134: }
135: }
|