|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.jackrabbit.core.persistence.bundle.AbstractBundlePersistenceManager
org.apache.jackrabbit.core.persistence.bundle.BundleDbPersistenceManager
public class BundleDbPersistenceManager
This is a generic persistence manager that stores the NodePropBundles
in a database.
bundleCacheSize" value="8"/>
consistencyCheck" value="false"/>
consistencyFix" value="false"/>
minBlobSize" value="4096"/>
driver" value=""/>
url" value=""/>
user" value=""/>
password" value=""/>
schema" value=""/>
schemaObjectPrefix" value=""/>
errorHandling" value=""/>
blockOnConnectionLoss" value="false"/>
| Nested Class Summary | |
|---|---|
protected static interface |
BundleDbPersistenceManager.CloseableBLOBStore
Helper interface for closeable stores |
protected class |
BundleDbPersistenceManager.DbBlobStore
Implementation of a blob store that stores the data inside the database |
protected class |
BundleDbPersistenceManager.FSBlobStore
own implementation of the filesystem blob store that uses a different blob-id scheme. |
| Field Summary | |
|---|---|
protected BundleBinding |
binding
the bundle binding |
protected BundleDbPersistenceManager.CloseableBLOBStore |
blobStore
file system where BLOB data is stored |
protected boolean |
blockOnConnectionLoss
indicates whether to block if the database connection is lost |
protected java.lang.String |
bundleDeleteSQL
|
protected java.lang.String |
bundleInsertSQL
|
protected java.lang.String |
bundleSelectAllIdsFromSQL
|
protected java.lang.String |
bundleSelectAllIdsSQL
|
protected java.lang.String |
bundleSelectSQL
|
protected java.lang.String |
bundleUpdateSQL
|
protected ConnectionRecoveryManager |
connectionManager
The class that manages statement execution and recovery from connection loss. |
protected boolean |
consistencyCheck
flag indicating if a consistency check should be issued during startup |
protected boolean |
consistencyFix
flag indicating if the consistency check should attempt to fix issues |
protected java.lang.String |
driver
the jdbc driver name |
protected ErrorHandling |
errorHandling
flag for error handling |
protected boolean |
externalBLOBs
indicates if uses (filesystem) blob store |
protected static int |
INITIAL_BUFFER_SIZE
initial size of buffer used to serialize objects |
protected boolean |
initialized
flag indicating if this manager was initialized |
protected java.lang.String |
nodeReferenceDeleteSQL
|
protected java.lang.String |
nodeReferenceInsertSQL
|
protected java.lang.String |
nodeReferenceSelectSQL
|
protected java.lang.String |
nodeReferenceUpdateSQL
|
protected java.lang.String |
password
the jdbc password |
protected java.lang.String |
schema
the schema identifier |
static java.lang.String |
SCHEMA_OBJECT_PREFIX_VARIABLE
the variable for the schema prefix |
protected java.lang.String |
schemaObjectPrefix
the prefix for the database objects |
static int |
SM_BINARY_KEYS
storage model modifier: binary keys |
static int |
SM_LONGLONG_KEYS
storage model modifier: longlong keys |
protected java.lang.String |
url
the jdbc url string |
protected java.lang.String |
user
the jdbc user |
| Fields inherited from class org.apache.jackrabbit.core.persistence.bundle.AbstractBundlePersistenceManager |
|---|
context, NODEFILENAME, NODEREFSFILENAME, RES_NAME_INDEX, RES_NS_INDEX |
| Constructor Summary | |
|---|---|
BundleDbPersistenceManager()
|
|
| Method Summary | |
|---|---|
protected void |
buildSQLStatements()
Initializes the SQL strings. |
protected void |
checkBundleConsistency(NodeId id,
NodePropBundle bundle,
boolean fix,
java.util.Collection modifications)
Checks a single bundle for inconsistencies, ie. |
void |
checkConsistency(java.lang.String[] uuids,
boolean recursive,
boolean fix)
This implementation does nothing. |
protected void |
checkSchema()
Checks if the required schema objects exist and creates them if they don't exist yet. |
protected boolean |
checkTablesExist()
Checks if the database table exist. |
protected boolean |
checkTablesWithUser()
Indicates if the user name should be included when retrieving the tables during checkTablesExist(). |
void |
close()
Closes the persistence manager. |
protected void |
closeResultSet(java.sql.ResultSet rs)
Closes the result set |
protected void |
closeStatement(java.sql.PreparedStatement stmt)
closes the statement |
protected BundleDbPersistenceManager.CloseableBLOBStore |
createBlobStore()
Creates a suitable blobstore |
protected BundleDbPersistenceManager.CloseableBLOBStore |
createDBBlobStore(PMContext context)
Creates a blob store that uses the database. |
protected DbNameIndex |
createDbNameIndex()
Returns a new instance of a DbNameIndex. |
protected BundleDbPersistenceManager.CloseableBLOBStore |
createLocalFSBlobStore(PMContext context)
Creates a blob store that is based on a local fs. |
protected java.lang.Object[] |
createParams(UUID uuid,
java.lang.Object p,
boolean before)
Creates a parameter array for an SQL statement that needs (i) a UUID, and (2) another parameter. |
protected java.lang.String |
createSchemaSQL(java.lang.String sql)
Creates an SQL statement for schema creation by variable substitution. |
void |
destroy(NodeReferences refs)
Deletes the node references from the underlying system. |
protected void |
destroyBundle(NodePropBundle bundle)
Deletes the bundle from the underlying system. |
boolean |
exists(NodeReferencesId targetId)
Checks whether references of the identified target node exist. |
protected boolean |
existsBundle(NodeId id)
Checks if a bundle exists in the underlying system. |
NodeIdIterator |
getAllNodeIds(NodeId bigger,
int maxCount)
Get all node ids. |
protected BundleBinding |
getBinding()
Returns the bundle binding that is used for serializing the bundles. |
java.lang.String |
getBlockOnConnectionLoss()
|
java.lang.String |
getConsistencyCheck()
Checks if consistency check is enabled. |
java.lang.String |
getConsistencyFix()
Checks if consistency fix is enabled. |
java.lang.String |
getDriver()
Returns the class name of the JDBC driver. |
java.lang.String |
getErrorHandling()
Returns the error handling configuration of this manager |
protected java.lang.Object[] |
getKey(UUID uuid)
Constructs a parameter list for a PreparedStatement for the given UUID. |
java.lang.String |
getMinBlobSize()
Returns the minimum blob size in bytes. |
StringIndex |
getNameIndex()
Returns the local name index |
java.lang.String |
getPassword()
Returns the configured password that is used to establish JDBC connections. |
java.lang.String |
getSchema()
Returns the configured schema identifier. |
java.lang.String |
getSchemaObjectPrefix()
Returns the configured schema object prefix. |
int |
getStorageModel()
returns the storage model |
java.lang.String |
getUrl()
Returns the configured JDBC connection url. |
java.lang.String |
getUser()
Returns the configured user that is used to establish JDBC connections. |
void |
init(PMContext context)
Initializes the persistence manager. |
boolean |
isExternalBLOBs()
Returns if uses external (filesystem) blob store. |
NodeReferences |
load(NodeReferencesId targetId)
Load the persistent members of a node references object. |
protected NodePropBundle |
loadBundle(NodeId id)
Loads a bundle from the underlying system. |
protected NodePropBundle |
loadBundle(NodeId id,
boolean checkBeforeLoading)
Loads a bundle from the underlying system and optionally performs a check on the bundle first. |
protected void |
logException(java.lang.String message,
java.sql.SQLException e)
logs an sql exception |
protected void |
prepareSchemaObjectPrefix()
Makes sure that schemaObjectPrefix does only consist of
characters that are allowed in names on the target database. |
protected void |
resetStatement(java.sql.PreparedStatement stmt)
Resets the given PreparedStatement by clearing the
parameters and warnings contained. |
void |
setBlockOnConnectionLoss(java.lang.String block)
|
void |
setConsistencyCheck(java.lang.String consistencyCheck)
Defines if a consistency check is to be performed on initialization. |
void |
setConsistencyFix(java.lang.String consistencyFix)
Defines if the consistency check should attempt to fix issues that it finds. |
void |
setDriver(java.lang.String driver)
Sets the class name of the JDBC driver. |
void |
setErrorHandling(java.lang.String errorHandling)
Sets the error handling behaviour of this manager. |
void |
setExternalBLOBs(boolean externalBLOBs)
Sets the flag for external (filesystem) blob store usage. |
protected int |
setKey(java.sql.PreparedStatement stmt,
UUID uuid,
int pos)
Sets the key parameters to the prepared statement, starting at pos and returns the number of key parameters + pos. |
void |
setMinBlobSize(java.lang.String minBlobSize)
Sets the minimum blob size. |
void |
setPassword(java.lang.String password)
Sets the password that will be used to establish JDBC connections. |
void |
setSchema(java.lang.String schema)
Sets the schema identifier. |
void |
setSchemaObjectPrefix(java.lang.String schemaObjectPrefix)
Sets the schema object prefix. |
void |
setUrl(java.lang.String url)
Sets the JDBC connection URL. |
void |
setUser(java.lang.String user)
Sets the user name that will be used to establish JDBC connections. |
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)
Stores a node references to the underlying system. |
protected void |
storeBundle(NodePropBundle bundle)
Stores a bundle to the underlying system. |
java.lang.String |
toString()
|
boolean |
useDbBlobStore()
Returns true if the blobs are stored in the DB. |
boolean |
useLocalFsBlobStore()
Returns true if the blobs are stored in the local fs. |
| Methods inherited from class org.apache.jackrabbit.core.persistence.bundle.AbstractBundlePersistenceManager |
|---|
buildBlobFilePath, buildNodeFilePath, buildNodeFolderPath, buildNodeReferencesFilePath, buildPropFilePath, createNew, createNew, evictBundle, exists, exists, getBundleCacheSize, getNsIndex, load, load, onExternalUpdate, setBundleCacheSize |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String SCHEMA_OBJECT_PREFIX_VARIABLE
public static final int SM_BINARY_KEYS
public static final int SM_LONGLONG_KEYS
protected boolean initialized
protected java.lang.String driver
protected java.lang.String url
protected java.lang.String user
protected java.lang.String password
protected java.lang.String schema
protected java.lang.String schemaObjectPrefix
protected boolean consistencyCheck
protected boolean consistencyFix
protected static final int INITIAL_BUFFER_SIZE
protected boolean externalBLOBs
protected boolean blockOnConnectionLoss
protected ConnectionRecoveryManager connectionManager
protected java.lang.String bundleInsertSQL
protected java.lang.String bundleUpdateSQL
protected java.lang.String bundleSelectSQL
protected java.lang.String bundleDeleteSQL
protected java.lang.String bundleSelectAllIdsFromSQL
protected java.lang.String bundleSelectAllIdsSQL
protected java.lang.String nodeReferenceInsertSQL
protected java.lang.String nodeReferenceUpdateSQL
protected java.lang.String nodeReferenceSelectSQL
protected java.lang.String nodeReferenceDeleteSQL
protected BundleDbPersistenceManager.CloseableBLOBStore blobStore
protected ErrorHandling errorHandling
protected BundleBinding binding
| Constructor Detail |
|---|
public BundleDbPersistenceManager()
| Method Detail |
|---|
public java.lang.String getUrl()
public void setUrl(java.lang.String url)
url - the url to set.public java.lang.String getUser()
public void setUser(java.lang.String user)
user - the user name.public java.lang.String getPassword()
public void setPassword(java.lang.String password)
password - the password for the connectionpublic java.lang.String getDriver()
public void setDriver(java.lang.String driver)
init in order to assure the existence.
If no driver is specified, the default driver for the database is used.
driver - the class name of the driverpublic java.lang.String getSchemaObjectPrefix()
public void setSchemaObjectPrefix(java.lang.String schemaObjectPrefix)
schemaObjectPrefix - the prefix for schema objects.public java.lang.String getSchema()
public void setSchema(java.lang.String schema)
schema - the schema identifier.public boolean isExternalBLOBs()
public void setExternalBLOBs(boolean externalBLOBs)
externalBLOBs - a value of "true" indicates that an external blob
store is to be used.public java.lang.String getConsistencyCheck()
true if consistency check is enabled.public void setConsistencyCheck(java.lang.String consistencyCheck)
consistencyCheck - the consistency check flag.public java.lang.String getConsistencyFix()
true if consistency fix is enabled.public void setConsistencyFix(java.lang.String consistencyFix)
consistencyFix - the consistency fix flag.public java.lang.String getMinBlobSize()
public void setMinBlobSize(java.lang.String minBlobSize)
minBlobSize - the minimum blob size in bytes.public void setErrorHandling(java.lang.String errorHandling)
ErrorHandling
for details about the flags.
errorHandling - the error handling flagspublic java.lang.String getErrorHandling()
public void setBlockOnConnectionLoss(java.lang.String block)
public java.lang.String getBlockOnConnectionLoss()
public boolean useDbBlobStore()
true if the blobs are stored in the DB.
true if the blobs are stored in the DB.public boolean useLocalFsBlobStore()
true if the blobs are stored in the local fs.
true if the blobs are stored in the local fs.
protected void checkSchema()
throws java.sql.SQLException,
javax.jcr.RepositoryException
java.sql.SQLException - if an SQL error occurs.
javax.jcr.RepositoryException - if an error occurs.protected java.lang.String createSchemaSQL(java.lang.String sql)
sql - a SQL string which may contain variables to substitute
protected boolean checkTablesExist()
throws java.sql.SQLException,
javax.jcr.RepositoryException
true if the tables exist;
false otherwise.
java.sql.SQLException - if a database error occurs.
javax.jcr.RepositoryException - if a repository exception occurs.protected boolean checkTablesWithUser()
checkTablesExist().
Please note that this currently only needs to be changed for oracle based
persistence managers.
false
public void store(ChangeLog changeLog)
throws ItemStateException
store in interface PersistenceManagerstore in class AbstractBundlePersistenceManagerchangeLog - change log containing states that were changed
ItemStateException - if the changes could not be saved
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. Initializes the internal structures of this abstract persistence manager.
init in interface PersistenceManagerinit in class AbstractBundlePersistenceManagercontext - persistence manager context
java.lang.Exception - if the persistence manager initialization failedprotected BundleBinding getBinding()
getBinding in class AbstractBundlePersistenceManager
protected BundleDbPersistenceManager.CloseableBLOBStore createBlobStore()
throws java.lang.Exception
java.lang.Exception - if an unspecified error occurspublic StringIndex getNameIndex()
getNameIndex in class AbstractBundlePersistenceManagerjava.lang.IllegalStateException - if an error occurs.
protected DbNameIndex createDbNameIndex()
throws java.sql.SQLException
java.sql.SQLException - if an SQL error occurs.public int getStorageModel()
protected BundleDbPersistenceManager.CloseableBLOBStore createLocalFSBlobStore(PMContext context)
throws java.lang.Exception
useLocalFsBlobStore() returns true.
context - the persistence manager context
java.lang.Exception - if an error occurs.
protected BundleDbPersistenceManager.CloseableBLOBStore createDBBlobStore(PMContext context)
throws java.lang.Exception
useDbBlobStore() returns true.
context - the persistence manager context
java.lang.Exception - if an error occurs.
protected void checkBundleConsistency(NodeId id,
NodePropBundle bundle,
boolean fix,
java.util.Collection modifications)
id - node id for the bundle to checkbundle - the bundle to checkfix - if true, repair things that can be repairedmodifications - if fix == true, collect the repaired
bundles here
public void checkConsistency(java.lang.String[] uuids,
boolean recursive,
boolean fix)
checkConsistency in interface PersistenceManagercheckConsistency in class AbstractBundlePersistenceManageruuids - list of UUIDs of nodes to be checked. if null, all nodes will
be checkedrecursive - if true, the tree(s) below the given node(s) will be traversed
and checked as wellfix - if true, any problems found that can be repaired will be
repaired. if false, no data will be modified, instead all
inconsistencies will only get logged
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
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. Closes the persistence manager, release acquired resourecs.
close in interface PersistenceManagerclose in class AbstractBundlePersistenceManagerjava.lang.Exception - if the persistence manager failed to close properly
protected int setKey(java.sql.PreparedStatement stmt,
UUID uuid,
int pos)
throws java.sql.SQLException
pos and returns the number of key parameters + pos.
stmt - the statementuuid - the uuid of the keypos - the position of the key parameter
pos
java.sql.SQLException - if an SQL error occurs.protected java.lang.Object[] getKey(UUID uuid)
uuid - the uuid
protected java.lang.Object[] createParams(UUID uuid,
java.lang.Object p,
boolean before)
uuid - the UUIDp - the other parameterbefore - whether the other parameter should be before the uuid parameter
public NodeIdIterator getAllNodeIds(NodeId bigger,
int maxCount)
throws ItemStateException,
javax.jcr.RepositoryException
bigger - the lower limit, or null for no limit.maxCount - the maximum number of node ids to return, or 0 for no limit.
ItemStateException - if an error while loading occurs.
javax.jcr.RepositoryException - if a repository exception occurs
protected NodePropBundle loadBundle(NodeId id)
throws ItemStateException
loadBundle in class AbstractBundlePersistenceManagerid - the node id of the bundle
null if the bundle does not
exist.
ItemStateException - if an error while loading occurs.
protected NodePropBundle loadBundle(NodeId id,
boolean checkBeforeLoading)
throws ItemStateException
id - the node id of the bundlecheckBeforeLoading - check the bundle before loading it and log
detailed information about it (slower)
null if the bundle does not
exist.
ItemStateException - if an error while loading occurs.
protected boolean existsBundle(NodeId id)
throws ItemStateException
existsBundle in class AbstractBundlePersistenceManagerid - the node id of the bundle
true if the bundle exists;
false otherwise.
ItemStateException - if an error while checking occurs.
protected void storeBundle(NodePropBundle bundle)
throws ItemStateException
storeBundle in class AbstractBundlePersistenceManagerbundle - the bundle to store
ItemStateException - if an error while storing occurs.
protected void destroyBundle(NodePropBundle bundle)
throws ItemStateException
destroyBundle in class AbstractBundlePersistenceManagerbundle - the bundle to destroy
ItemStateException - if an error while destroying occurs.
public NodeReferences load(NodeReferencesId targetId)
throws NoSuchItemStateException,
ItemStateException
load in interface PersistenceManagerload in class AbstractBundlePersistenceManagertargetId - 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 used 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
statement must be synchronized.
store in class AbstractBundlePersistenceManagerrefs - the node references to store.
ItemStateException - if an error while storing occurs.
public void destroy(NodeReferences refs)
throws ItemStateException
destroy in class AbstractBundlePersistenceManagerrefs - the node references to destroy.
ItemStateException - if an error while destroying occurs.
public boolean exists(NodeReferencesId targetId)
throws ItemStateException
targetId - target node id
true if the references exist,
false otherwise
ItemStateException - on persistence manager errorsprotected void resetStatement(java.sql.PreparedStatement stmt)
PreparedStatement by clearing the
parameters and warnings contained.
stmt - The PreparedStatement to reset. If
null this method does nothing.protected void closeResultSet(java.sql.ResultSet rs)
rs - the result setprotected void closeStatement(java.sql.PreparedStatement stmt)
stmt - the statement
protected void logException(java.lang.String message,
java.sql.SQLException e)
message - the messagee - the exceptionpublic java.lang.String toString()
toString in class java.lang.Objectprotected void buildSQLStatements()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||