Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: ojb/odmg/locking/LockManager.java


1   /*
2    * ObJectRelationalBridge - Bridging Java Objects and Relational Databases
3    * http://objectbridge.sourceforge.net
4    * Copyright (C) 2000, 2001 Thomas Mahler, et al.
5    *
6    * This library is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU Lesser General Public
8    * License as published by the Free Software Foundation; either
9    * version 2.1 of the License, or (at your option) any later version.
10   *
11   * This library is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   * Lesser General Public License for more details.
15   *
16   * You should have received a copy of the GNU Lesser General Public
17   * License along with this library; if not, write to the Free Software
18   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19   */
20  package ojb.odmg.locking;
21  
22  import ojb.odmg.TransactionImpl;
23  
24  /**
25   * This interface declares the functionality of the OJB internal Locking mechanism.
26   * A default implementaion LockManagerDefaultImpl is provided. This implementaion
27   * keeps distributed locks in the database. The locking mechanisms thus involves a
28   * lot of database lookups and writes. For some environments this solution may not
29   * be adequate. OJB allows to provide user defined implementations of this interface.
30   * To activate a user defined LockManagerDefaultImpl it must be configured in the OJB.properties file.
31   *
32   *
33   * @author thma
34   */
35  public interface LockManager
36  {
37      /**
38       * aquires a readlock for transaction tx on object obj.
39       * Returns true if successful, else false.
40       */
41      public abstract boolean readLock(TransactionImpl tx, Object obj);
42  
43      /**
44       * aquires a writelock for transaction tx on object obj.
45       * Returns true if successful, else false.
46       */
47      public abstract boolean writeLock(TransactionImpl tx, Object obj);
48  
49      /**
50       * upgrades readlock for transaction tx on object obj to a writelock.
51       * If no readlock existed a writelock is acquired anyway.
52       * Returns true if successful, else false.
53       */
54      public abstract boolean upgradeLock(TransactionImpl tx, Object obj);
55  
56      /**
57       * releases a lock for transaction tx on object obj.
58       * Returns true if successful, else false.
59       */
60      public abstract boolean releaseLock(TransactionImpl tx, Object obj);
61  
62      /**
63       * checks if there is a readlock for transaction tx on object obj.
64       * Returns true if so, else false.
65       */
66      public abstract boolean checkRead(TransactionImpl tx, Object obj);
67  
68      /**
69       * checks if there is a writelock for transaction tx on object obj.
70       * Returns true if so, else false.
71       */
72      public abstract boolean checkWrite(TransactionImpl tx, Object obj);
73  
74  
75  }