001: package org.apache.ojb.odmg.locking;
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.apache.ojb.odmg.TransactionImpl;
019: import org.apache.ojb.broker.Identity;
020:
021: /**
022: * This interface declares the functionality of the OJB internal Locking mechanism.
023: * A default implementaion LockManagerDefaultImpl is provided. This implementaion
024: * keeps distributed locks in the database. The locking mechanisms thus involves a
025: * lot of database lookups and writes. For some environments this solution may not
026: * be adequate. OJB allows to provide user defined implementations of this interface.
027: * To activate a user defined LockManagerDefaultImpl it must be configured in the OJB.properties file.
028: *
029: *
030: * @author thma
031: */
032: public interface LockManager {
033: /**
034: * aquires a readlock for transaction tx on object obj.
035: * Returns true if successful, else false.
036: */
037: public abstract boolean readLock(TransactionImpl tx, Object obj);
038:
039: /**
040: * aquires a readlock for transaction tx on object obj.
041: * Returns true if successful, else false.
042: */
043: public abstract boolean readLock(TransactionImpl tx, Identity oid,
044: Object obj);
045:
046: /**
047: * aquires a writelock for transaction tx on object obj.
048: * Returns true if successful, else false.
049: */
050: public abstract boolean writeLock(TransactionImpl tx, Object obj);
051:
052: /**
053: * aquires a writelock for transaction tx on object obj.
054: * Returns true if successful, else false.
055: */
056: public abstract boolean writeLock(TransactionImpl tx, Identity oid,
057: Object obj);
058:
059: /**
060: * upgrades readlock for transaction tx on object obj to a writelock.
061: * If no readlock existed a writelock is acquired anyway.
062: * Returns true if successful, else false.
063: */
064: public abstract boolean upgradeLock(TransactionImpl tx, Object obj);
065:
066: /**
067: * upgrades readlock for transaction tx on object obj to a writelock.
068: * If no readlock existed a writelock is acquired anyway.
069: * Returns true if successful, else false.
070: */
071: public abstract boolean upgradeLock(TransactionImpl tx,
072: Identity oid, Object obj);
073:
074: /**
075: * releases a lock for transaction tx on object obj.
076: * Returns true if successful, else false.
077: */
078: public abstract boolean releaseLock(TransactionImpl tx, Object obj);
079:
080: /**
081: * releases a lock for transaction tx on object obj.
082: * Returns true if successful, else false.
083: */
084: public abstract boolean releaseLock(TransactionImpl tx,
085: Identity oid, Object obj);
086:
087: /**
088: * checks if there is a readlock for transaction tx on object obj.
089: * Returns true if so, else false.
090: */
091: public abstract boolean checkRead(TransactionImpl tx, Object obj);
092:
093: /**
094: * checks if there is a readlock for transaction tx on object obj.
095: * Returns true if so, else false.
096: */
097: public abstract boolean checkRead(TransactionImpl tx, Identity oid,
098: Object obj);
099:
100: /**
101: * checks if there is a writelock for transaction tx on object obj.
102: * Returns true if so, else false.
103: */
104: public abstract boolean checkWrite(TransactionImpl tx, Object obj);
105:
106: /**
107: * checks if there is a writelock for transaction tx on object obj.
108: * Returns true if so, else false.
109: */
110: public abstract boolean checkWrite(TransactionImpl tx,
111: Identity oid, Object obj);
112: }
|