001: package org.apache.ojb.odmg;
002:
003: /* Copyright 2002-2005 The Apache Software Foundation
004: *
005: * Licensed under the Apache License, Version 2.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: import org.odmg.LockNotGrantedException;
019: import org.apache.ojb.broker.PersistenceBroker;
020: import org.apache.ojb.broker.Identity;
021: import org.apache.ojb.broker.PersistenceBrokerException;
022:
023: /**
024: * Wraps {@link org.odmg.Transaction} in managed environments.
025: *
026: * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
027: */
028: public class NarrowTransaction implements TransactionExt {
029: private TransactionImpl tx;
030:
031: public NarrowTransaction(TransactionImpl tx) {
032: this .tx = tx;
033: }
034:
035: public TransactionImpl getRealTransaction() {
036: return tx;
037: }
038:
039: public void markDelete(Object anObject) {
040: this .tx.markDelete(anObject);
041: }
042:
043: public void markDirty(Object anObject) {
044: this .tx.markDirty(anObject);
045: }
046:
047: public void flush() {
048: tx.flush();
049: }
050:
051: /**
052: * Return associated PB instance, or null if not found.
053: */
054: public PersistenceBroker getBroker() {
055: return tx.getBroker();
056: }
057:
058: /**
059: * Not supported!!
060: */
061: public void join() {
062: throw new UnsupportedOperationException(
063: "Not supported operation");
064: }
065:
066: /**
067: * Not supported!!
068: */
069: public void leave() {
070: throw new UnsupportedOperationException(
071: "Not supported operation");
072: }
073:
074: /**
075: * Not supported!!
076: */
077: public void begin() {
078: throw new UnsupportedOperationException(
079: "Not supported operation");
080: }
081:
082: /**
083: * Not supported!!
084: */
085: public boolean isOpen() {
086: return tx.isOpen();
087: }
088:
089: /**
090: * Not supported!!
091: */
092: public void commit() {
093: throw new UnsupportedOperationException(
094: "Not supported operation");
095: }
096:
097: /**
098: * Abort the underlying odmg-transaction
099: */
100: public void abort() {
101: tx.abort();
102: //throw new UnsupportedOperationException("Not supported operation");
103: }
104:
105: /**
106: * Not supported!!
107: */
108: public void checkpoint() {
109: throw new UnsupportedOperationException(
110: "Not supported operation");
111: }
112:
113: /**
114: * lock the given object
115: * @see org.odmg.Transaction#lock
116: */
117: public void lock(Object obj, int lockMode)
118: throws LockNotGrantedException {
119: tx.lock(obj, lockMode);
120: }
121:
122: /**
123: * lock the given object if possible
124: * @see org.odmg.Transaction#tryLock
125: */
126: public boolean tryLock(Object obj, int lockMode) {
127: return tx.tryLock(obj, lockMode);
128: }
129:
130: public Object getObjectByIdentity(Identity id)
131: throws PersistenceBrokerException {
132: return tx.getObjectByIdentity(id);
133: }
134:
135: /**
136: * @see org.apache.ojb.odmg.TransactionExt#setImplicitLocking(boolean)
137: */
138: public void setImplicitLocking(boolean value) {
139: tx.setImplicitLocking(value);
140: }
141:
142: /**
143: * @see org.apache.ojb.odmg.TransactionExt#isImplicitLocking
144: */
145: public boolean isImplicitLocking() {
146: return tx.isImplicitLocking();
147: }
148:
149: /**
150: * @see org.apache.ojb.odmg.TransactionExt#setCascadingDelete(Class, String, boolean)
151: */
152: public void setCascadingDelete(Class target, String referenceField,
153: boolean doCascade) {
154: tx.setCascadingDelete(target, referenceField, doCascade);
155: }
156:
157: /**
158: * @see org.apache.ojb.odmg.TransactionExt#setCascadingDelete(Class, boolean)
159: */
160: public void setCascadingDelete(Class target, boolean doCascade) {
161: tx.setCascadingDelete(target, doCascade);
162: }
163:
164: public boolean isOrdering() {
165: return tx.isOrdering();
166: }
167:
168: public void setOrdering(boolean ordering) {
169: tx.setOrdering(ordering);
170: }
171:
172: // public boolean isNoteUserOrder()
173: // {
174: // return tx.isNoteUserOrder();
175: // }
176: //
177: // public void setNoteUserOrder(boolean noteUserOrder)
178: // {
179: // tx.setNoteUserOrder(noteUserOrder);
180: // }
181:
182: public boolean isDeleted(Identity id) {
183: return tx.isDeleted(id);
184: }
185: }
|