|
||||||||||
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 java.lang.String |
DATA
CacheImpl data file. |
static java.lang.String |
DIR_SUFFIX
CacheImpl directory suffix. |
static java.util.regex.Pattern |
FQN_PATTERN
For fqn, check '*' '<' '>' '|' '"' '?' |
protected StripedLock |
lock
|
static java.util.regex.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()
|
protected void |
doMarshall(Fqn fqn,
java.lang.Object toMarshall)
|
protected java.lang.Object |
doUnmarshall(Fqn fqn,
java.lang.Object fromFile)
|
boolean |
exists(Fqn fqn)
Returns true if the CacheLoader has a node with a Fqn . |
java.util.Map |
get(Fqn fqn)
Returns all keys and values from the persistent store, given a Fqn |
CacheLoaderConfig.IndividualCacheLoaderConfig |
getConfig()
Gets the configuration. |
java.util.Set<java.lang.String> |
getChildrenNames(Fqn fqn)
Returns a set of children node names. |
protected boolean |
isCharacterPortableLocation(java.lang.String fileAbsolutePath)
|
protected boolean |
isCharacterPortableTree(Fqn fqn)
|
protected boolean |
isLengthPortablePath(java.lang.String absoluteFqnPath)
|
protected java.util.Map |
loadAttributes(Fqn fqn)
|
void |
put(Fqn fqn,
java.util.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,
java.util.Map attributes,
boolean erase)
|
java.lang.Object |
put(Fqn fqn,
java.lang.Object key,
java.lang.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. |
java.lang.Object |
remove(Fqn fqn,
java.lang.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,
java.util.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 java.lang.String DATA
public static final java.lang.String DIR_SUFFIX
public static final java.util.regex.Pattern PATH_PATTERN
public static final java.util.regex.Pattern FQN_PATTERN
Constructor Detail |
---|
public FileCacheLoader()
Method Detail |
---|
public void setConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
CacheLoader
Lifecycle.create()
and Lifecycle.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 java.lang.Exception
create
in interface Lifecycle
create
in class AbstractCacheLoader
java.lang.Exception
public java.util.Set<java.lang.String> getChildrenNames(Fqn fqn) throws java.lang.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
java.lang.Exception
public java.util.Map get(Fqn fqn) throws java.lang.Exception
CacheLoader
Fqn
fqn
- the Fqn
to search for.
public boolean exists(Fqn fqn) throws java.lang.Exception
CacheLoader
Fqn
.
java.lang.Exception
public java.lang.Object put(Fqn fqn, java.lang.Object key, java.lang.Object value) throws java.lang.Exception
CacheLoader
java.lang.Exception
public void put(Fqn fqn, java.util.Map attributes) throws java.lang.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
java.lang.Exception
public void put(Fqn fqn, java.util.Map attributes, boolean erase) throws java.lang.Exception
put
in class AbstractCacheLoader
java.lang.Exception
public java.lang.Object remove(Fqn fqn, java.lang.Object key) throws java.lang.Exception
CacheLoader
java.lang.Exception
public void remove(Fqn fqn) throws java.lang.Exception
CacheLoader
fqn
- the Fqn
of the node
java.lang.Exception
public void removeData(Fqn fqn) throws java.lang.Exception
CacheLoader
fqn
- the Fqn
of the node
java.lang.Exception
protected java.util.Map loadAttributes(Fqn fqn) throws java.lang.Exception
java.lang.Exception
protected void storeAttributes(Fqn fqn, java.util.Map attrs) throws java.lang.Exception
java.lang.Exception
protected void doMarshall(Fqn fqn, java.lang.Object toMarshall) throws java.lang.Exception
doMarshall
in class AbstractCacheLoader
java.lang.Exception
protected java.lang.Object doUnmarshall(Fqn fqn, java.lang.Object fromFile) throws java.lang.Exception
doUnmarshall
in class AbstractCacheLoader
java.lang.Exception
protected boolean isCharacterPortableLocation(java.lang.String fileAbsolutePath)
protected boolean isCharacterPortableTree(Fqn fqn)
protected boolean isLengthPortablePath(java.lang.String absoluteFqnPath)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |