|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.cache.loader.AbstractCacheLoader
org.jboss.cache.loader.FileCacheLoader
@ThreadSafe public class FileCacheLoader
Simple file-based CacheLoader implementation. Nodes are directories, attributes of a node is a file in the directory
The FileCacheLoader has some severe limitations which restrict its use in a production environment, or if used in such an environment, it should be used with due care and sufficient understanding of these limitations.CacheLoader
, this implementation uses a StripedLock
Field Summary | |
---|---|
static String |
DATA
CacheImpl data file. |
static String |
DIR_SUFFIX
CacheImpl directory suffix. |
static Pattern |
FQN_PATTERN
For fqn, check '*' '<' '>' '|' '"' '?' |
protected StripedLock |
lock
|
static Pattern |
PATH_PATTERN
For full path, check '*' '<' '>' '|' '"' '?' |
Fields inherited from class org.jboss.cache.loader.AbstractCacheLoader |
---|
buddyFqnTransformer, cache, regionManager, transactions |
Constructor Summary | |
---|---|
FileCacheLoader()
|
Method Summary | |
---|---|
void |
create()
Lifecycle method, called when the cache loader is created. |
protected void |
doMarshall(Fqn fqn,
Object toMarshall)
|
protected Object |
doUnmarshall(Fqn fqn,
Object fromFile)
|
boolean |
exists(Fqn fqn)
Returns true if the CacheLoader has a node with a Fqn . |
Map |
get(Fqn fqn)
Returns all keys and values from the persistent store, given a Fqn |
CacheLoaderConfig.IndividualCacheLoaderConfig |
getConfig()
Gets the configuration. |
Set<String> |
getChildrenNames(Fqn fqn)
Returns a set of children node names. |
protected boolean |
isCharacterPortableLocation(String fileAbsolutePath)
|
protected boolean |
isCharacterPortableTree(Fqn fqn)
|
protected boolean |
isLengthPortablePath(String absoluteFqnPath)
|
protected Map |
loadAttributes(Fqn fqn)
|
void |
put(Fqn fqn,
Map attributes)
Puts all entries of the map into the existing map of the given node, overwriting existing keys, but not clearing the existing map before insertion. |
void |
put(Fqn fqn,
Map attributes,
boolean erase)
|
Object |
put(Fqn fqn,
Object key,
Object value)
Puts a key and value into the attribute map of a given node. |
void |
remove(Fqn fqn)
Removes the given node and all its subnodes, does nothing if the node does not exist. |
Object |
remove(Fqn fqn,
Object key)
Removes the given key and value from the attributes of the given node. |
void |
removeData(Fqn fqn)
Removes all attributes from a given node, but doesn't delete the node itself or any subnodes. |
void |
setConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
Sets the configuration. |
protected void |
storeAttributes(Fqn fqn,
Map attrs)
|
Methods inherited from class org.jboss.cache.loader.AbstractCacheLoader |
---|
commit, destroy, getMarshaller, getNodeDataList, loadEntireState, loadState, loadStateHelper, move, prepare, put, regionAwareMarshall, regionAwareUnmarshall, rollback, setCache, setRegionManager, start, stop, storeEntireState, storeState, storeStateHelper |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final StripedLock lock
public static final String DATA
public static final String DIR_SUFFIX
public static final Pattern PATH_PATTERN
public static final Pattern FQN_PATTERN
Constructor Detail |
---|
public FileCacheLoader()
Method Detail |
---|
public void setConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
CacheLoader
CacheLoader.create()
and CacheLoader.start()
.
base
- May be an instance of the CacheLoaderConfig.IndividualCacheLoaderConfig
base
class, in which case the cache loader should use the
PluggableConfigurationComponent.getProperties()
method to find configuration information. Alternatively,
may be a type-specific subclass of CacheLoaderConfig.IndividualCacheLoaderConfig
,
if there is one.public CacheLoaderConfig.IndividualCacheLoaderConfig getConfig()
CacheLoader
CacheLoaderConfig.IndividualCacheLoaderConfig
object.public void create() throws Exception
CacheLoader
create
in interface CacheLoader
create
in class AbstractCacheLoader
Exception
public Set<String> getChildrenNames(Fqn fqn) throws Exception
CacheLoader
Fqn
.
Returns null if the named node is not found or there are no children.
The returned set must not be modifiable. Implementors can use
Collections.unmodifiableSet(java.util.Set)
to make the set unmodifiable.
Implementors may impose restrictions on the contents of an Fqn (such as Strings-only) and as such, indirectly
impose the same restriction on the contents of a Set returned by getChildrenNames().
fqn
- The Fqn
of the parent
Exception
public Map get(Fqn fqn) throws Exception
CacheLoader
Fqn
fqn
- the Fqn
to search for.
public boolean exists(Fqn fqn) throws Exception
CacheLoader
Fqn
.
Exception
public Object put(Fqn fqn, Object key, Object value) throws Exception
CacheLoader
Exception
public void put(Fqn fqn, Map attributes) throws Exception
CacheLoader
Map.putAll(java.util.Map extends K, ? extends V>)
.
If the node does not exist, all parent nodes from the root down are created automatically
Note since 3.0, as an optimization, this method will require a definitive attribute map and
not just a subset. This will allow cache loader implementations to overwrite rather than merge, if that is
deemed more efficient. This will not break backward compatibility since performing a merge will not cause
any loss of data even though it is an unnecessary step.
fqn
- The fully qualified name of the nodeattributes
- A Map of attributes. Can be null
Exception
public void put(Fqn fqn, Map attributes, boolean erase) throws Exception
put
in class AbstractCacheLoader
Exception
public Object remove(Fqn fqn, Object key) throws Exception
CacheLoader
Exception
public void remove(Fqn fqn) throws Exception
CacheLoader
fqn
- the Fqn
of the node
Exception
public void removeData(Fqn fqn) throws Exception
CacheLoader
fqn
- the Fqn
of the node
Exception
protected Map loadAttributes(Fqn fqn) throws Exception
Exception
protected void storeAttributes(Fqn fqn, Map attrs) throws Exception
Exception
protected void doMarshall(Fqn fqn, Object toMarshall) throws Exception
doMarshall
in class AbstractCacheLoader
Exception
protected Object doUnmarshall(Fqn fqn, Object fromFile) throws Exception
doUnmarshall
in class AbstractCacheLoader
Exception
protected boolean isCharacterPortableLocation(String fileAbsolutePath)
protected boolean isCharacterPortableTree(Fqn fqn)
protected boolean isLengthPortablePath(String absoluteFqnPath)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |