Class DatabasePersistenceManager
- java.lang.Object
-
- org.apache.jackrabbit.core.persistence.AbstractPersistenceManager
-
- org.apache.jackrabbit.core.persistence.db.DatabasePersistenceManager
-
- All Implemented Interfaces:
PersistenceManager
- Direct Known Subclasses:
JNDIDatabasePersistenceManager,SimpleDbPersistenceManager
@Deprecated public abstract class DatabasePersistenceManager extends AbstractPersistenceManager
Deprecated.Please migrate to a bundle persistence manager (JCR-2802)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 thegetConnection()method to return the configured database connection.See the
SimpleDbPersistenceManagerfor a detailed description of the available configuration options and database behaviour.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanautoReconnectDeprecated.protected StringblobDeleteSQLDeprecated.protected FileSystemblobFSDeprecated.file system where BLOB data is stored (ifexternalBLOBs==true)protected StringblobInsertSQLDeprecated.protected StringblobSelectExistSQLDeprecated.protected StringblobSelectSQLDeprecated.protected BLOBStoreblobStoreDeprecated.BLOBStore that manages BLOB data in the file system (ifexternalBLOBs==true)protected StringblobUpdateSQLDeprecated.protected ConnectionconDeprecated.protected booleanexternalBLOBsDeprecated.protected static intINITIAL_BUFFER_SIZEDeprecated.protected booleaninitializedDeprecated.protected StringnodeReferenceDeleteSQLDeprecated.protected StringnodeReferenceInsertSQLDeprecated.protected StringnodeReferenceSelectExistSQLDeprecated.protected StringnodeReferenceSelectSQLDeprecated.protected StringnodeReferenceUpdateSQLDeprecated.protected StringnodeStateDeleteSQLDeprecated.protected StringnodeStateInsertSQLDeprecated.protected StringnodeStateSelectExistSQLDeprecated.protected StringnodeStateSelectSQLDeprecated.protected StringnodeStateUpdateSQLDeprecated.protected StringpropertyStateDeleteSQLDeprecated.protected StringpropertyStateInsertSQLDeprecated.protected StringpropertyStateSelectExistSQLDeprecated.protected StringpropertyStateSelectSQLDeprecated.protected StringpropertyStateUpdateSQLDeprecated.protected StringschemaDeprecated.protected static StringSCHEMA_OBJECT_PREFIX_VARIABLEDeprecated.protected StringschemaObjectPrefixDeprecated.protected static intSLEEP_BEFORE_RECONNECTDeprecated.
-
Constructor Summary
Constructors Constructor Description DatabasePersistenceManager()Deprecated.Creates a newDatabasePersistenceManagerinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidbuildSQLStatements()Deprecated.Builds the SQL statementsprotected voidcheckSchema()Deprecated.Checks if the required schema objects exist and creates them if they don't exist yet.voidclose()Deprecated.Closes the persistence manager.protected voidcloseConnection(Connection connection)Deprecated.Closes the given database connection.protected voidcloseResultSet(ResultSet rs)Deprecated.protected voidcloseStatement(Statement stmt)Deprecated.protected StringcreateSchemaSql(String sql)Deprecated.Replace wildcards and return the expanded SQL statement.voiddestroy(NodeReferences refs)Deprecated.Destroy a node references object.voiddestroy(NodeState state)Deprecated.Destroy a node state.voiddestroy(PropertyState state)Deprecated.Destroy a property state.protected StatementexecuteStmt(String sql, Object[] params)Deprecated.Executes the given SQL statement with the specified parameters.booleanexists(NodeId id)Deprecated.Checks whether the identified node exists.booleanexists(PropertyId id)Deprecated.Checks whether the identified property exists.booleanexistsReferencesTo(NodeId targetId)Deprecated.Checks whether references of the identified target node exist.protected ConnectiongetConnection()Deprecated.Abstract factory method for creating a new database connection.StringgetSchema()Deprecated.protected InputStreamgetSchemaDDL()Deprecated.Returns an input stream to the schema DDL resource.StringgetSchemaObjectPrefix()Deprecated.voidinit(PMContext context)Deprecated.Initializes the persistence manager.protected voidinitConnection()Deprecated.Initializes the database connection used by this persistence manager.protected voidinitPreparedStatements()Deprecated.Initializes the map of prepared statements.booleanisExternalBLOBs()Deprecated.booleanisSchemaCheckEnabled()Deprecated.NodeStateload(NodeId id)Deprecated.Load the persistent members of a node state.PropertyStateload(PropertyId id)Deprecated.Load the persistent members of a property state.NodeReferencesloadReferencesTo(NodeId targetId)Deprecated.Load the persisted references to the node with the given identifier.protected voidlogException(String message, SQLException se)Deprecated.protected voidprepareSchemaObjectPrefix()Deprecated.Makes sure thatschemaObjectPrefixdoes only consist of characters that are allowed in names on the target database.protected booleanreestablishConnection()Deprecated.Re-establishes the database connection.protected voidresetStatement(PreparedStatement stmt)Deprecated.Resets the givenPreparedStatementby clearing the parameters and warnings contained.voidsetExternalBLOBs(boolean externalBLOBs)Deprecated.voidsetExternalBLOBs(String externalBLOBs)Deprecated.voidsetSchema(String schema)Deprecated.voidsetSchemaCheckEnabled(boolean enabled)Deprecated.voidsetSchemaObjectPrefix(String schemaObjectPrefix)Deprecated.voidstore(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.voidstore(NodeReferences refs)Deprecated.Store a references object.voidstore(NodeState state)Deprecated.Store a node state.voidstore(PropertyState state)Deprecated.Store a property state.-
Methods inherited from class org.apache.jackrabbit.core.persistence.AbstractPersistenceManager
checkConsistency, createNew, createNew
-
-
-
-
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 (ifexternalBLOBs==true)
-
blobStore
protected BLOBStore blobStore
Deprecated.BLOBStore that manages BLOB data in the file system (ifexternalBLOBs==true)
-
-
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 ExceptionDeprecated.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:
storein interfacePersistenceManager- Overrides:
storein classAbstractPersistenceManager- 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 existItemStateException- 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 existItemStateException- 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 synchronized the shared statements would have to be synchronized.- Specified by:
storein classAbstractPersistenceManager- 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 synchronized the shared statements would have to be synchronized.- Specified by:
storein classAbstractPersistenceManager- 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:
destroyin classAbstractPersistenceManager- 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:
destroyin classAbstractPersistenceManager- 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 existItemStateException- 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 synchronized the shared statements would have to be synchronized.- Specified by:
storein classAbstractPersistenceManager- 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:
destroyin classAbstractPersistenceManager- 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:
trueif the node exists,falseotherwise- 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:
trueif the property exists,falseotherwise- 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:
trueif the references exist,falseotherwise- Throws:
ItemStateException- on persistence manager errors
-
initConnection
protected void initConnection() throws ExceptionDeprecated.Initializes the database connection used by this persistence manager.Subclasses should normally override the
getConnection()method instead of this one. The default implementation callsgetConnection()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 byinit(PMContext)when the persistence manager is started. The returned connection should come with the default JDBC settings, as theinit(PMContext)method will explicitly set theautoCommitand 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 thecloseConnection(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 byclose()to close the connection acquired usinggetConnection()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 bystore(ChangeLog)andexecuteStmt(String, Object[])after aSQLExceptionhad 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 aSQLExceptionis encountered andautoReconnect==trueone attempt is made to re-establish the database connection and re-execute the statement.- Parameters:
sql- statement to executeparams- parameters to set- Returns:
- the
Statementobject that had been executed - Throws:
SQLException- if an error occurs
-
resetStatement
protected void resetStatement(PreparedStatement stmt)
Deprecated.Resets the givenPreparedStatementby clearing the parameters and warnings contained.NOTE: This method MUST be called in a synchronized context as neither this method nor the
PreparedStatementinstance on which it operates are thread safe.- Parameters:
stmt- ThePreparedStatementto reset. Ifnullthis 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 ExceptionDeprecated.Makes sure thatschemaObjectPrefixdoes 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 ExceptionDeprecated.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 SQLExceptionDeprecated.Initializes the map of prepared statements.- Throws:
SQLException- if an error occurs
-
-