1 package org.apache.ojb.odmg.locking; 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.apache.ojb.odmg.TransactionImpl; 19 import org.apache.ojb.broker.Identity; 20 21 /** 22 * This interface declares the functionality of the OJB internal Locking mechanism. 23 * A default implementaion LockManagerDefaultImpl is provided. This implementaion 24 * keeps distributed locks in the database. The locking mechanisms thus involves a 25 * lot of database lookups and writes. For some environments this solution may not 26 * be adequate. OJB allows to provide user defined implementations of this interface. 27 * To activate a user defined LockManagerDefaultImpl it must be configured in the OJB.properties file. 28 * 29 * 30 * @author thma 31 */ 32 public interface LockManager 33 { 34 /** 35 * aquires a readlock for transaction tx on object obj. 36 * Returns true if successful, else false. 37 */ 38 public abstract boolean readLock(TransactionImpl tx, Object obj); 39 40 /** 41 * aquires a readlock for transaction tx on object obj. 42 * Returns true if successful, else false. 43 */ 44 public abstract boolean readLock(TransactionImpl tx, Identity oid, Object obj); 45 46 47 /** 48 * aquires a writelock for transaction tx on object obj. 49 * Returns true if successful, else false. 50 */ 51 public abstract boolean writeLock(TransactionImpl tx, Object obj); 52 53 /** 54 * aquires a writelock for transaction tx on object obj. 55 * Returns true if successful, else false. 56 */ 57 public abstract boolean writeLock(TransactionImpl tx, Identity oid, Object obj); 58 59 60 /** 61 * upgrades readlock for transaction tx on object obj to a writelock. 62 * If no readlock existed a writelock is acquired anyway. 63 * Returns true if successful, else false. 64 */ 65 public abstract boolean upgradeLock(TransactionImpl tx, Object obj); 66 67 /** 68 * upgrades readlock for transaction tx on object obj to a writelock. 69 * If no readlock existed a writelock is acquired anyway. 70 * Returns true if successful, else false. 71 */ 72 public abstract boolean upgradeLock(TransactionImpl tx, Identity oid, Object obj); 73 74 75 /** 76 * releases a lock for transaction tx on object obj. 77 * Returns true if successful, else false. 78 */ 79 public abstract boolean releaseLock(TransactionImpl tx, Object obj); 80 81 /** 82 * releases a lock for transaction tx on object obj. 83 * Returns true if successful, else false. 84 */ 85 public abstract boolean releaseLock(TransactionImpl tx, Identity oid, Object obj); 86 87 88 /** 89 * checks if there is a readlock for transaction tx on object obj. 90 * Returns true if so, else false. 91 */ 92 public abstract boolean checkRead(TransactionImpl tx, Object obj); 93 94 /** 95 * checks if there is a readlock for transaction tx on object obj. 96 * Returns true if so, else false. 97 */ 98 public abstract boolean checkRead(TransactionImpl tx, Identity oid, Object obj); 99 100 101 /** 102 * checks if there is a writelock for transaction tx on object obj. 103 * Returns true if so, else false. 104 */ 105 public abstract boolean checkWrite(TransactionImpl tx, Object obj); 106 107 /** 108 * checks if there is a writelock for transaction tx on object obj. 109 * Returns true if so, else false. 110 */ 111 public abstract boolean checkWrite(TransactionImpl tx, Identity oid, Object obj); 112 }