org.apache.jackrabbit.core.state
Interface PersistenceManager

All Known Implementing Classes:
AbstractPersistenceManager

public interface PersistenceManager

Persistence manager interface. Persistence managers are internal Jackrabbit components that handle the persistent storage of content nodes and properties. A persistence manager knows how to retrieve the persistent states of content items and how to atomically save a set of changes to the persistent state.

Each workspace of a Jackrabbit content repository uses separate persistence manager to store the content in that workspace. Also the Jackrabbit version handler uses a separate persistence manager. The persistence managers in use are configured in the Jackrabbit XML configuration files. The configured persistence managers are instantiated and initialized using the JavaBeans conventions.

Persistence manager life cycle

The life cycle of a persistence manager instance contains four phases:

  1. Instantiation, where the instance is created and possible configuration properties are set using the JavaBean conventions. During this phase the persistence manager should not attempt to reference any external resources.
  2. Initialization, where the init method is invoked to bind the persistence manager with a given context.
  3. Normal usage, where the various create, load, exists, and store methods of the persistence manager are used to manage the persistent content items.
  4. Closing, where the close method is invoked to close the persistence manager and release all acquired resources.


Method Summary
 void close()
          Closes the persistence manager.
 NodeState createNew(NodeId id)
          Creates a new node state instance with the given id.
 PropertyState createNew(PropertyId id)
          Creates a new property state instance with the given id.
 boolean exists(NodeId id)
          Checks whether the identified node exists.
 boolean exists(NodeReferencesId targetId)
          Checks whether references of the identified target node exist.
 boolean exists(PropertyId id)
          Checks whether the identified property exists.
 void init(PMContext context)
          Initializes the persistence manager.
 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 store(ChangeLog changeLog)
          Atomically saves the given set of changes.
 

Method Detail

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

createNew

public NodeState createNew(NodeId id)
Creates a new node state instance with the given id.

Parameters:
id - node id
Returns:
node state instance

createNew

public PropertyState createNew(PropertyId id)
Creates a new property state instance with the given id.

Parameters:
id - property id
Returns:
property state instance

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

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:
NoSuchItemStateException - if the target node does not exist
ItemStateException - if another error occurs

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(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(NodeReferencesId targetId)
               throws ItemStateException
Checks whether references of the identified target node exist.

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

store

public void store(ChangeLog changeLog)
           throws ItemStateException
Atomically saves the given set of changes.

Parameters:
changeLog - change log containing states that were changed
Throws:
ItemStateException - if the changes could not be saved


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