View Javadoc

1   package org.apache.ojb.odmg;
2   
3   /* Copyright 2002-2005 The Apache Software Foundation
4    *
5    * Licensed under the Apache License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  import org.odmg.LockNotGrantedException;
19  import org.apache.ojb.broker.PersistenceBroker;
20  import org.apache.ojb.broker.Identity;
21  import org.apache.ojb.broker.PersistenceBrokerException;
22  
23  /**
24   * Wraps {@link org.odmg.Transaction} in managed environments.
25   *
26   * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
27   */
28  public class NarrowTransaction implements TransactionExt
29  {
30      private TransactionImpl tx;
31  
32      public NarrowTransaction(TransactionImpl tx)
33      {
34          this.tx = tx;
35      }
36  
37      public TransactionImpl getRealTransaction()
38      {
39          return tx;
40      }
41  
42      public void markDelete(Object anObject)
43      {
44          this.tx.markDelete(anObject);
45      }
46  
47      public void markDirty(Object anObject)
48      {
49          this.tx.markDirty(anObject);
50      }
51  
52      public void flush()
53      {
54          tx.flush();
55      }
56  
57      /**
58       * Return associated PB instance, or null if not found.
59       */
60      public PersistenceBroker getBroker()
61      {
62          return tx.getBroker();
63      }
64  
65      /**
66       * Not supported!!
67       */
68      public void join()
69      {
70          throw new UnsupportedOperationException("Not supported operation");
71      }
72  
73      /**
74       * Not supported!!
75       */
76      public void leave()
77      {
78          throw new UnsupportedOperationException("Not supported operation");
79      }
80  
81      /**
82       * Not supported!!
83       */
84      public void begin()
85      {
86          throw new UnsupportedOperationException("Not supported operation");
87      }
88  
89      /**
90       * Not supported!!
91       */
92      public boolean isOpen()
93      {
94          return tx.isOpen();
95      }
96  
97      /**
98       * Not supported!!
99       */
100     public void commit()
101     {
102         throw new UnsupportedOperationException("Not supported operation");
103     }
104 
105     /**
106      * Abort the underlying odmg-transaction
107      */
108     public void abort()
109     {
110         tx.abort();
111         //throw new UnsupportedOperationException("Not supported operation");
112     }
113 
114     /**
115      * Not supported!!
116      */
117     public void checkpoint()
118     {
119         throw new UnsupportedOperationException("Not supported operation");
120     }
121 
122     /**
123      * lock the given object
124      * @see org.odmg.Transaction#lock
125      */
126     public void lock(Object obj, int lockMode)
127             throws LockNotGrantedException
128     {
129         tx.lock(obj, lockMode);
130     }
131 
132     /**
133      * lock the given object if possible
134      * @see org.odmg.Transaction#tryLock
135      */
136     public boolean tryLock(Object obj, int lockMode)
137     {
138         return tx.tryLock(obj, lockMode);
139     }
140 
141 	public Object getObjectByIdentity(Identity id)
142 			throws PersistenceBrokerException
143 	{
144 		return tx.getObjectByIdentity(id);
145 	}
146     /**
147      * @see org.apache.ojb.odmg.TransactionExt#setImplicitLocking(boolean)
148      */
149     public void setImplicitLocking(boolean value)
150     {
151     	tx.setImplicitLocking(value);
152     }
153 
154     /**
155      * @see org.apache.ojb.odmg.TransactionExt#isImplicitLocking
156      */
157     public boolean isImplicitLocking()
158     {
159         return tx.isImplicitLocking();
160     }
161 
162     /**
163      * @see org.apache.ojb.odmg.TransactionExt#setCascadingDelete(Class, String, boolean)
164      */
165     public void setCascadingDelete(Class target, String referenceField, boolean doCascade)
166     {
167         tx.setCascadingDelete(target, referenceField, doCascade);
168     }
169 
170     /**
171      * @see org.apache.ojb.odmg.TransactionExt#setCascadingDelete(Class, boolean) 
172      */
173     public void setCascadingDelete(Class target, boolean doCascade)
174     {
175         tx.setCascadingDelete(target, doCascade);
176     }
177 
178     public boolean isOrdering()
179     {
180         return tx.isOrdering();
181     }
182 
183     public void setOrdering(boolean ordering)
184     {
185         tx.setOrdering(ordering);
186     }
187 
188 //    public boolean isNoteUserOrder()
189 //    {
190 //        return tx.isNoteUserOrder();
191 //    }
192 //
193 //    public void setNoteUserOrder(boolean noteUserOrder)
194 //    {
195 //        tx.setNoteUserOrder(noteUserOrder);
196 //    }
197 
198     public boolean isDeleted(Identity id)
199     {
200         return tx.isDeleted(id);
201     }
202 }