Smack

org.jivesoftware.smackx.entitycaps.cache
Class SimpleDirectoryPersistentCache

java.lang.Object
  extended by org.jivesoftware.smackx.entitycaps.cache.SimpleDirectoryPersistentCache
All Implemented Interfaces:
EntityCapsPersistentCache

public class SimpleDirectoryPersistentCache
extends Object
implements EntityCapsPersistentCache

Simple implementation of an EntityCapsPersistentCache that uses a directory to store the Caps information for every known node. Every node is represented by an file.

Author:
Florian Schmaus

Constructor Summary
SimpleDirectoryPersistentCache(File cacheDir)
          Creates a new SimpleDirectoryPersistentCache Object.
SimpleDirectoryPersistentCache(File cacheDir, StringEncoder filenameEncoder)
          Creates a new SimpleDirectoryPersistentCache Object.
 
Method Summary
 void addDiscoverInfoByNodePersistent(String node, DiscoverInfo info)
          Add an DiscoverInfo to the persistent Cache
 void emptyCache()
          Empty the Cache
 void replay()
          Replay the Caches data into EntityCapsManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleDirectoryPersistentCache

public SimpleDirectoryPersistentCache(File cacheDir)
Creates a new SimpleDirectoryPersistentCache Object. Make sure that the cacheDir exists and that it's an directory.

Default filename encoder Base32Encoder, as this will work on all filesystems, both case sensitive and case insensitive. It does however produce longer filenames.

Parameters:
cacheDir -

SimpleDirectoryPersistentCache

public SimpleDirectoryPersistentCache(File cacheDir,
                                      StringEncoder filenameEncoder)
Creates a new SimpleDirectoryPersistentCache Object. Make sure that the cacheDir exists and that it's an directory. If your cacheDir is case insensitive then make sure to set the StringEncoder to Base32Encoder (which is the default).

Parameters:
cacheDir - The directory where the cache will be stored.
filenameEncoder - Encodes the node string into a filename.
Method Detail

addDiscoverInfoByNodePersistent

public void addDiscoverInfoByNodePersistent(String node,
                                            DiscoverInfo info)
Description copied from interface: EntityCapsPersistentCache
Add an DiscoverInfo to the persistent Cache

Specified by:
addDiscoverInfoByNodePersistent in interface EntityCapsPersistentCache

replay

public void replay()
            throws IOException
Description copied from interface: EntityCapsPersistentCache
Replay the Caches data into EntityCapsManager

Specified by:
replay in interface EntityCapsPersistentCache
Throws:
IOException

emptyCache

public void emptyCache()
Description copied from interface: EntityCapsPersistentCache
Empty the Cache

Specified by:
emptyCache in interface EntityCapsPersistentCache

Smack

Copyright © 2003-2007 Jive Software.