|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.jackrabbit.core.persistence.AbstractPersistenceManager
org.apache.jackrabbit.core.persistence.db.DatabasePersistenceManager
public abstract class DatabasePersistenceManager
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
|
protected java.lang.String |
blobDeleteSQL
|
protected FileSystem |
blobFS
file system where BLOB data is stored (if externalBLOBs==true) |
protected java.lang.String |
blobInsertSQL
|
protected java.lang.String |
blobSelectExistSQL
|
protected java.lang.String |
blobSelectSQL
|
protected BLOBStore |
blobStore
BLOBStore that manages BLOB data in the file system (if externalBLOBs==true) |
protected java.lang.String |
blobUpdateSQL
|
protected java.sql.Connection |
con
|
protected boolean |
externalBLOBs
|
protected static int |
INITIAL_BUFFER_SIZE
|
protected boolean |
initialized
|
protected java.lang.String |
nodeReferenceDeleteSQL
|
protected java.lang.String |
nodeReferenceInsertSQL
|
protected java.lang.String |
nodeReferenceSelectExistSQL
|
protected java.lang.String |
nodeReferenceSelectSQL
|
protected java.lang.String |
nodeReferenceUpdateSQL
|
protected java.lang.String |
nodeStateDeleteSQL
|
protected java.lang.String |
nodeStateInsertSQL
|
protected java.lang.String |
nodeStateSelectExistSQL
|
protected java.lang.String |
nodeStateSelectSQL
|
protected java.lang.String |
nodeStateUpdateSQL
|
protected java.lang.String |
propertyStateDeleteSQL
|
protected java.lang.String |
propertyStateInsertSQL
|
protected java.lang.String |
propertyStateSelectExistSQL
|
protected java.lang.String |
propertyStateSelectSQL
|
protected java.lang.String |
propertyStateUpdateSQL
|
protected java.lang.String |
schema
|
protected static java.lang.String |
SCHEMA_OBJECT_PREFIX_VARIABLE
|
protected java.lang.String |
schemaObjectPrefix
|
protected static int |
SLEEP_BEFORE_RECONNECT
|
| Constructor Summary | |
|---|---|
DatabasePersistenceManager()
Creates a new DatabasePersistenceManager instance. |
|
| Method Summary | |
|---|---|
protected void |
buildSQLStatements()
Builds the SQL statements |
protected void |
checkSchema()
Checks if the required schema objects exist and creates them if they don't exist yet. |
void |
close()
Closes the persistence manager. |
protected void |
closeConnection(java.sql.Connection connection)
Closes the given database connection. |
protected void |
closeResultSet(java.sql.ResultSet rs)
|
protected void |
closeStatement(java.sql.Statement stmt)
|
void |
destroy(NodeReferences refs)
Destroy a node references object. |
void |
destroy(NodeState state)
Destroy a node state. |
void |
destroy(PropertyState state)
Destroy a property state. |
protected java.sql.Statement |
executeStmt(java.lang.String sql,
java.lang.Object[] params)
Executes the given SQL statement with the specified parameters. |
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. |
protected java.sql.Connection |
getConnection()
Abstract factory method for creating a new database connection. |
java.lang.String |
getSchema()
|
protected java.io.InputStream |
getSchemaDDL()
Returns an input stream to the schema DDL resource. |
java.lang.String |
getSchemaObjectPrefix()
|
void |
init(PMContext context)
Initializes the persistence manager. |
protected void |
initConnection()
Initializes the database connection used by this persistence manager. |
protected void |
initPreparedStatements()
Initializes the map of prepared statements. |
boolean |
isExternalBLOBs()
|
NodeState |
load(NodeId id)
Load the persistent members of a node state. |
NodeReferences |
load(NodeReferencesId targetId)
Load the persistent members of a node references object. |
PropertyState |
load(PropertyId id)
Load the persistent members of a property state. |
protected void |
logException(java.lang.String message,
java.sql.SQLException se)
|
protected void |
prepareSchemaObjectPrefix()
Makes sure that schemaObjectPrefix does only consist of
characters that are allowed in names on the target database. |
protected boolean |
reestablishConnection()
Re-establishes the database connection. |
protected void |
resetStatement(java.sql.PreparedStatement stmt)
Resets the given PreparedStatement by clearing the parameters
and warnings contained. |
void |
setExternalBLOBs(boolean externalBLOBs)
|
void |
setExternalBLOBs(java.lang.String externalBLOBs)
|
void |
setSchema(java.lang.String schema)
|
void |
setSchemaObjectPrefix(java.lang.String schemaObjectPrefix)
|
void |
store(ChangeLog changeLog)
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)
Store a references object. |
void |
store(NodeState state)
Store a node state. |
void |
store(PropertyState state)
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 |
|---|
protected static final java.lang.String SCHEMA_OBJECT_PREFIX_VARIABLE
protected boolean initialized
protected java.lang.String schema
protected java.lang.String schemaObjectPrefix
protected boolean externalBLOBs
protected static final int INITIAL_BUFFER_SIZE
protected java.sql.Connection con
protected boolean autoReconnect
protected static final int SLEEP_BEFORE_RECONNECT
protected java.lang.String nodeStateInsertSQL
protected java.lang.String nodeStateUpdateSQL
protected java.lang.String nodeStateSelectSQL
protected java.lang.String nodeStateSelectExistSQL
protected java.lang.String nodeStateDeleteSQL
protected java.lang.String propertyStateInsertSQL
protected java.lang.String propertyStateUpdateSQL
protected java.lang.String propertyStateSelectSQL
protected java.lang.String propertyStateSelectExistSQL
protected java.lang.String propertyStateDeleteSQL
protected java.lang.String nodeReferenceInsertSQL
protected java.lang.String nodeReferenceUpdateSQL
protected java.lang.String nodeReferenceSelectSQL
protected java.lang.String nodeReferenceSelectExistSQL
protected java.lang.String nodeReferenceDeleteSQL
protected java.lang.String blobInsertSQL
protected java.lang.String blobUpdateSQL
protected java.lang.String blobSelectSQL
protected java.lang.String blobSelectExistSQL
protected java.lang.String blobDeleteSQL
protected FileSystem blobFS
externalBLOBs==true)
protected BLOBStore blobStore
externalBLOBs==true)
| Constructor Detail |
|---|
public DatabasePersistenceManager()
DatabasePersistenceManager instance.
| Method Detail |
|---|
public java.lang.String getSchemaObjectPrefix()
public void setSchemaObjectPrefix(java.lang.String schemaObjectPrefix)
public java.lang.String getSchema()
public void setSchema(java.lang.String schema)
public boolean isExternalBLOBs()
public void setExternalBLOBs(boolean externalBLOBs)
public void setExternalBLOBs(java.lang.String externalBLOBs)
public void init(PMContext context)
throws java.lang.Exception
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.
context - persistence manager context
java.lang.Exception - if the persistence manager initialization failed
public void close()
throws java.lang.Exception
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.
java.lang.Exception - if the persistence manager failed to close properly
public void store(ChangeLog changeLog)
throws ItemStateException
store in interface PersistenceManagerstore in class AbstractPersistenceManagerchangeLog - change log containing states that were changed
ItemStateException - if the changes could not be saved
public NodeState load(NodeId id)
throws NoSuchItemStateException,
ItemStateException
id - node id
NoSuchItemStateException - if the node state does not exist
ItemStateException - if another error occurs
public PropertyState load(PropertyId id)
throws NoSuchItemStateException,
ItemStateException
id - property id
NoSuchItemStateException - if the property state does not exist
ItemStateException - if another error occurs
public void store(NodeState state)
throws ItemStateException
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.
store in class AbstractPersistenceManagerstate - node state to store
ItemStateException - if an error occurs
public void store(PropertyState state)
throws ItemStateException
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.
store in class AbstractPersistenceManagerstate - property state to store
ItemStateException - if an error occurs
public void destroy(NodeState state)
throws ItemStateException
destroy in class AbstractPersistenceManagerstate - node state to destroy
ItemStateException - if an error occurs
public void destroy(PropertyState state)
throws ItemStateException
destroy in class AbstractPersistenceManagerstate - property state to destroy
ItemStateException - if an error occurs
public NodeReferences load(NodeReferencesId targetId)
throws NoSuchItemStateException,
ItemStateException
targetId - reference target node id
NoSuchItemStateException - if the target node does not exist
ItemStateException - if another error occurs
public void store(NodeReferences refs)
throws ItemStateException
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.
store in class AbstractPersistenceManagerrefs - references object to store
ItemStateException - if an error occurs
public void destroy(NodeReferences refs)
throws ItemStateException
destroy in class AbstractPersistenceManagerrefs - node references object to destroy
ItemStateException - if an error occurs
public boolean exists(NodeId id)
throws ItemStateException
id - node id
true if the node exists,
false otherwise
ItemStateException - on persistence manager errors
public boolean exists(PropertyId id)
throws ItemStateException
id - property id
true if the property exists,
false otherwise
ItemStateException - on persistence manager errors
public boolean exists(NodeReferencesId targetId)
throws ItemStateException
targetId - target node id
true if the references exist,
false otherwise
ItemStateException - on persistence manager errors
protected void initConnection()
throws java.lang.Exception
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.
java.lang.Exception - if an error occurs
protected java.sql.Connection getConnection()
throws java.lang.Exception
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.
java.lang.Exception - if an error occurs
protected void closeConnection(java.sql.Connection connection)
throws java.lang.Exception
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.
connection - database connection
java.lang.Exception - if an error occursprotected boolean reestablishConnection()
store(ChangeLog) and executeStmt(String, Object[])
after a SQLException had been encountered.
protected java.sql.Statement executeStmt(java.lang.String sql,
java.lang.Object[] params)
throws java.sql.SQLException
SQLException is encountered and
autoReconnect==true one attempt is made to re-establish
the database connection and re-execute the statement.
sql - statement to executeparams - parameters to set
Statement object that had been executed
java.sql.SQLException - if an error occursprotected void resetStatement(java.sql.PreparedStatement stmt)
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.
stmt - The PreparedStatement to reset. If
null this method does nothing.protected void closeResultSet(java.sql.ResultSet rs)
protected void closeStatement(java.sql.Statement stmt)
protected void logException(java.lang.String message,
java.sql.SQLException se)
protected void prepareSchemaObjectPrefix()
throws java.lang.Exception
schemaObjectPrefix does only consist of
characters that are allowed in names on the target database. Illegal
characters will be escaped as necessary.
java.lang.Exception - if an error occurs
protected void checkSchema()
throws java.lang.Exception
java.lang.Exception - if an error occursprotected java.io.InputStream getSchemaDDL()
protected void buildSQLStatements()
protected void initPreparedStatements()
throws java.sql.SQLException
java.sql.SQLException - if an error occurs
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||