org.outerj.daisy.blobstore.impl
Class FSBlobStore

java.lang.Object
  extended by org.outerj.daisy.blobstore.impl.FSBlobStore
All Implemented Interfaces:
org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.configuration.Configurable, BlobStore

public class FSBlobStore
extends java.lang.Object
implements BlobStore, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Initializable

Implementation of BlobStore that stores blobs in a directory on the filesystem.

This class in an Avalon component, and hence its lifecycle interfaces should be respected before being used.


Constructor Summary
FSBlobStore()
           
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration configuration)
           
 void delete(java.lang.String name)
           
 EDU.oswego.cs.dl.util.concurrent.Sync getAvoidSuspendLock()
          Returns a lock which can be acquired to avoid that the BlobStore can go into suspension while you have this lock.
 void initialize()
           
 void resumeWrites()
          Resumes write operations (after being suspended with BlobStore.suspendWrites(long).
 java.io.InputStream retrieve(java.lang.String name)
          The caller is responsible himself that a file is not being read before it is completely written.
 java.lang.String store(byte[] data)
          Returns an auto-generated key by which the blob can later be retrieved.
 java.lang.String store(java.io.InputStream is)
          Returns an auto-generated key by which the blob can later be retrieved.
 boolean suspendWrites(long msecs)
          Suspends all write operations to the blob store, after calling this method only read operation will be allowed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FSBlobStore

public FSBlobStore()
Method Detail

configure

public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

initialize

public void initialize()
                throws java.lang.Exception
Specified by:
initialize in interface org.apache.avalon.framework.activity.Initializable
Throws:
java.lang.Exception

delete

public void delete(java.lang.String name)
            throws NonExistingBlobException
Specified by:
delete in interface BlobStore
Throws:
NonExistingBlobException

store

public java.lang.String store(byte[] data)
                       throws BlobIOException
Description copied from interface: BlobStore
Returns an auto-generated key by which the blob can later be retrieved.

Specified by:
store in interface BlobStore
Throws:
BlobIOException

store

public java.lang.String store(java.io.InputStream is)
                       throws BlobIOException
Description copied from interface: BlobStore
Returns an auto-generated key by which the blob can later be retrieved. The InputStream will be closed for you.

Specified by:
store in interface BlobStore
Throws:
BlobIOException

retrieve

public java.io.InputStream retrieve(java.lang.String name)
                             throws BlobIOException,
                                    NonExistingBlobException
Description copied from interface: BlobStore
The caller is responsible himself that a file is not being read before it is completely written. The caller is also responsible for making sure the stream gets closed, otherwise resource might leak (thus: always in a try-catch block!).

Specified by:
retrieve in interface BlobStore
Throws:
BlobIOException
NonExistingBlobException

suspendWrites

public boolean suspendWrites(long msecs)
                      throws java.lang.InterruptedException
Description copied from interface: BlobStore
Suspends all write operations to the blob store, after calling this method only read operation will be allowed. This method only returns after all active write operations have been finished.

Specified by:
suspendWrites in interface BlobStore
Parameters:
msecs - max time to wait for active write operations to finish
Throws:
java.lang.InterruptedException

resumeWrites

public void resumeWrites()
Description copied from interface: BlobStore
Resumes write operations (after being suspended with BlobStore.suspendWrites(long).

Specified by:
resumeWrites in interface BlobStore

getAvoidSuspendLock

public EDU.oswego.cs.dl.util.concurrent.Sync getAvoidSuspendLock()
Description copied from interface: BlobStore
Returns a lock which can be acquired to avoid that the BlobStore can go into suspension while you have this lock.

Specified by:
getAvoidSuspendLock in interface BlobStore


Copyright © -2012 . All Rights Reserved.