Version: 1.1.1

org.inb.biomoby.central.cache
Class CacheConfig

java.lang.Object
  extended by org.inb.biomoby.central.cache.CacheConfig

public class CacheConfig
extends Object

BioMoby Registry cache implementation. By default a cache location is in a $HOME/.MobyCentralCache/ directory, but may be overriden by providing a custom implementation of IMobyCentralCache interface.

Author:
Dmitry Repchevsky

Method Summary
static CacheConfig instance()
          A singleton instance creator.
 boolean isCached()
          Method to check whether a cache must be used
<T extends AbstractEntity>
List<T>
load(MobyCentral central, String file)
          Generic method to load BioMoby entities from a cache.
<T extends AbstractEntity>
List<T>
load(Reader reader)
          Generic method to load BioMoby entities from a cache.
<T extends AbstractEntity>
void
save(List<T> entities, MobyCentral central, String file)
          Generic method that saves any BioMoby entities ("Namespace", "Service", "ServiceType" and "ObjectType") to a cache file.
<T extends AbstractEntity>
void
save(List<T> entities, Writer writer)
          Generic method to save BioMoby entities to the provided writer
 void setCache(IMobyCentralCache cache)
          Method allows override a default cache location.
 void setCached(boolean isCached)
          Method to mark that a cache must be used.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isCached

public boolean isCached()
Method to check whether a cache must be used

Returns:
true if cache is enabled, false otherwise.

setCached

public void setCached(boolean isCached)
Method to mark that a cache must be used.

Parameters:
isCached - - true to enable a cache, false otherwise

setCache

public void setCache(IMobyCentralCache cache)
Method allows override a default cache location.

Parameters:
cache - - a custom cache implementation

save

public <T extends AbstractEntity> void save(List<T> entities,
                                            MobyCentral central,
                                            String file)
          throws Exception
Generic method that saves any BioMoby entities ("Namespace", "Service", "ServiceType" and "ObjectType") to a cache file.

Type Parameters:
T - - the entity type to save
Parameters:
entities - - the list of entities to be saved
central - - a BioMoby registry the cache belongs to
file - - a file name entities to be saved (for instance "MobyServiceList" ...)
Throws:
Exception

save

public <T extends AbstractEntity> void save(List<T> entities,
                                            Writer writer)
          throws Exception
Generic method to save BioMoby entities to the provided writer

Type Parameters:
T - - the entity type to save
Parameters:
entities - - the list of entities to be saved
writer - - the writer where entities are saved
Throws:
Exception

load

public <T extends AbstractEntity> List<T> load(MobyCentral central,
                                               String file)
                                    throws Exception
Generic method to load BioMoby entities from a cache.

Type Parameters:
T - - the entity type to be load from the cache
Parameters:
central - - a BioMoby registry the cache belongs to
file - - file name from which to load entities
Returns:
- a list of loaded entities
Throws:
Exception

load

public <T extends AbstractEntity> List<T> load(Reader reader)
                                    throws Exception
Generic method to load BioMoby entities from a cache.

Type Parameters:
T - - the entity type to be load from the cache
Parameters:
reader - - a reader to load entities from.
Returns:
- a list of loaded entities
Throws:
Exception

instance

public static CacheConfig instance()
A singleton instance creator. This is the only way to construct a CacheConfig object. The may be only one CacheConfig per application.

Returns:
a singleton CacheConfig object.

Version: 1.1.1

Submit a bug or feature
Generated: Sat May 29 04:26:35 EDT 2010