org.sapia.filestorm.file
Class CachingFileStore

java.lang.Object
  extended by org.sapia.filestorm.file.FileStore
      extended by org.sapia.filestorm.file.CachingFileStore
All Implemented Interfaces:
Store

public class CachingFileStore
extends FileStore

An instance of this class implements caching over another Store - the other store acts as a master copy.

An instance of this class uses the local file system to keep cached data. That cached data is synchronized with the delegate store after a given period of time.

Author:
yduchesne

Field Summary
 
Fields inherited from class org.sapia.filestorm.file.FileStore
_baseDir, _bufsz, _log
 
Constructor Summary
CachingFileStore(File baseDir, Store delegate, long timeout, int bufSize)
           
 
Method Summary
 void close()
          Closes this instance.
 boolean contains(String name)
           
 InputStream get(String name)
           
 void get(String name, OutputStream out)
          Streams the data corresponding to the given name into the given stream.
 void notifyDelete(String name)
           
 void notifyUpdate(String name)
           
 
Methods inherited from class org.sapia.filestorm.file.FileStore
cleanup, delete, getContentLength, getLastModified, list, put, put
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingFileStore

public CachingFileStore(File baseDir,
                        Store delegate,
                        long timeout,
                        int bufSize)
                 throws IOException
Parameters:
baseDir - the base directory of this instance.
delegate - the delegate Store - with which this instance's state is to be synchronized.
timeout - the timeout after which given data is to be synchronized with the delegate instance.
bufSize - the size of buffers that are internally used for data transfer.
Throws:
IOException - if an IO problem occurs when creating the instance.
Method Detail

get

public InputStream get(String name)
                throws IOException
Specified by:
get in interface Store
Overrides:
get in class FileStore
Parameters:
name - the name corresponding to the data to retrieve.
Returns:
the stream of data corresponding to the given name.
Throws:
IOException - if an IO problem occurs while performing this operation.
FileNotFoundException - if no data exists for the given name.

get

public void get(String name,
                OutputStream out)
         throws FileNotFoundException,
                IOException
Description copied from interface: Store
Streams the data corresponding to the given name into the given stream. The stream is closed by this method.

Specified by:
get in interface Store
Overrides:
get in class FileStore
Parameters:
name - the name corresponding to the data to retrieve.
out - an OutputStream to which the data is to be written.
Throws:
FileNotFoundException - if no data exists for the given name.
IOException - if an IO problem occurs while performing this operation.

contains

public boolean contains(String name)
                 throws IOException
Specified by:
contains in interface Store
Overrides:
contains in class FileStore
Parameters:
name - the name corresponding to the data whose existence must be checked.
Returns:
true if data exists for the given name, false otherwise.
Throws:
IOException

close

public void close()
Description copied from interface: Store
Closes this instance.

Specified by:
close in interface Store
Overrides:
close in class FileStore

notifyUpdate

public void notifyUpdate(String name)

notifyDelete

public void notifyDelete(String name)


Copyright © 2007 Sapia Open Community, Inc. All Rights Reserved.