org.apache.jackrabbit.core.persistence.db
Class DatabasePersistenceManager

java.lang.Object
  extended by org.apache.jackrabbit.core.persistence.AbstractPersistenceManager
      extended by org.apache.jackrabbit.core.persistence.db.DatabasePersistenceManager
All Implemented Interfaces:
PersistenceManager
Direct Known Subclasses:
JNDIDatabasePersistenceManager, SimpleDbPersistenceManager

Deprecated. Please migrate to a bundle persistence manager (JCR-2802)

@Deprecated
public abstract class DatabasePersistenceManager
extends AbstractPersistenceManager

Abstract base class for database persistence managers. This class contains common functionality for database persistence manager subclasses that normally differ only in the way the database connection is acquired. Subclasses should override the getConnection() method to return the configured database connection.

See the SimpleDbPersistenceManager for a detailed description of the available configuration options and database behaviour.


Field Summary
protected  boolean autoReconnect
          Deprecated.  
protected  String blobDeleteSQL
          Deprecated.  
protected  FileSystem blobFS
          Deprecated. file system where BLOB data is stored (if externalBLOBs==true)
protected  String blobInsertSQL
          Deprecated.  
protected  String blobSelectExistSQL
          Deprecated.  
protected  String blobSelectSQL
          Deprecated.  
protected  BLOBStore blobStore
          Deprecated. BLOBStore that manages BLOB data in the file system (if externalBLOBs==true)
protected  String blobUpdateSQL
          Deprecated.  
protected  Connection con
          Deprecated.  
protected  boolean externalBLOBs
          Deprecated.  
protected static int INITIAL_BUFFER_SIZE
          Deprecated.  
protected  boolean initialized
          Deprecated.  
protected  String nodeReferenceDeleteSQL
          Deprecated.  
protected  String nodeReferenceInsertSQL
          Deprecated.  
protected  String nodeReferenceSelectExistSQL
          Deprecated.  
protected  String nodeReferenceSelectSQL
          Deprecated.  
protected  String nodeReferenceUpdateSQL
          Deprecated.  
protected  String nodeStateDeleteSQL
          Deprecated.  
protected  String nodeStateInsertSQL
          Deprecated.  
protected  String nodeStateSelectExistSQL
          Deprecated.  
protected  String nodeStateSelectSQL
          Deprecated.  
protected  String nodeStateUpdateSQL
          Deprecated.  
protected  String propertyStateDeleteSQL
          Deprecated.  
protected  String propertyStateInsertSQL
          Deprecated.  
protected  String propertyStateSelectExistSQL
          Deprecated.  
protected  String propertyStateSelectSQL
          Deprecated.  
protected  String propertyStateUpdateSQL
          Deprecated.  
protected  String schema
          Deprecated.  
protected static String SCHEMA_OBJECT_PREFIX_VARIABLE
          Deprecated.  
protected  String schemaObjectPrefix
          Deprecated.  
protected static int SLEEP_BEFORE_RECONNECT
          Deprecated.  
 
Constructor Summary
DatabasePersistenceManager()
          Deprecated. Creates a new DatabasePersistenceManager instance.
 
Method Summary
protected  void buildSQLStatements()
          Deprecated. Builds the SQL statements
protected  void checkSchema()
          Deprecated. Checks if the required schema objects exist and creates them if they don't exist yet.
 void close()
          Deprecated. Closes the persistence manager.
protected  void closeConnection(Connection connection)
          Deprecated. Closes the given database connection.
protected  void closeResultSet(ResultSet rs)
          Deprecated.  
protected  void closeStatement(Statement stmt)
          Deprecated.  
protected  String createSchemaSql(String sql)
          Deprecated. Replace wildcards and return the expanded SQL statement.
 void destroy(NodeReferences refs)
          Deprecated. Destroy a node references object.
 void destroy(NodeState state)
          Deprecated. Destroy a node state.
 void destroy(PropertyState state)
          Deprecated. Destroy a property state.
protected  Statement executeStmt(String sql, Object[] params)
          Deprecated. Executes the given SQL statement with the specified parameters.
 boolean exists(NodeId id)
          Deprecated. Checks whether the identified node exists.
 boolean exists(PropertyId id)
          Deprecated. Checks whether the identified property exists.
 boolean existsReferencesTo(NodeId targetId)
          Deprecated. Checks whether references of the identified target node exist.
protected  Connection getConnection()
          Deprecated. Abstract factory method for creating a new database connection.
 String getSchema()
          Deprecated.  
protected  InputStream getSchemaDDL()
          Deprecated. Returns an input stream to the schema DDL resource.
 String getSchemaObjectPrefix()
          Deprecated.  
 void init(PMContext context)
          Deprecated. Initializes the persistence manager.
protected  void initConnection()
          Deprecated. Initializes the database connection used by this persistence manager.
protected  void initPreparedStatements()
          Deprecated. Initializes the map of prepared statements.
 boolean isExternalBLOBs()
          Deprecated.  
 boolean isSchemaCheckEnabled()
          Deprecated.  
 NodeState load(NodeId id)
          Deprecated. Load the persistent members of a node state.
 PropertyState load(PropertyId id)
          Deprecated. Load the persistent members of a property state.
 NodeReferences loadReferencesTo(NodeId targetId)
          Deprecated. Load the persisted references to the node with the given identifier.
protected  void logException(String message, SQLException se)
          Deprecated.  
protected  void prepareSchemaObjectPrefix()
          Deprecated. Makes sure that schemaObjectPrefix does only consist of characters that are allowed in names on the target database.
protected  boolean reestablishConnection()
          Deprecated. Re-establishes the database connection.
protected  void resetStatement(PreparedStatement stmt)
          Deprecated. Resets the given PreparedStatement by clearing the parameters and warnings contained.
 void setExternalBLOBs(boolean externalBLOBs)
          Deprecated.  
 void setExternalBLOBs(String externalBLOBs)
          Deprecated.  
 void setSchema(String schema)
          Deprecated.  
 void setSchemaCheckEnabled(boolean enabled)
          Deprecated.  
 void setSchemaObjectPrefix(String schemaObjectPrefix)
          Deprecated.  
 void store(ChangeLog changeLog)
          Deprecated. Right now, this iterates over all items in the changelog and calls the individual methods that handle single item states or node references objects.
 void store(NodeReferences refs)
          Deprecated. Store a references object.
 void store(NodeState state)
          Deprecated. Store a node state.
 void store(PropertyState state)
          Deprecated. Store a property state.
 
Methods inherited from class org.apache.jackrabbit.core.persistence.AbstractPersistenceManager
checkConsistency, createNew, createNew
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCHEMA_OBJECT_PREFIX_VARIABLE

protected static final String SCHEMA_OBJECT_PREFIX_VARIABLE
Deprecated. 
See Also:
Constant Field Values

initialized

protected boolean initialized
Deprecated. 

schema

protected String schema
Deprecated. 

schemaObjectPrefix

protected String schemaObjectPrefix
Deprecated. 

externalBLOBs

protected boolean externalBLOBs
Deprecated. 

INITIAL_BUFFER_SIZE

protected static final int INITIAL_BUFFER_SIZE
Deprecated. 
See Also:
Constant Field Values

con

protected Connection con
Deprecated. 

autoReconnect

protected boolean autoReconnect
Deprecated. 

SLEEP_BEFORE_RECONNECT

protected static final int SLEEP_BEFORE_RECONNECT
Deprecated. 
See Also:
Constant Field Values

nodeStateInsertSQL

protected String nodeStateInsertSQL
Deprecated. 

nodeStateUpdateSQL

protected String nodeStateUpdateSQL
Deprecated. 

nodeStateSelectSQL

protected String nodeStateSelectSQL
Deprecated. 

nodeStateSelectExistSQL

protected String nodeStateSelectExistSQL
Deprecated. 

nodeStateDeleteSQL

protected String nodeStateDeleteSQL
Deprecated. 

propertyStateInsertSQL

protected String propertyStateInsertSQL
Deprecated. 

propertyStateUpdateSQL

protected String propertyStateUpdateSQL
Deprecated. 

propertyStateSelectSQL

protected String propertyStateSelectSQL
Deprecated. 

propertyStateSelectExistSQL

protected String propertyStateSelectExistSQL
Deprecated. 

propertyStateDeleteSQL

protected String propertyStateDeleteSQL
Deprecated. 

nodeReferenceInsertSQL

protected String nodeReferenceInsertSQL
Deprecated. 

nodeReferenceUpdateSQL

protected String nodeReferenceUpdateSQL
Deprecated. 

nodeReferenceSelectSQL

protected String nodeReferenceSelectSQL
Deprecated. 

nodeReferenceSelectExistSQL

protected String nodeReferenceSelectExistSQL
Deprecated. 

nodeReferenceDeleteSQL

protected String nodeReferenceDeleteSQL
Deprecated. 

blobInsertSQL

protected String blobInsertSQL
Deprecated. 

blobUpdateSQL

protected String blobUpdateSQL
Deprecated. 

blobSelectSQL

protected String blobSelectSQL
Deprecated. 

blobSelectExistSQL

protected String blobSelectExistSQL
Deprecated. 

blobDeleteSQL

protected String blobDeleteSQL
Deprecated. 

blobFS

protected FileSystem blobFS
Deprecated. 
file system where BLOB data is stored (if externalBLOBs==true)


blobStore

protected BLOBStore blobStore
Deprecated. 
BLOBStore that manages BLOB data in the file system (if externalBLOBs==true)

Constructor Detail

DatabasePersistenceManager

public DatabasePersistenceManager()
Deprecated. 
Creates a new DatabasePersistenceManager instance.

Method Detail

getSchemaObjectPrefix

public String getSchemaObjectPrefix()
Deprecated. 

setSchemaObjectPrefix

public void setSchemaObjectPrefix(String schemaObjectPrefix)
Deprecated. 

getSchema

public String getSchema()
Deprecated. 

setSchema

public void setSchema(String schema)
Deprecated. 

isExternalBLOBs

public boolean isExternalBLOBs()
Deprecated. 

setExternalBLOBs

public void setExternalBLOBs(boolean externalBLOBs)
Deprecated. 

setExternalBLOBs

public void setExternalBLOBs(String externalBLOBs)
Deprecated. 

isSchemaCheckEnabled

public final boolean isSchemaCheckEnabled()
Deprecated. 
Returns:
whether the schema check is enabled

setSchemaCheckEnabled

public final void setSchemaCheckEnabled(boolean enabled)
Deprecated. 
Parameters:
enabled - set whether the schema check is enabled

init

public void init(PMContext context)
          throws Exception
Deprecated. 
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 initialization failed

close

public void close()
           throws Exception
Deprecated. 
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

store

public void store(ChangeLog changeLog)
           throws ItemStateException
Deprecated. 
Right now, this iterates over all items in the changelog and calls the individual methods that handle single item states or node references objects. Properly implemented, this method should ensure that changes are either written completely to the underlying persistence layer, or not at all. Atomically saves the given set of changes.

Specified by:
store in interface PersistenceManager
Overrides:
store in class AbstractPersistenceManager
Parameters:
changeLog - change log containing states that were changed
Throws:
ItemStateException - if the changes could not be saved

load

public NodeState load(NodeId id)
               throws NoSuchItemStateException,
                      ItemStateException
Deprecated. 
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
Deprecated. 
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

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

This method uses shared PreparedStatements which must be executed strictly sequentially. Because this method synchronizes on the persistence manager instance there is no need to synchronize on the shared statement. If the method would not be sychronized the shared statements would have to be synchronized.

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

store

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

This method uses shared PreparedStatements which must be executed strictly sequentially. Because this method synchronizes on the persistence manager instance there is no need to synchronize on the shared statement. If the method would not be sychronized the shared statements would have to be synchronized.

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

destroy

public void destroy(NodeState state)
             throws ItemStateException
Deprecated. 
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

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

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

loadReferencesTo

public NodeReferences loadReferencesTo(NodeId targetId)
                                throws NoSuchItemStateException,
                                       ItemStateException
Deprecated. 
Load the persisted references to the node with the given identifier.

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

store

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

This method uses shared PreparedStatements which must be executed strictly sequentially. Because this method synchronizes on the persistence manager instance there is no need to synchronize on the shared statement. If the method would not be sychronized the shared statements would have to be synchronized.

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

destroy

public void destroy(NodeReferences refs)
             throws ItemStateException
Deprecated. 
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(NodeId id)
               throws ItemStateException
Deprecated. 
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
Deprecated. 
Checks whether the identified property exists.

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

existsReferencesTo

public boolean existsReferencesTo(NodeId targetId)
                           throws ItemStateException
Deprecated. 
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

initConnection

protected void initConnection()
                       throws Exception
Deprecated. 
Initializes the database connection used by this persistence manager.

Subclasses should normally override the getConnection() method instead of this one. The default implementation calls getConnection() to get the database connection and disables the autocommit feature.

Throws:
Exception - if an error occurs

getConnection

protected Connection getConnection()
                            throws Exception
Deprecated. 
Abstract factory method for creating a new database connection. This method is called by init(PMContext) when the persistence manager is started. The returned connection should come with the default JDBC settings, as the init(PMContext) method will explicitly set the autoCommit and other properties as needed.

Note that the returned database connection is kept during the entire lifetime of the persistence manager, after which it is closed by close() using the closeConnection(Connection) method.

Returns:
new connection
Throws:
Exception - if an error occurs

closeConnection

protected void closeConnection(Connection connection)
                        throws Exception
Deprecated. 
Closes the given database connection. This method is called by close() to close the connection acquired using getConnection() when the persistence manager was started.

The default implementation just calls the Connection.close() method of the given connection, but subclasses can override this method to provide more extensive database and connection cleanup.

Parameters:
connection - database connection
Throws:
Exception - if an error occurs

reestablishConnection

protected boolean reestablishConnection()
Deprecated. 
Re-establishes the database connection. This method is called by store(ChangeLog) and executeStmt(String, Object[]) after a SQLException had been encountered.

Returns:
true if the connection could be successfully re-established, false otherwise.

executeStmt

protected Statement executeStmt(String sql,
                                Object[] params)
                         throws SQLException
Deprecated. 
Executes the given SQL statement with the specified parameters. If a SQLException is encountered and autoReconnect==true one attempt is made to re-establish the database connection and re-execute the statement.

Parameters:
sql - statement to execute
params - parameters to set
Returns:
the Statement object that had been executed
Throws:
SQLException - if an error occurs

resetStatement

protected void resetStatement(PreparedStatement stmt)
Deprecated. 
Resets the given PreparedStatement by clearing the parameters and warnings contained.

NOTE: This method MUST be called in a synchronized context as neither this method nor the PreparedStatement instance on which it operates are thread safe.

Parameters:
stmt - The PreparedStatement to reset. If null this method does nothing.

closeResultSet

protected void closeResultSet(ResultSet rs)
Deprecated. 

closeStatement

protected void closeStatement(Statement stmt)
Deprecated. 

logException

protected void logException(String message,
                            SQLException se)
Deprecated. 

prepareSchemaObjectPrefix

protected void prepareSchemaObjectPrefix()
                                  throws Exception
Deprecated. 
Makes sure that schemaObjectPrefix does only consist of characters that are allowed in names on the target database. Illegal characters will be escaped as necessary.

Throws:
Exception - if an error occurs

checkSchema

protected void checkSchema()
                    throws Exception
Deprecated. 
Checks if the required schema objects exist and creates them if they don't exist yet.

Throws:
Exception - if an error occurs

createSchemaSql

protected String createSchemaSql(String sql)
Deprecated. 
Replace wildcards and return the expanded SQL statement.

Parameters:
sql - The SQL with embedded wildcards.
Returns:
The SQL with no wildcards present.

getSchemaDDL

protected InputStream getSchemaDDL()
Deprecated. 
Returns an input stream to the schema DDL resource.

Returns:
an input stream to the schema DDL resource.

buildSQLStatements

protected void buildSQLStatements()
Deprecated. 
Builds the SQL statements


initPreparedStatements

protected void initPreparedStatements()
                               throws SQLException
Deprecated. 
Initializes the map of prepared statements.

Throws:
SQLException - if an error occurs


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