org.jboss.soa.esb.listeners.gateway.remotestrategies.cache
Class FtpFileCache

java.lang.Object
  extended by org.jboss.soa.esb.listeners.gateway.remotestrategies.cache.FtpFileCache

public class FtpFileCache
extends java.lang.Object

Implements a cache of file names which can be replicated in a cluster. See the JBoss Cache docs for details on configuring the cache.

Author:
Daniel Bevenius

Constructor Summary
FtpFileCache(java.lang.String config)
           
 
Method Summary
 void addCacheListener(org.jboss.cache.TreeCacheListener listener)
           
 boolean containsFile(java.lang.String fileName)
          Checks to see if the filename exists in the cache
 java.lang.Object deleteFile(java.lang.String fileName)
          Removed the fileName from the cache if it exist there
 void destroy()
           
 java.lang.String getCache()
          Gets the a string of all files in the cache
 java.util.Map getCacheListeners()
           
 java.lang.String getConfigFile()
           
protected  java.io.InputStream getConfigInputStream(java.lang.String path)
          Gets an input stream from the specified path.
 java.lang.Object getFileName(java.lang.String fileName)
          Will get the filename if it exists in the cache.
 java.lang.String getFqn()
           
 void putFileName(java.lang.String fileName)
          Will add the filename to the cache.
 void removeAll()
          Removes all data under the fqn, but not the fqn itself
 void setCacheListener(java.lang.Class cacheListenerClass)
           
 void setDeleteOnEviction()
           
 void setFqn(java.lang.String fqn)
           
 void start()
          Start the cache
 void stop()
          Stops the cache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FtpFileCache

public FtpFileCache(java.lang.String config)
             throws FtpFileCacheException
Parameters:
config - either an absolute path of a relative path
Throws:
java.lang.Exception
FtpFileCacheException
Method Detail

getConfigInputStream

protected java.io.InputStream getConfigInputStream(java.lang.String path)
Gets an input stream from the specified path. If the path denotes a file on the filesystem, that file will be used. If a file is not found in the filesystem, this method will look for the file on the classpath.

Parameters:
path - the path to the JBossCache configuration file
Returns:
InputStream the inputstream for the passed-in path

start

public void start()
           throws FtpFileCacheException
Start the cache

Throws:
java.lang.Exception
FtpFileCacheException

stop

public void stop()
Stops the cache


putFileName

public void putFileName(java.lang.String fileName)
                 throws org.jboss.cache.CacheException
Will add the filename to the cache.

Parameters:
fileName -
Throws:
org.jboss.cache.CacheException

getFileName

public java.lang.Object getFileName(java.lang.String fileName)
                             throws org.jboss.cache.CacheException
Will get the filename if it exists in the cache.

Parameters:
fileName -
Throws:
org.jboss.cache.CacheException

deleteFile

public java.lang.Object deleteFile(java.lang.String fileName)
                            throws org.jboss.cache.CacheException
Removed the fileName from the cache if it exist there

Parameters:
fileName -
Returns:
Object the value of the removed object
Throws:
org.jboss.cache.CacheException

containsFile

public boolean containsFile(java.lang.String fileName)
Checks to see if the filename exists in the cache

Parameters:
fileName - the filename to look for
Returns:
true if the file exists in the cache

getCache

public java.lang.String getCache()
Gets the a string of all files in the cache

Returns:
String

getFqn

public java.lang.String getFqn()

setFqn

public void setFqn(java.lang.String fqn)

getConfigFile

public java.lang.String getConfigFile()

removeAll

public void removeAll()
               throws org.jboss.cache.CacheException
Removes all data under the fqn, but not the fqn itself

Throws:
org.jboss.cache.CacheException

setDeleteOnEviction

public void setDeleteOnEviction()

addCacheListener

public void addCacheListener(org.jboss.cache.TreeCacheListener listener)

getCacheListeners

public java.util.Map getCacheListeners()

setCacheListener

public void setCacheListener(java.lang.Class cacheListenerClass)
                      throws FtpFileCacheException
Throws:
FtpFileCacheException

destroy

public void destroy()