org.apache.jackrabbit.core.state.mem
Class InMemPersistenceManager

java.lang.Object
  extended byorg.apache.jackrabbit.core.state.AbstractPersistenceManager
      extended byorg.apache.jackrabbit.core.state.mem.InMemPersistenceManager
All Implemented Interfaces:
PersistenceManager

public class InMemPersistenceManager
extends AbstractPersistenceManager

InMemPersistenceManager is a very simple HashMap-based PersistenceManager for Jackrabbit that keeps all data in memory and that is capable of storing and loading its contents using a simple custom binary serialization format (see Serializer).

It is configured through the following properties:

Please note that this class should only be used for testing purposes.


Field Summary
protected  FileSystem blobFS
           
protected  BLOBStore blobStore
           
protected static int INITIAL_BUFFER_SIZE
           
protected  int initialCapacity
           
protected  boolean initialized
           
protected  float loadFactor
           
protected static byte NODE_ENTRY
           
protected  boolean persistent
           
protected static byte PROP_ENTRY
           
protected static String REFS_FILE_PATH
           
protected  Map refsStore
           
protected static String STATE_FILE_PATH
           
protected  Map stateStore
           
protected  FileSystem wspFS
          file system where the content of the hash maps are read from/written to (if persistent==true)
 
Constructor Summary
InMemPersistenceManager()
          Creates a new InMemPersistenceManager instance.
 
Method Summary
protected static String buildBlobFilePath(String parentUUID, QName propName, int index)
           
 void close()
          Closes the persistence manager. The consistency of the persistent storage is guaranteed and all acquired resources are released. It is an error to invoke any methods on a closed persistence manager, and implementations are free to enforce this constraint by throwing IllegalStateExceptions in such cases.

An appropriate exception is thrown if the persistence manager could not be closed properly. In this case the state of the persistence manager is undefined and the instance should be discarded.

protected  void destroy(NodeReferences refs)
          Destroy a node references object. Subclass responsibility.
protected  void destroy(NodeState state)
          Destroy a node state. Subclass responsibility.
protected  void destroy(PropertyState state)
          Destroy a property state. Subclass responsibility.
 boolean exists(NodeId id)
          Checks whether the identified node exists.
 boolean exists(NodeReferencesId id)
          Checks whether references of the identified target node exist.
 boolean exists(PropertyId id)
          Checks whether the identified property exists.
 String getInitialCapacity()
           
 String getLoadFactor()
           
 void init(PMContext context)
          Initializes the persistence manager. The persistence manager is permanently bound to the given context, and any required external resources are acquired.

An appropriate exception is thrown if the persistence manager initialization fails for whatever reason. In this case the state of the persistence manager is undefined and the instance should be discarded.

 boolean isPersistent()
           
 NodeState load(NodeId id)
          Load the persistent members of a node state.
 NodeReferences load(NodeReferencesId id)
          Load the persistent members of a node references object.
 PropertyState load(PropertyId id)
          Load the persistent members of a property state.
 void loadContents()
          Reads the content of the hash maps from the file system
 void setInitialCapacity(int initialCapacity)
           
 void setInitialCapacity(String initialCapacity)
           
 void setLoadFactor(float loadFactor)
           
 void setLoadFactor(String loadFactor)
           
 void setPersistent(boolean persistent)
           
 void setPersistent(String persistent)
           
protected  void store(NodeReferences refs)
          Store a references object. Subclass responsibility.
protected  void store(NodeState state)
          Store a node state. Subclass responsibility.
protected  void store(PropertyState state)
          Store a property state. Subclass responsibility.
 void storeContents()
          Writes the content of the hash maps to the file system
 
Methods inherited from class org.apache.jackrabbit.core.state.AbstractPersistenceManager
createNew, createNew, store
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

initialized

protected boolean initialized

stateStore

protected Map stateStore

refsStore

protected Map refsStore

INITIAL_BUFFER_SIZE

protected static final int INITIAL_BUFFER_SIZE
See Also:
Constant Field Values

STATE_FILE_PATH

protected static final String STATE_FILE_PATH
See Also:
Constant Field Values

REFS_FILE_PATH

protected static final String REFS_FILE_PATH
See Also:
Constant Field Values

NODE_ENTRY

protected static final byte NODE_ENTRY
See Also:
Constant Field Values

PROP_ENTRY

protected static final byte PROP_ENTRY
See Also:
Constant Field Values

blobFS

protected FileSystem blobFS

blobStore

protected BLOBStore blobStore

wspFS

protected FileSystem wspFS
file system where the content of the hash maps are read from/written to (if persistent==true)


initialCapacity

protected int initialCapacity

loadFactor

protected float loadFactor

persistent

protected boolean persistent
Constructor Detail

InMemPersistenceManager

public InMemPersistenceManager()
Creates a new InMemPersistenceManager instance.

Method Detail

setInitialCapacity

public void setInitialCapacity(int initialCapacity)

setInitialCapacity

public void setInitialCapacity(String initialCapacity)

getInitialCapacity

public String getInitialCapacity()

setLoadFactor

public void setLoadFactor(float loadFactor)

setLoadFactor

public void setLoadFactor(String loadFactor)

getLoadFactor

public String getLoadFactor()

isPersistent

public boolean isPersistent()

setPersistent

public void setPersistent(boolean persistent)

setPersistent

public void setPersistent(String persistent)

buildBlobFilePath

protected static String buildBlobFilePath(String parentUUID,
                                          QName propName,
                                          int index)

loadContents

public void loadContents()
                  throws Exception
Reads the content of the hash maps from the file system

Throws:
Exception - if an error occurs

storeContents

public void storeContents()
                   throws Exception
Writes the content of the hash maps to the file system

Throws:
Exception - if an error occurs

init

public void init(PMContext context)
          throws Exception
Initializes the persistence manager. The persistence manager is permanently bound to the given context, and any required external resources are acquired.

An appropriate exception is thrown if the persistence manager initialization fails for whatever reason. In this case the state of the persistence manager is undefined and the instance should be discarded.

Parameters:
context - persistence manager context
Throws:
Exception - if the persistence manager intialization failed

close

public void close()
           throws Exception
Closes the persistence manager. The consistency of the persistent storage is guaranteed and all acquired resources are released. It is an error to invoke any methods on a closed persistence manager, and implementations are free to enforce this constraint by throwing IllegalStateExceptions in such cases.

An appropriate exception is thrown if the persistence manager could not be closed properly. In this case the state of the persistence manager is undefined and the instance should be discarded.

Throws:
Exception - if the persistence manager failed to close properly

load

public NodeState load(NodeId id)
               throws NoSuchItemStateException,
                      ItemStateException
Load the persistent members of a node state.

Parameters:
id - node id
Returns:
loaded node state
Throws:
NoSuchItemStateException - if the node state does not exist
ItemStateException - if another error occurs

load

public PropertyState load(PropertyId id)
                   throws NoSuchItemStateException,
                          ItemStateException
Load the persistent members of a property state.

Parameters:
id - property id
Returns:
loaded property state
Throws:
NoSuchItemStateException - if the property state does not exist
ItemStateException - if another error occurs

store

protected void store(NodeState state)
              throws ItemStateException
Store a node state. Subclass responsibility.

Specified by:
store in class AbstractPersistenceManager
Parameters:
state - node state to store
Throws:
ItemStateException - if an error occurs

store

protected void store(PropertyState state)
              throws ItemStateException
Store a property state. Subclass responsibility.

Specified by:
store in class AbstractPersistenceManager
Parameters:
state - property state to store
Throws:
ItemStateException - if an error occurs

destroy

protected void destroy(NodeState state)
                throws ItemStateException
Destroy a node state. Subclass responsibility.

Specified by:
destroy in class AbstractPersistenceManager
Parameters:
state - node state to destroy
Throws:
ItemStateException - if an error occurs

destroy

protected void destroy(PropertyState state)
                throws ItemStateException
Destroy a property state. Subclass responsibility.

Specified by:
destroy in class AbstractPersistenceManager
Parameters:
state - property state to destroy
Throws:
ItemStateException - if an error occurs

load

public NodeReferences load(NodeReferencesId id)
                    throws NoSuchItemStateException,
                           ItemStateException
Load the persistent members of a node references object.

Parameters:
id - reference target node id
Throws:
ItemStateException - if another error occurs
NoSuchItemStateException - if the target node does not exist

store

protected void store(NodeReferences refs)
              throws ItemStateException
Store a references object. Subclass responsibility.

Specified by:
store in class AbstractPersistenceManager
Parameters:
refs - references object to store
Throws:
ItemStateException - if an error occurs

destroy

protected void destroy(NodeReferences refs)
                throws ItemStateException
Destroy a node references object. Subclass responsibility.

Specified by:
destroy in class AbstractPersistenceManager
Parameters:
refs - node references object to destroy
Throws:
ItemStateException - if an error occurs

exists

public boolean exists(PropertyId id)
               throws ItemStateException
Checks whether the identified property exists.

Parameters:
id - property id
Returns:
true if the property exists, false otherwise
Throws:
ItemStateException - on persistence manager errors

exists

public boolean exists(NodeId id)
               throws ItemStateException
Checks whether the identified node exists.

Parameters:
id - node id
Returns:
true if the node exists, false otherwise
Throws:
ItemStateException - on persistence manager errors

exists

public boolean exists(NodeReferencesId id)
               throws ItemStateException
Checks whether references of the identified target node exist.

Parameters:
id - target node id
Returns:
true if the references exist, false otherwise
Throws:
ItemStateException - on persistence manager errors


Copyright © 2004-2006 The Apache Software Foundation. All Rights Reserved.