|
||||||||||
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 it's 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 '*' '<' '>' '|' '"' '?' and also '\' '/' and ':' |
protected StripedLock |
lock
|
static java.util.regex.Pattern |
PATH_PATTERN
For full path, check '*' '<' '>' '|' '"' '?' Regex: [\*<>|"?] |
Fields inherited from class org.jboss.cache.loader.AbstractCacheLoader |
---|
cache, regionManager |
Constructor Summary | |
---|---|
FileCacheLoader()
|
Method Summary | |
---|---|
void |
commit(java.lang.Object tx)
Commits the transaction. |
void |
create()
Lifecycle method, called when the cache loader is created. |
void |
destroy()
Lifecycle method, called when the cache loader is destroyed. |
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 |
java.util.Set<java.lang.String> |
getChildrenNames(Fqn fqn)
Returns a set of children node names. |
CacheLoaderConfig.IndividualCacheLoaderConfig |
getConfig()
Gets the configuration. |
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)
|
protected void |
marshall(java.lang.Object obj,
java.io.File to)
|
void |
prepare(java.lang.Object tx,
java.util.List<Modification> modifications,
boolean one_phase)
Prepares a list of modifications. |
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 |
rollback(java.lang.Object tx)
Rolls the transaction back. |
void |
setConfig(CacheLoaderConfig.IndividualCacheLoaderConfig base)
Sets the configuration. |
void |
start()
Lifecycle method, called when the cache loader is started. |
void |
stop()
Lifecycle method, called when the cache loader is stopped. |
protected void |
storeAttributes(Fqn fqn,
java.util.Map attrs)
|
protected java.lang.Object |
unmarshall(java.io.File from)
|
Methods inherited from class org.jboss.cache.loader.AbstractCacheLoader |
---|
getMarshaller, getNodeDataList, loadEntireState, loadState, loadStateHelper, put, setCache, setRegionManager, storeEntireState, storeState |
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
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
CacheLoaderConfig.IndividualCacheLoaderConfig.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
CacheLoader
java.lang.Exception
public void start() throws java.lang.Exception
CacheLoader
java.lang.Exception
public void stop()
CacheLoader
public void destroy()
CacheLoader
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
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
public void prepare(java.lang.Object tx, java.util.List<Modification> modifications, boolean one_phase) throws java.lang.Exception
CacheLoader
tx
(tx is the key)
tx
- The transaction, indended to be used by implementations as an identifier of the transaction (and not necessarily a JTA Transaction
object)modifications
- A List
containing Modification
s, for the given transactionone_phase
- Persist immediately and (for example) commit the local JDBC transaction as well. When true,
we won't get a CacheLoader.commit(Object)
or CacheLoader.rollback(Object)
method call later
java.lang.Exception
public void commit(java.lang.Object tx) throws java.lang.Exception
CacheLoader
tx
and commit that
transaction. Non-transactional CacheLoaders could simply write the data
that was previously saved transiently under the given tx
key, to (for example) a file system.
Note this only holds if the previous prepare() did not define one_phase=true
tx
- transaction to commit
java.lang.Exception
public void rollback(java.lang.Object tx)
CacheLoader
tx
and roll back that
transaction.
tx
- transaction to roll backprotected 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 boolean isCharacterPortableLocation(java.lang.String fileAbsolutePath)
protected boolean isCharacterPortableTree(Fqn fqn)
protected boolean isLengthPortablePath(java.lang.String absoluteFqnPath)
protected java.lang.Object unmarshall(java.io.File from) throws java.lang.Exception
java.lang.Exception
protected void marshall(java.lang.Object obj, java.io.File to) throws java.lang.Exception
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |