Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Beta3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.jcr.value.binary
Class SharedLockingInputStream

    java.lang.Object
      java.io.InputStream
          org.modeshape.jcr.value.binary.SharedLockingInputStream

All Implemented Interfaces:
  Closeable

    public final class SharedLockingInputStream

extends InputStream

A `InputStream` implementation around a file that creates a shared lock when reading the file, ensuring the file is not changed by other writers in this or other JVM processes. The stream automatically closes itself and releases the lock when `closed explicitly` or if there are any errors or exceptions while reading. Caution: be very careful when working with this class, as any open without close operations can produce "readLocks" which do not get released, blocking any potential subsequent writes.

Field Summary
`protected boolean` | `eofReached`
`protected File` | `file`
`protected FileLocks.WrappedLock` | `fileLock`
`protected BinaryKey` | `key`
`protected NamedLocks` | `lockManager`
`protected Lock` | `processLock`
`protected InputStream` | `stream`

Constructor Summary
`SharedLockingInputStream(BinaryKey key, File file, NamedLocks lockManager)` Create a self-closing, (shared) locking `InputStream` to read the content of the supplied `file`.

Method Summary
`int` | `available()`
`void` | `close()`
`boolean` | `equals(Object obj)`
`int` | `hashCode()`
`void` | `mark(int readlimit)`
`boolean` | `markSupported()`
`protected void` | `open()`
`int` | `read()`
`int` | `read(byte[] b)`
`int` | `read(byte[] b, int off, int len)`
`void` | `reset()`
`long` | `skip(long n)`
`String` | `toString()`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### key

    protected final BinaryKey key

### file

    protected final File file

### lockManager

    protected final NamedLocks lockManager

### stream

    protected InputStream stream

### processLock

    protected Lock processLock

### fileLock

    protected FileLocks.WrappedLock fileLock

### eofReached

    protected boolean eofReached

Constructor Detail

### SharedLockingInputStream

    public SharedLockingInputStream(BinaryKey key,
                                    File file,
                                    NamedLocks lockManager)

  Create a self-closing, (shared) locking `InputStream` to read the content of the supplied `file`.

  Parameters:
    `key` - the binary key; may not be null
    `file` - the file that is to be read; may not be null
    `lockManager` - the manager of the locks, from which a read lock is to be obtained; may be null if no read lock is needed

Method Detail

### open

    protected void open()
                 throws IOException

  Throws:
    `IOException`

### available

    public int available()
                  throws IOException

  Overrides:
    `available` in class `InputStream`
  Throws:
    `IOException`

### close

    public void close()
               throws IOException

  Specified by:
    `close` in interface `Closeable`
  Overrides:
    `close` in class `InputStream`
  Throws:
    `IOException`

### equals

    public boolean equals(Object obj)

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `Object`

### mark

    public void mark(int readlimit)

  Overrides:
    `mark` in class `InputStream`

### markSupported

    public boolean markSupported()

  Overrides:
    `markSupported` in class `InputStream`

### read

    public int read(byte[] b,
                    int off,
                    int len)
             throws IOException

  Overrides:
    `read` in class `InputStream`
  Throws:
    `IOException`

### read

    public int read(byte[] b)
             throws IOException

  Overrides:
    `read` in class `InputStream`
  Throws:
    `IOException`

### read

    public int read()
             throws IOException

  Specified by:
    `read` in class `InputStream`
  Throws:
    `IOException`

### reset

    public void reset()
               throws IOException

  Overrides:
    `reset` in class `InputStream`
  Throws:
    `IOException`

### skip

    public long skip(long n)
              throws IOException

  Overrides:
    `skip` in class `InputStream`
  Throws:
    `IOException`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ModeShape Distribution 3.0.0.Beta3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.