org.jboss.virtual.plugins.cache
Class CachePolicyVFSCache<T extends org.jboss.util.CachePolicy>

java.lang.Object
  extended by org.jboss.virtual.plugins.cache.AbstractVFSCache
      extended by org.jboss.virtual.plugins.cache.PathMatchingVFSCache
          extended by org.jboss.virtual.plugins.cache.CachePolicyVFSCache<T>
Type Parameters:
T - exact policy type
All Implemented Interfaces:
CacheStatistics, VFSCache
Direct Known Subclasses:
LRUVFSCache, TimedVFSCache

public abstract class CachePolicyVFSCache<T extends org.jboss.util.CachePolicy>
extends PathMatchingVFSCache

Cache policy vfs cache.

Author:
Ales Justin

Field Summary
 
Fields inherited from class org.jboss.virtual.plugins.cache.AbstractVFSCache
log
 
Constructor Summary
protected CachePolicyVFSCache()
           
protected CachePolicyVFSCache(Map<Object,Object> properties)
           
 
Method Summary
protected  void check()
          Is cache valid.
protected abstract  T createCachePolicy()
          Create cache policy.
 void flush()
          Flush the cache.
 Iterable<VFSContext> getCachedContexts()
          Get cached contexts.
protected  VFSContext getContext(String path)
          Get the cached context.
protected static Integer getInteger(Object value)
          Get integer from value.
protected  T getPolicy()
          Get the policy.
protected static Integer parseInteger(String value)
          Parse integer.
protected  void putContext(String path, VFSContext context)
          Put vfs context and its path key into cache.
protected  Object readInstanceProperties(String key, Object defaultValue, boolean useSystemProperties)
          Read instance properties.
protected static String readSystemProperty(String key, String defaultValue)
          Read system property.
 void removeContext(String key, VFSContext context)
          Remove vfs context and its path key from cache.
 int size()
          Get cache size.
 void start()
          Start the cache.
 void stop()
          Stop the cache.
 
Methods inherited from class org.jboss.virtual.plugins.cache.PathMatchingVFSCache
findContext
 
Methods inherited from class org.jboss.virtual.plugins.cache.AbstractVFSCache
findContext, lastInsert, putContext, readLock, readUnlock, removeContext, writeLock, writeUnlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachePolicyVFSCache

protected CachePolicyVFSCache()

CachePolicyVFSCache

protected CachePolicyVFSCache(Map<Object,Object> properties)
Method Detail

getCachedContexts

public Iterable<VFSContext> getCachedContexts()
Description copied from interface: CacheStatistics
Get cached contexts.

Returns:
the cached contexts

size

public int size()
Description copied from interface: CacheStatistics
Get cache size.

Returns:
the cache size

getPolicy

protected T getPolicy()
Get the policy. Run check before.

Returns:
the policy

check

protected void check()
Description copied from class: AbstractVFSCache
Is cache valid.

Specified by:
check in class AbstractVFSCache

start

public void start()
           throws Exception
Description copied from interface: VFSCache
Start the cache.

Throws:
Exception - for any error

stop

public void stop()
Description copied from interface: VFSCache
Stop the cache.


flush

public void flush()
Description copied from interface: VFSCache
Flush the cache.


getContext

protected VFSContext getContext(String path)
Description copied from class: AbstractVFSCache
Get the cached context.

Specified by:
getContext in class AbstractVFSCache
Parameters:
path - the path to match
Returns:
cached context or null if not found

putContext

protected void putContext(String path,
                          VFSContext context)
Description copied from class: AbstractVFSCache
Put vfs context and its path key into cache.

Specified by:
putContext in class AbstractVFSCache
Parameters:
path - the context's path
context - the vfs context

removeContext

public void removeContext(String key,
                          VFSContext context)
Description copied from class: AbstractVFSCache
Remove vfs context and its path key from cache.

Specified by:
removeContext in class AbstractVFSCache
Parameters:
key - the context's path
context - the vfs context

createCachePolicy

protected abstract T createCachePolicy()
Create cache policy.

Returns:
the cache policy

readInstanceProperties

protected Object readInstanceProperties(String key,
                                        Object defaultValue,
                                        boolean useSystemProperties)
Read instance properties.

Parameters:
key - the property key
defaultValue - the default value
useSystemProperties - do we fallback to system properties
Returns:
property or default value

readSystemProperty

protected static String readSystemProperty(String key,
                                           String defaultValue)
Read system property.

Parameters:
key - the property key
defaultValue - the default value
Returns:
system property or default value

parseInteger

protected static Integer parseInteger(String value)
Parse integer.

Parameters:
value - the string int value
Returns:
integer value or null

getInteger

protected static Integer getInteger(Object value)
Get integer from value.

Parameters:
value - the value
Returns:
integer value or null


Copyright © 2010 JBoss, A division of Red Hat, Inc. All Rights Reserved.