| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| EditingContext |
|
| 1.0;1 |
| 1 | package org.apache.ojb.otm; | |
| 2 | ||
| 3 | /* Copyright 2003-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.apache.ojb.broker.Identity; | |
| 19 | import org.apache.ojb.otm.lock.LockingException; | |
| 20 | import org.apache.ojb.otm.states.State; | |
| 21 | ||
| 22 | import java.util.Collection; | |
| 23 | ||
| 24 | /** | |
| 25 | * | |
| 26 | * The EditingContext contains and manages the set of object read/edited within the context of a | |
| 27 | * transaction. Logically, this could be considered similar to a document that is being edited. | |
| 28 | * During commit, all objects within this transaction that are marked as being written to (ones | |
| 29 | * with a write lock) are written back to the persistent store. | |
| 30 | * | |
| 31 | * @author <a href="mailto:rraghuram@hotmail.com">Raghu Rajah</a> | |
| 32 | * | |
| 33 | */ | |
| 34 | public interface EditingContext | |
| 35 | { | |
| 36 | ||
| 37 | /** | |
| 38 | * | |
| 39 | * Insert the given object into the EditingContext, acquiring the specified lock. | |
| 40 | * | |
| 41 | * @param oid the identity of the object to be inserted | |
| 42 | * @param userObject the object to insert, for user operations | |
| 43 | * @param lock the lock to be acquired. | |
| 44 | * @throws LockingException thrown by the Lock Manager to avoid deadlocks. The insertion | |
| 45 | * could be re-attempted if the lock fails. | |
| 46 | * | |
| 47 | */ | |
| 48 | public void insert (Identity oid, Object userObject, int lock) | |
| 49 | throws LockingException; | |
| 50 | ||
| 51 | /** | |
| 52 | * | |
| 53 | * Remove a managed object from the management of this EditingContext. All edits on the object | |
| 54 | * will be lost. All locks kept by this object will be released. | |
| 55 | * | |
| 56 | * @param oid the Identity of the object to be removed from this context. | |
| 57 | * | |
| 58 | */ | |
| 59 | public void remove (Identity oid); | |
| 60 | ||
| 61 | /** | |
| 62 | * | |
| 63 | * Lookup object with the given oid in the Context. | |
| 64 | * | |
| 65 | * @param oid the oid of the object to lookup | |
| 66 | * | |
| 67 | */ | |
| 68 | public Object lookup (Identity oid) | |
| 69 | throws LockingException; | |
| 70 | ||
| 71 | /** | |
| 72 | * lookup the state of an object, given the oid, in the context | |
| 73 | * @param oid | |
| 74 | * @return the state of that object in the context, null if the object is not in the context | |
| 75 | * @throws LockingException | |
| 76 | */ | |
| 77 | State lookupState(Identity oid) | |
| 78 | throws LockingException; | |
| 79 | ||
| 80 | void setState(Identity oid, State state); | |
| 81 | ||
| 82 | Collection getAllObjectsInContext(); | |
| 83 | ||
| 84 | /** | |
| 85 | * Rollback all changes made during this transaction to the given object. | |
| 86 | */ | |
| 87 | public void refresh(Identity oid, Object object); | |
| 88 | } |