KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > transaction > locking > MultiLevelLock


1 /*
2  * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//transaction/src/java/org/apache/commons/transaction/locking/MultiLevelLock.java,v 1.1 2004/11/18 23:27:17 ozeigermann Exp $
3  * $Revision$
4  * $Date: 2005-02-26 14:16:14 +0100 (Sa, 26 Feb 2005) $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2004 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.commons.transaction.locking;
25
26 /**
27  *
28  * A multi level lock. Depending on the implementation more than one owner may own a certain lock level on the same lock.
29  *
30  * @version $Revision$
31  * @see LockManager
32  */

33 public interface MultiLevelLock {
34
35     /**
36      * Tries to acquire a certain lock level on this lock.
37      *
38      * @param ownerId a unique id identifying the entity that wants to acquire a certain lock level on this lock
39      * @param targetLockLevel the lock level to acquire
40      * @param wait <code>true</code> if this method shall block when the desired lock level can not be acquired
41      * @param reentrant <code>true</code> if lock levels of the same entity acquired earlier
42      * should not restrict compatibility with the lock level desired now
43      * @param timeoutMSecs if blocking is enabled by the <code>wait</code> parameter this specifies the maximum wait time in milliseconds
44      * @return <code>true</code> if the lock actually was acquired
45      * @throws InterruptedException when the thread waiting on this method is interrupted
46      */

47     public boolean acquire(Object JavaDoc ownerId, int targetLockLevel, boolean wait, boolean reentrant, long timeoutMSecs)
48         throws InterruptedException JavaDoc;
49
50     /**
51      * Releases any lock levels the specified owner may hold on this lock.
52      *
53      * @param ownerId a unique id identifying the entity that wants to release all lock levels
54      * @return <code>true</code> if the lock actually was released, <code>false</code> in case
55      * there was no lock held by the owner
56      */

57     public boolean release(Object JavaDoc ownerId);
58
59    /**
60     * Retuns the highest lock level the specified owner holds on this lock or <code>0</code> if it holds no locks at all.
61     *
62     * @param ownerId a unique id identifying the entity that wants to know its highest lock level
63     * @return the highest lock level
64     */

65     public int getLockLevel(Object JavaDoc ownerId);
66 }
67
Popular Tags