org.apache.jackrabbit.core.state.obj
Class ObjectPersistenceManager

java.lang.Object
  extended byorg.apache.jackrabbit.core.state.AbstractPersistenceManager
      extended byorg.apache.jackrabbit.core.state.obj.ObjectPersistenceManager
All Implemented Interfaces:
BLOBStore, PersistenceManager

public class ObjectPersistenceManager
extends AbstractPersistenceManager
implements BLOBStore

ObjectPersistenceManager is a FileSystem-based PersistenceManager that persists ItemState and NodeReferences objects using a simple custom serialization format.


Constructor Summary
ObjectPersistenceManager()
          Creates a new ObjectPersistenceManager instance.
 
Method Summary
 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.

static void deserialize(NodeReferences refs, InputStream stream)
          Deserializes a NodeReferences object from the given stream.
static void deserialize(NodeState state, InputStream stream)
          Deserializes a state object from the given stream.
static void deserialize(PropertyState state, InputStream stream, BLOBStore blobStore)
          Deserializes a state object from the given stream.
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.
 FileSystemResource get(String blobId)
          
 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.

 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.
 String put(PropertyId id, int index, InputStream in, long size)
          
 boolean remove(String blobId)
          
static void serialize(NodeReferences refs, OutputStream stream)
          Serializes the specified NodeReferences object to the given stream.
static void serialize(NodeState state, OutputStream stream)
          Serializes the specified state object to the given stream.
static void serialize(PropertyState state, OutputStream stream, BLOBStore blobStore)
          Serializes the specified state object to the given stream.
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.
 
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
 

Constructor Detail

ObjectPersistenceManager

public ObjectPersistenceManager()
Creates a new ObjectPersistenceManager instance.

Method Detail

serialize

public static void serialize(NodeState state,
                             OutputStream stream)
                      throws Exception
Serializes the specified state object to the given stream.

Parameters:
state - state to serialize
stream - the stream where the state should be serialized to
Throws:
Exception - if an error occurs during the serialization
See Also:
deserialize(NodeState, InputStream)

deserialize

public static void deserialize(NodeState state,
                               InputStream stream)
                        throws Exception
Deserializes a state object from the given stream.

Parameters:
state - state to deserialize
stream - the stream where the state should be deserialized from
Throws:
Exception - if an error occurs during the deserialization
See Also:
serialize(NodeState, OutputStream)

serialize

public static void serialize(PropertyState state,
                             OutputStream stream,
                             BLOBStore blobStore)
                      throws Exception
Serializes the specified state object to the given stream.

Parameters:
state - state to serialize
stream - the stream where the state should be serialized to
blobStore - handler for blob data
Throws:
Exception - if an error occurs during the serialization
See Also:
deserialize(PropertyState, InputStream, BLOBStore)

deserialize

public static void deserialize(PropertyState state,
                               InputStream stream,
                               BLOBStore blobStore)
                        throws Exception
Deserializes a state object from the given stream.

Parameters:
state - state to deserialize
stream - the stream where the state should be deserialized from
blobStore - handler for blob data
Throws:
Exception - if an error occurs during the deserialization
See Also:
serialize(PropertyState, OutputStream, BLOBStore)

serialize

public static void serialize(NodeReferences refs,
                             OutputStream stream)
                      throws IOException
Serializes the specified NodeReferences object to the given stream.

Parameters:
refs - object to serialize
stream - the stream where the object should be serialized to
Throws:
IOException - if an error occurs during the serialization
See Also:
deserialize(NodeReferences, InputStream)

deserialize

public static void deserialize(NodeReferences refs,
                               InputStream stream)
                        throws Exception
Deserializes a NodeReferences object from the given stream.

Parameters:
refs - object to deserialize
stream - the stream where the object should be deserialized from
Throws:
Exception - if an error occurs during the deserialization
See Also:
serialize(NodeReferences, OutputStream)

get

public FileSystemResource get(String blobId)
                       throws Exception

Specified by:
get in interface BLOBStore
Parameters:
blobId -
Returns:
Throws:
Exception

put

public String put(PropertyId id,
                  int index,
                  InputStream in,
                  long size)
           throws Exception

Specified by:
put in interface BLOBStore
Parameters:
id - id of the property associated with the blob data
index - subscript of the value holding the blob data
in -
size -
Returns:
a string identifying the blob data
Throws:
Exception

remove

public boolean remove(String blobId)
               throws Exception

Specified by:
remove in interface BLOBStore
Parameters:
blobId -
Returns:
Throws:
Exception

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.

Specified by:
init in interface PersistenceManager
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.

Specified by:
close in interface PersistenceManager
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.

Specified by:
load in interface PersistenceManager
Parameters:
id - node id
Returns:
loaded node state
Throws:
ItemStateException - if another error occurs
NoSuchItemStateException - if the node state does not exist

load

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

Specified by:
load in interface PersistenceManager
Parameters:
id - property id
Returns:
loaded property state
Throws:
ItemStateException - if another error occurs
NoSuchItemStateException - if the property state does not exist

load

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

Specified by:
load in interface PersistenceManager
Parameters:
id - reference target node id
Throws:
NoSuchItemStateException - if the target node 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

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(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

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.

Specified by:
exists in interface PersistenceManager
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.

Specified by:
exists in interface PersistenceManager
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.

Specified by:
exists in interface PersistenceManager
Parameters:
id - target node id
Returns:
true if the references exist, false otherwise
Throws:
ItemStateException - on persistence manager errors


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