01: package org.apache.ojb.otm;
02:
03: /* Copyright 2003-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * 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: * Insert the given object into the EditingContext, acquiring the specified lock.
39: *
40: * @param oid the identity of the object to be inserted
41: * @param userObject the object to insert, for user operations
42: * @param lock the lock to be acquired.
43: * @throws LockingException thrown by the Lock Manager to avoid deadlocks. The insertion
44: * could be re-attempted if the lock fails.
45: *
46: */
47: public void insert(Identity oid, Object userObject, int lock)
48: throws LockingException;
49:
50: /**
51: *
52: * Remove a managed object from the management of this EditingContext. All edits on the object
53: * will be lost. All locks kept by this object will be released.
54: *
55: * @param oid the Identity of the object to be removed from this context.
56: *
57: */
58: public void remove(Identity oid);
59:
60: /**
61: *
62: * Lookup object with the given oid in the Context.
63: *
64: * @param oid the oid of the object to lookup
65: *
66: */
67: public Object lookup(Identity oid) throws LockingException;
68:
69: /**
70: * lookup the state of an object, given the oid, in the context
71: * @param oid
72: * @return the state of that object in the context, null if the object is not in the context
73: * @throws LockingException
74: */
75: State lookupState(Identity oid) throws LockingException;
76:
77: void setState(Identity oid, State state);
78:
79: Collection getAllObjectsInContext();
80:
81: /**
82: * Rollback all changes made during this transaction to the given object.
83: */
84: public void refresh(Identity oid, Object object);
85: }
|