Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.transaction.locking
Interface MultiLevelLock2

All Superinterfaces:
  MultiLevelLock

All Known Implementing Classes:
  GenericLock

public interface MultiLevelLock2
extends MultiLevelLock

Extended multi level lock. Compared to basic `MultiLevelLock` allows for more flexible locking including preference and more compatibility modes.

Since:
  1.1
Version:
  $Revision$
See Also:
  `LockManager2`, `MultiLevelLock`, `GenericLock`

Field Summary
`static int` | `COMPATIBILITY_NONE` Compatibility mode: none reentrant.
`static int` | `COMPATIBILITY_REENTRANT` Compatibility mode: reentrant.
`static int` | `COMPATIBILITY_REENTRANT_AND_SUPPORT` Compatibility mode: reentrant and supporting.
`static int` | `COMPATIBILITY_SUPPORT` Compatibility mode: supporting.

Method Summary
`boolean` | `acquire(Object ownerId, int targetLockLevel, boolean wait, int compatibility, boolean preferred, long timeoutMSecs)` Tries to acquire a certain lock level on this lock.
`boolean` | `has(Object ownerId, int lockLevel)` Tests if a certain lock level is owned by an owner.
`boolean` | `test(Object ownerId, int targetLockLevel, int compatibility)` Tests if a certain lock level could be acquired.

Methods inherited from interface org.apache.commons.transaction.locking.MultiLevelLock
`acquire, getLockLevel, release`

Field Detail

### COMPATIBILITY_NONE

    public static final int COMPATIBILITY_NONE

  Compatibility mode: none reentrant. Lock level by the same owner shall affect compatibility.

  See Also:
    Constant Field Values

### COMPATIBILITY_REENTRANT

    public static final int COMPATIBILITY_REENTRANT

  Compatibility mode: reentrant. Lock level by the same owner shall not affect compatibility.

  See Also:
    Constant Field Values

### COMPATIBILITY_SUPPORT

    public static final int COMPATIBILITY_SUPPORT

  Compatibility mode: supporting. Lock levels that are the same as the desired shall not affect compatibility, but lock level held by the same owner shall.

  See Also:
    Constant Field Values

### COMPATIBILITY_REENTRANT_AND_SUPPORT

    public static final int COMPATIBILITY_REENTRANT_AND_SUPPORT

  Compatibility mode: reentrant and supporting. Lock levels that are the same as the desired and lock levels held by the same owner shall not affect compatibility.

  See Also:
    Constant Field Values

Method Detail

### has

    public boolean has(Object ownerId,
                       int lockLevel)

  Tests if a certain lock level is owned by an owner.

  Parameters:
    `ownerId` - a unique id identifying the entity that wants to check a certain lock level on this lock
    `lockLevel` - the lock level to test
  Returns:
    `true` if the lock could be acquired at the time this method was called

### test

    public boolean test(Object ownerId,
                        int targetLockLevel,
                        int compatibility)

  Tests if a certain lock level could be acquired. This method tests only and does not actually acquire the lock.

  Parameters:
    `ownerId` - a unique id identifying the entity that wants to test a certain lock level on this lock
    `targetLockLevel` - the lock level to acquire
    `compatibility` - `COMPATIBILITY_NONE`if no additional compatibility is desired (same as reentrant set to false) , `COMPATIBILITY_REENTRANT`if lock level by the same owner shall not affect compatibility (same as reentrant set to true), or `COMPATIBILITY_SUPPORT`if lock levels that are the same as the desired shall not affect compatibility, or finally `COMPATIBILITY_REENTRANT_AND_SUPPORT`which is a combination of reentrant and support
  Returns:
    `true` if the lock could be acquired at the time this method was called

### acquire

    public boolean acquire(Object ownerId,
                           int targetLockLevel,
                           boolean wait,
                           int compatibility,
                           boolean preferred,
                           long timeoutMSecs)
                    throws InterruptedException

  Tries to acquire a certain lock level on this lock. Does the same as `MultiLevelLock.acquire(java.lang.Object, int, boolean, boolean, long)` except that it allows for different compatibility settings. There is an additional compatibility mode `COMPATIBILITY_SUPPORT`that allows equal lock levels not to interfere with each other. This is like an additional shared compatibility and useful when you only want to make sure not to interfer with lowe levels, but are fine with the same.

  Parameters:
    `ownerId` - a unique id identifying the entity that wants to acquire a certain lock level on this lock
    `targetLockLevel` - the lock level to acquire
    `wait` - `true` if this method shall block when the desired lock level can not be acquired
    `compatibility` - `COMPATIBILITY_NONE`if no additional compatibility is desired (same as reentrant set to false) , `COMPATIBILITY_REENTRANT`if lock level by the same owner shall not affect compatibility (same as reentrant set to true), or `COMPATIBILITY_SUPPORT`if lock levels that are the same as the desired shall not affect compatibility, or finally `COMPATIBILITY_REENTRANT_AND_SUPPORT`which is a combination of reentrant and support
    `preferred` - in case this lock request is incompatible with existing ones and we wait, it shall be granted before other waiting requests that are not preferred
    `timeoutMSecs` - if blocking is enabled by the `wait` parameter this specifies the maximum wait time in milliseconds
  Returns:
    `true` if the lock actually was acquired
  Throws:
    `InterruptedException` - when the thread waiting on this method is interrupted

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004 The Apache Software Foundation. All Rights Reserved.