Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.tangosol.io.bdb
Class DatabaseFactory.EnvironmentHolder.DirectoryLock

    java.lang.Object
      com.tangosol.io.bdb.DatabaseFactory.EnvironmentHolder.DirectoryLock

Enclosing class:
  DatabaseFactory.EnvironmentHolder

    protected static class DatabaseFactory.EnvironmentHolder.DirectoryLock

extends java.lang.Object

Directory based lock.

A single instance of the DirectoryLock is not intended for inter thread locking. Multiple instance refering to the same File should be used instead.

Field Summary
`static java.lang.String` | `LOCK_FILE_NAME` Name of warning file.
`protected java.io.File` | `m_dir` Directory to lock.
`protected java.io.FileOutputStream` | `m_fstreamLocked` The FileStream which the actuall lock is held on.
`protected java.nio.channels.FileLock` | `m_lockDir` The actual FileLock.
`protected java.lang.String` | `m_sLockText` Text to include in the lock file.

Constructor Summary
`DatabaseFactory.EnvironmentHolder.DirectoryLock(java.io.File dir, java.lang.String sLockText)` Create a DirectoryLock which can be used to try to lock a directory.

Method Summary
`protected void` | `finalize()` Automatically release the lock on finalization.
`boolean` | `tryLock()` Try to lock the directory.
`boolean` | `tryUnlock()` Try to unlock the directory.

Field Detail

### LOCK_FILE_NAME

    public static final java.lang.String LOCK_FILE_NAME

  Name of warning file.

  See Also:
    Constant Field Values

### m_dir

    protected java.io.File m_dir

  Directory to lock.

### m_fstreamLocked

    protected java.io.FileOutputStream m_fstreamLocked

  The FileStream which the actuall lock is held on.

### m_lockDir

    protected java.nio.channels.FileLock m_lockDir

  The actual FileLock.

### m_sLockText

    protected java.lang.String m_sLockText

  Text to include in the lock file.

Constructor Detail

### DatabaseFactory.EnvironmentHolder.DirectoryLock

    public DatabaseFactory.EnvironmentHolder.DirectoryLock(java.io.File dir,
                                                           java.lang.String sLockText)

  Create a DirectoryLock which can be used to try to lock a directory. The object is created in an unlocked state.

  Parameters:
    `dir` - the directory to lock
    `sLockText` - the text to include in the lock file

Method Detail

### tryLock

    public boolean tryLock()
                    throws java.io.IOException

  Try to lock the directory.

  Returns:
    true if a lock is obtained, false if it is locked by another DirectoryLock
  Throws:
    `java.io.IOException` - if an IO error occurs while creating the lock file

### tryUnlock

    public boolean tryUnlock()
                      throws java.io.IOException

  Try to unlock the directory.

  Returns:
    true if a lock is released, false if the directory was not locked by this DirectoryLock
  Throws:
    `java.io.IOException` - if an IO error occurs while deleting the lock file, the lock may be left in an unlocked state

### finalize

    protected void finalize()
                     throws java.lang.Throwable

  Automatically release the lock on finalization.

  The OS will ensure that the lock is released regardless but this allows the lock file to be deleted as well.

  Throws:
    `java.lang.Throwable`

Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2010, Oracle. All rights reserved.