|
||||||||||
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 NodePropBundle
s
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 String |
bundleDeleteSQL
|
protected String |
bundleInsertSQL
|
protected String |
bundleSelectAllIdsFromSQL
|
protected String |
bundleSelectAllIdsSQL
|
protected String |
bundleSelectSQL
|
protected 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 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 String |
nodeReferenceDeleteSQL
|
protected String |
nodeReferenceInsertSQL
|
protected String |
nodeReferenceSelectSQL
|
protected String |
nodeReferenceUpdateSQL
|
protected String |
password
the jdbc password |
protected String |
schema
the schema identifier |
static String |
SCHEMA_OBJECT_PREFIX_VARIABLE
the variable for the schema prefix |
protected 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 String |
url
the jdbc url string |
protected 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 |
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 username should be included when retrieving the tables during checkTablesExist() . |
void |
close()
Closes the persistence manager. |
protected void |
closeResultSet(ResultSet rs)
Closes the result set |
protected void |
closeStatement(PreparedStatement stmt)
closes the statement |
protected void |
closeStream(InputStream ins)
closes the input stream |
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 Object[] |
createParams(UUID uuid,
Object p,
boolean before)
Creates a parameter array for an SQL statement that needs (i) a UUID, and (2) another parameter. |
protected String |
createSchemaSQL(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. |
String |
getBlockOnConnectionLoss()
|
String |
getConsistencyCheck()
Checks if consistency check is enabled. |
String |
getConsistencyFix()
Checks if consistency fix is enabled. |
String |
getDriver()
Returns the class name of the JDBC driver. |
String |
getErrorHandling()
Returns the error handling configuration of this manager |
protected Object[] |
getKey(UUID uuid)
Constructs a parameter list for a PreparedStatement for the given UUID. |
String |
getMinBlobSize()
Returns the minimum blob size in bytes. |
StringIndex |
getNameIndex()
Returns the local name index |
String |
getPassword()
Returns the configured password that is used to establish JDBC connections. |
String |
getSchema()
Returns the configured schema identifier. |
String |
getSchemaObjectPrefix()
Returns the configured schema object prefix. |
int |
getStorageModel()
returns the storage model |
String |
getUrl()
Returns the configured JDBC connection url. |
String |
getUser()
Returns the configured user that is used to establish JDBC connections. |
void |
init(PMContext context)
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. Initializes the internal structures of this abstract 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 void |
logException(String message,
SQLException se)
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(PreparedStatement stmt)
Resets the given PreparedStatement by clearing the
parameters and warnings contained. |
void |
setBlockOnConnectionLoss(String block)
|
void |
setConsistencyCheck(String consistencyCheck)
Defines if a consistency check is to be performed on initialization. |
void |
setConsistencyFix(String consistencyFix)
Defines if the consistency check should attempt to fix issues that it finds. |
void |
setDriver(String driver)
Sets the class name of the JDBC driver. |
void |
setErrorHandling(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(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(String minBlobSize)
Sets the minimum blob size. |
void |
setPassword(String password)
Sets the password that will be used to establish JDBC connections. |
void |
setSchema(String schema)
Sets the schema identifier. |
void |
setSchemaObjectPrefix(String schemaObjectPrefix)
Sets the schema object prefix. |
void |
setUrl(String url)
Sets the JDBC connection URL. |
void |
setUser(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. Basically wraps a JDBC transaction around super.store(). |
void |
store(NodeReferences refs)
Stores a node references to the underlying system. This method uses shared PreparedStatements , which must
be used strictly sequentially. |
protected void |
storeBundle(NodePropBundle bundle)
Stores a bundle to the underlying system. |
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, 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 String SCHEMA_OBJECT_PREFIX_VARIABLE
public static final int SM_BINARY_KEYS
public static final int SM_LONGLONG_KEYS
protected boolean initialized
protected String driver
protected String url
protected String user
protected String password
protected String schema
protected 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 String bundleInsertSQL
protected String bundleUpdateSQL
protected String bundleSelectSQL
protected String bundleDeleteSQL
protected String bundleSelectAllIdsFromSQL
protected String bundleSelectAllIdsSQL
protected String nodeReferenceInsertSQL
protected String nodeReferenceUpdateSQL
protected String nodeReferenceSelectSQL
protected String nodeReferenceDeleteSQL
protected BundleDbPersistenceManager.CloseableBLOBStore blobStore
protected ErrorHandling errorHandling
protected BundleBinding binding
Constructor Detail |
---|
public BundleDbPersistenceManager()
Method Detail |
---|
public String getUrl()
public void setUrl(String url)
url
- the url to set.public String getUser()
public void setUser(String user)
user
- the user name.public String getPassword()
public void setPassword(String password)
password
- the password for the connectionpublic String getDriver()
public void setDriver(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 String getSchemaObjectPrefix()
public void setSchemaObjectPrefix(String schemaObjectPrefix)
schemaObjectPrefix
- the prefix for schema objects.public String getSchema()
public void setSchema(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 String getConsistencyCheck()
true
if consistency check is enabled.public void setConsistencyCheck(String consistencyCheck)
consistencyCheck
- the consistency check flag.public String getConsistencyFix()
true
if consistency fix is enabled.public void setConsistencyFix(String consistencyFix)
consistencyFix
- the consistency fix flag.public String getMinBlobSize()
public void setMinBlobSize(String minBlobSize)
minBlobSize
- the minimum blobsize in bytes.public void setErrorHandling(String errorHandling)
ErrorHandling
for details about the flags.
errorHandling
- the error handling flagspublic String getErrorHandling()
public void setBlockOnConnectionLoss(String block)
public 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 SQLException, RepositoryException
SQLException
- if an SQL error occurs.
RepositoryException
- if an error occurs.protected String createSchemaSQL(String sql)
sql
- a SQL string which may contain variables to substitute
protected boolean checkTablesExist() throws SQLException, RepositoryException
true
if the tables exist;
false
otherwise.
SQLException
- if a database error occurs.
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 PersistenceManager
store
in class AbstractBundlePersistenceManager
changeLog
- change log containing states that were changed
ItemStateException
- if the changes could not be savedpublic void init(PMContext context) throws 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 PersistenceManager
init
in class AbstractBundlePersistenceManager
context
- persistence manager context
Exception
- if the persistence manager initialization failedprotected BundleBinding getBinding()
getBinding
in class AbstractBundlePersistenceManager
protected BundleDbPersistenceManager.CloseableBLOBStore createBlobStore() throws Exception
Exception
- if an unspecified error occurspublic StringIndex getNameIndex()
getNameIndex
in class AbstractBundlePersistenceManager
IllegalStateException
- if an error occurs.protected DbNameIndex createDbNameIndex() throws SQLException
SQLException
- if an SQL error occurs.public int getStorageModel()
protected BundleDbPersistenceManager.CloseableBLOBStore createLocalFSBlobStore(PMContext context) throws Exception
useLocalFsBlobStore()
returns true
.
context
- the persistence manager context
Exception
- if an error occurs.protected BundleDbPersistenceManager.CloseableBLOBStore createDBBlobStore(PMContext context) throws Exception
useDbBlobStore()
returns true
.
context
- the persistence manager context
Exception
- if an error occurs.protected void prepareSchemaObjectPrefix() throws Exception
schemaObjectPrefix
does only consist of
characters that are allowed in names on the target database. Illegal
characters will be escaped as necessary.
Exception
- if an error occurspublic void close() throws 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.
Exception
- if the persistence manager failed to close properlyprotected int setKey(PreparedStatement stmt, UUID uuid, int pos) throws 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
SQLException
- if an SQL error occurs.protected Object[] getKey(UUID uuid)
uuid
- the uuid
protected Object[] createParams(UUID uuid, 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, 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.
RepositoryException
- if a repository exception occursprotected NodePropBundle loadBundle(NodeId id) throws ItemStateException
loadBundle
in class AbstractBundlePersistenceManager
id
- the node id of the bundle
null
if the bundle does not
exist.
ItemStateException
- if an error while loading occurs.protected boolean existsBundle(NodeId id) throws ItemStateException
existsBundle
in class AbstractBundlePersistenceManager
id
- 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 AbstractBundlePersistenceManager
bundle
- the bundle to store
ItemStateException
- if an error while storing occurs.protected void destroyBundle(NodePropBundle bundle) throws ItemStateException
destroyBundle
in class AbstractBundlePersistenceManager
bundle
- the bundle to destroy
ItemStateException
- if an error while destroying occurs.public NodeReferences load(NodeReferencesId targetId) throws NoSuchItemStateException, ItemStateException
load
in interface PersistenceManager
load
in class AbstractBundlePersistenceManager
targetId
- reference target node id
NoSuchItemStateException
- if the target node does not exist
ItemStateException
- if another error occurspublic 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 AbstractBundlePersistenceManager
refs
- the node references to store.
ItemStateException
- if an error while storing occurs.public void destroy(NodeReferences refs) throws ItemStateException
destroy
in class AbstractBundlePersistenceManager
refs
- 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(PreparedStatement stmt)
PreparedStatement
by clearing the
parameters and warnings contained.
stmt
- The PreparedStatement
to reset. If
null
this method does nothing.protected void closeResultSet(ResultSet rs)
rs
- the result setprotected void closeStream(InputStream ins)
ins
- the input streamprotected void closeStatement(PreparedStatement stmt)
stmt
- the statementprotected void logException(String message, SQLException se)
message
- the messagese
- the exceptionpublic String toString()
toString
in class Object
protected void buildSQLStatements()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |