org.apache.ojb.broker.locking
Class LockManagerRemoteImpl

java.lang.Object
  extended by org.apache.ojb.broker.locking.LockManagerRemoteImpl
All Implemented Interfaces:
IsolationLevels, LockManager, org.apache.ojb.broker.util.configuration.Configurable

public class LockManagerRemoteImpl
extends java.lang.Object
implements LockManager, org.apache.ojb.broker.util.configuration.Configurable

This implementation of the LockManager interface supports locking in distributed environments in combination with a specific lock servlet.

Version:
$Id: LockManagerRemoteImpl.java 365232 2005-12-21 22:36:07Z tomdz $
See Also:
LockManagerServlet

Nested Class Summary
static class LockManagerRemoteImpl.LockInfo
           
 
Field Summary
static byte METHOD_BLOCK_TIMEOUT
           
static byte METHOD_BLOCK_TIMEOUT_SET
           
static byte METHOD_CHECK_READ
           
static byte METHOD_CHECK_UPGRADE
           
static byte METHOD_CHECK_WRITE
           
static byte METHOD_LOCK_INFO
           
static byte METHOD_LOCK_TIMEOUT
           
static byte METHOD_LOCK_TIMEOUT_SET
           
static byte METHOD_READ_LOCK
           
static byte METHOD_RELEASE_LOCKS
           
static byte METHOD_RELEASE_SINGLE_LOCK
           
static byte METHOD_UPGRADE_LOCK
           
static byte METHOD_WRITE_LOCK
           
 
Fields inherited from interface org.apache.ojb.broker.locking.LockManager
DEFAULT_BLOCK_TIMEOUT, DEFAULT_LOCK_TIMEOUT
 
Fields inherited from interface org.apache.ojb.broker.locking.IsolationLevels
IL_DEFAULT, IL_NONE, IL_OPTIMISTIC, IL_READ_COMMITTED, IL_READ_UNCOMMITTED, IL_REPEATABLE_READ, IL_SERIALIZABLE, LITERAL_IL_NONE, LITERAL_IL_OPTIMISTIC, LITERAL_IL_READ_COMMITTED, LITERAL_IL_READ_UNCOMMITTED, LITERAL_IL_REPEATABLE_READ, LITERAL_IL_SERIALIZABLE
 
Constructor Summary
LockManagerRemoteImpl()
           
 
Method Summary
 void configure(org.apache.ojb.broker.util.configuration.Configuration pConfig)
          configure an object using the Configuration pConfig
 long getBlockTimeout()
          The maximal time to wait for acquire a lock.
 java.lang.String getLockInfo()
          Returns info about the used lock manager implementation and the state of the lock manager.
 long getLockTimeout()
          Get the current used lock timeout value in milliseconds.
 boolean hasRead(java.lang.Object key, java.lang.Object resourceId)
          Checks if there is a read lock for owner key on resource object.
 boolean hasUpgrade(java.lang.Object key, java.lang.Object resourceId)
          Checks if there is a upgrade lock for lock key on resource object.
 boolean hasWrite(java.lang.Object key, java.lang.Object resourceId)
          Checks if there is a write lock for lock key on resource object.
 boolean readLock(java.lang.Object key, java.lang.Object resourceId, int isolationLevel)
          Acquires a readlock for lock key on resource object.
 boolean releaseLock(java.lang.Object key, java.lang.Object resourceId)
          Releases a lock for lock key on resource object.
 void releaseLocks(java.lang.Object key)
          Release all resource locks hold by the specified owner key.
 byte[] serialize(java.lang.Object obj)
           
 void setBlockTimeout(long timeout)
          noop
 void setLockTimeout(long timeout)
          noop
 boolean upgradeLock(java.lang.Object key, java.lang.Object resourceId, int isolationLevel)
          Acquire an upgrade lock.
 boolean writeLock(java.lang.Object key, java.lang.Object resourceId, int isolationLevel)
          Acquires a write lock for lock key on resource object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

METHOD_READ_LOCK

public static final byte METHOD_READ_LOCK
See Also:
Constant Field Values

METHOD_WRITE_LOCK

public static final byte METHOD_WRITE_LOCK
See Also:
Constant Field Values

METHOD_UPGRADE_LOCK

public static final byte METHOD_UPGRADE_LOCK
See Also:
Constant Field Values

METHOD_CHECK_READ

public static final byte METHOD_CHECK_READ
See Also:
Constant Field Values

METHOD_CHECK_WRITE

public static final byte METHOD_CHECK_WRITE
See Also:
Constant Field Values

METHOD_CHECK_UPGRADE

public static final byte METHOD_CHECK_UPGRADE
See Also:
Constant Field Values

METHOD_RELEASE_SINGLE_LOCK

public static final byte METHOD_RELEASE_SINGLE_LOCK
See Also:
Constant Field Values

METHOD_RELEASE_LOCKS

public static final byte METHOD_RELEASE_LOCKS
See Also:
Constant Field Values

METHOD_LOCK_INFO

public static final byte METHOD_LOCK_INFO
See Also:
Constant Field Values

METHOD_LOCK_TIMEOUT

public static final byte METHOD_LOCK_TIMEOUT
See Also:
Constant Field Values

METHOD_LOCK_TIMEOUT_SET

public static final byte METHOD_LOCK_TIMEOUT_SET
See Also:
Constant Field Values

METHOD_BLOCK_TIMEOUT

public static final byte METHOD_BLOCK_TIMEOUT
See Also:
Constant Field Values

METHOD_BLOCK_TIMEOUT_SET

public static final byte METHOD_BLOCK_TIMEOUT_SET
See Also:
Constant Field Values
Constructor Detail

LockManagerRemoteImpl

public LockManagerRemoteImpl()
Method Detail

configure

public void configure(org.apache.ojb.broker.util.configuration.Configuration pConfig)
               throws org.apache.ojb.broker.util.configuration.ConfigurationException
Description copied from interface: org.apache.ojb.broker.util.configuration.Configurable
configure an object using the Configuration pConfig

Specified by:
configure in interface org.apache.ojb.broker.util.configuration.Configurable
Parameters:
pConfig - the Configuration object used to configure current instance
Throws:
org.apache.ojb.broker.util.configuration.ConfigurationException
See Also:
Configurable.configure(org.apache.ojb.broker.util.configuration.Configuration)

setLockTimeout

public void setLockTimeout(long timeout)
noop

Specified by:
setLockTimeout in interface LockManager
Parameters:
timeout -

getLockTimeout

public long getLockTimeout()
Description copied from interface: LockManager
Get the current used lock timeout value in milliseconds.

Specified by:
getLockTimeout in interface LockManager
Returns:
Current used locking timeout value in ms.

getBlockTimeout

public long getBlockTimeout()
Description copied from interface: LockManager
The maximal time to wait for acquire a lock.

Specified by:
getBlockTimeout in interface LockManager
Returns:

setBlockTimeout

public void setBlockTimeout(long timeout)
noop

Specified by:
setBlockTimeout in interface LockManager
Parameters:
timeout - The time to wait for acquire a lock.

getLockInfo

public java.lang.String getLockInfo()
Description copied from interface: LockManager
Returns info about the used lock manager implementation and the state of the lock manager.

Specified by:
getLockInfo in interface LockManager

readLock

public boolean readLock(java.lang.Object key,
                        java.lang.Object resourceId,
                        int isolationLevel)
Description copied from interface: LockManager
Acquires a readlock for lock key on resource object. Returns true if successful, else false.

Specified by:
readLock in interface LockManager
Parameters:
key - The owner key of the lock.
resourceId - The resource to lock.
isolationLevel - The isolation level of the lock.
Returns:
True if the lock was successfully acquired.

releaseLock

public boolean releaseLock(java.lang.Object key,
                           java.lang.Object resourceId)
Description copied from interface: LockManager
Releases a lock for lock key on resource object. Returns true if successful, else false.

Specified by:
releaseLock in interface LockManager
Parameters:
key - The owner key of the lock.
resourceId - The resource to release.
Returns:
True if the lock was successfully released.

releaseLocks

public void releaseLocks(java.lang.Object key)
Description copied from interface: LockManager
Release all resource locks hold by the specified owner key.

Specified by:
releaseLocks in interface LockManager
Parameters:
key - The owner key to release all associated locks.

writeLock

public boolean writeLock(java.lang.Object key,
                         java.lang.Object resourceId,
                         int isolationLevel)
Description copied from interface: LockManager
Acquires a write lock for lock key on resource object. Returns true if successful, else false.

Specified by:
writeLock in interface LockManager
Parameters:
key - The owner key of the lock.
resourceId - The resource to lock.
isolationLevel - The isolation level of the lock.
Returns:
True if the lock was successfully acquired.

upgradeLock

public boolean upgradeLock(java.lang.Object key,
                           java.lang.Object resourceId,
                           int isolationLevel)
Description copied from interface: LockManager
Acquire an upgrade lock. (Current implementations always acquire a write lock instead).

Specified by:
upgradeLock in interface LockManager
Parameters:
key - The owner key of the lock.
resourceId - The resource to lock.
isolationLevel - The isolation level of the lock.
Returns:
True if the lock was successfully acquired.

hasRead

public boolean hasRead(java.lang.Object key,
                       java.lang.Object resourceId)
Description copied from interface: LockManager
Checks if there is a read lock for owner key on resource object. Returns true if so, else false.

Specified by:
hasRead in interface LockManager
Parameters:
key - The owner key of the lock.
resourceId - The resource to check.
Returns:
True if the lock exists.

hasWrite

public boolean hasWrite(java.lang.Object key,
                        java.lang.Object resourceId)
Description copied from interface: LockManager
Checks if there is a write lock for lock key on resource object. Returns true if so, else false.

Specified by:
hasWrite in interface LockManager
Parameters:
key - The owner key of the lock.
resourceId - The resource to check.
Returns:
True if the lock exists.

hasUpgrade

public boolean hasUpgrade(java.lang.Object key,
                          java.lang.Object resourceId)
Description copied from interface: LockManager
Checks if there is a upgrade lock for lock key on resource object. Returns true if so, else false.

Specified by:
hasUpgrade in interface LockManager
Parameters:
key - The owner key of the lock.
resourceId - The resource to check.
Returns:
True if the lock exists.

serialize

public byte[] serialize(java.lang.Object obj)
                 throws java.io.IOException
Throws:
java.io.IOException


(C) 2002 - 2006 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30