|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jackrabbit.core.state.AbstractPersistenceManager
org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager
SimpleDbPersistenceManager
is a generic JDBC-based
PersistenceManager
for Jackrabbit that persists
ItemState
and NodeReferences
objects using a
simple custom serialization format and a very basic non-normalized database
schema (in essence tables with one 'key' and one 'data' column).
driver
: the FQN name of the JDBC driver classurl
: the database url of the form jdbc:subprotocol:subname
user
: the database userpassword
: the user's passwordschema
: type of schema to be used
(e.g. mysql
, mssql
, etc.); schemaObjectPrefix
: prefix to be prepended to schema objectsgetClass().getResourceAsStream(schema + ".ddl")
.
Every line in the specified .ddl file is executed separatly by calling
java.sql.Statement.execute(String)
where every occurence of the
the string "${schemaObjectPrefix}"
has been replaced with the
value of the property schemaObjectPrefix
.
The following is a fragment from a sample configuration using MySQL:
<PersistenceManager class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager"> <param name="driver" value="com.mysql.jdbc.Driver"/> <param name="url" value="jdbc:mysql:///test"/> <param name="schema" value="mysql"/> <param name="schemaObjectPrefix" value="${wsp.name}_"/> </PersistenceManager>The following is a fragment from a sample configuration using Daffodil One$DB Embedded:
<PersistenceManager class="org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager"> <param name="driver" value="in.co.daffodil.db.jdbc.DaffodilDBDriver"/> <param name="url" value="jdbc:daffodilDB_embedded:${wsp.name};path=${wsp.home}/../../databases;create=true"/> <param name="user" value="daffodil"/> <param name="password" value="daffodil"/> <param name="schema" value="daffodil"/> <param name="schemaObjectPrefix" value="${wsp.name}_"/> </PersistenceManager>
Field Summary | |
protected FileSystem |
blobFS
file system where BLOB data is stored |
protected Connection |
con
|
protected String |
driver
|
protected static int |
INITIAL_BUFFER_SIZE
|
protected boolean |
initialized
|
protected PreparedStatement |
nodeReferenceDelete
|
protected PreparedStatement |
nodeReferenceInsert
|
protected PreparedStatement |
nodeReferenceSelect
|
protected PreparedStatement |
nodeReferenceUpdate
|
protected PreparedStatement |
nodeStateDelete
|
protected PreparedStatement |
nodeStateInsert
|
protected PreparedStatement |
nodeStateSelect
|
protected PreparedStatement |
nodeStateUpdate
|
protected String |
password
|
protected PreparedStatement |
propertyStateDelete
|
protected PreparedStatement |
propertyStateInsert
|
protected PreparedStatement |
propertyStateSelect
|
protected PreparedStatement |
propertyStateUpdate
|
protected String |
schema
|
protected static String |
SCHEMA_OBJECT_PREFIX_VARIABLE
|
protected String |
schemaObjectPrefix
|
protected String |
url
|
protected String |
user
|
Constructor Summary | |
SimpleDbPersistenceManager()
Creates a new SimpleDbPersistenceManager instance. |
Method Summary | |
protected static String |
buildBlobFilePath(String parentUUID,
QName propName,
int index)
|
protected void |
checkSchema()
Checks if the required schema objects exist and creates them if they don't exist yet. |
void |
close()
|
protected void |
closeResultSet(ResultSet rs)
|
protected void |
closeStatement(Statement stmt)
|
protected void |
closeStream(InputStream in)
|
void |
destroy(NodeReferences refs)
|
void |
destroy(NodeState state)
|
void |
destroy(PropertyState state)
|
boolean |
exists(NodeId id)
|
boolean |
exists(NodeReferencesId targetId)
|
boolean |
exists(PropertyId id)
|
FileSystemResource |
get(String blobId)
|
String |
getDriver()
|
String |
getPassword()
|
String |
getSchema()
|
String |
getSchemaObjectPrefix()
|
String |
getUrl()
|
String |
getUser()
|
void |
init(PMContext context)
|
NodeState |
load(NodeId id)
|
NodeReferences |
load(NodeReferencesId targetId)
|
PropertyState |
load(PropertyId id)
|
protected void |
logException(String message,
SQLException se)
|
String |
put(PropertyId id,
int index,
InputStream in,
long size)
|
boolean |
remove(String blobId)
|
protected void |
resetStatement(PreparedStatement stmt)
Resets the given PreparedStatement by clearing the parameters
and warnings contained. |
void |
setDriver(String driver)
|
void |
setPassword(String password)
|
void |
setSchema(String schema)
|
void |
setSchemaObjectPrefix(String schemaObjectPrefix)
|
void |
setUrl(String url)
|
void |
setUser(String user)
|
void |
store(ChangeLog changeLog)
|
void |
store(NodeReferences refs)
This method uses shared PreparedStatement s which must
be executed strictly sequentially. |
void |
store(NodeState state)
This method uses shared PreparedStatement s which must
be executed strictly sequentially. |
void |
store(PropertyState state)
This method uses shared PreparedStatement s which must
be executed strictly sequentially. |
Methods inherited from class org.apache.jackrabbit.core.state.AbstractPersistenceManager |
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 String SCHEMA_OBJECT_PREFIX_VARIABLE
protected boolean initialized
protected String driver
protected String url
protected String user
protected String password
protected String schema
protected String schemaObjectPrefix
protected static final int INITIAL_BUFFER_SIZE
protected Connection con
protected PreparedStatement nodeStateInsert
protected PreparedStatement nodeStateUpdate
protected PreparedStatement nodeStateSelect
protected PreparedStatement nodeStateDelete
protected PreparedStatement propertyStateInsert
protected PreparedStatement propertyStateUpdate
protected PreparedStatement propertyStateSelect
protected PreparedStatement propertyStateDelete
protected PreparedStatement nodeReferenceInsert
protected PreparedStatement nodeReferenceUpdate
protected PreparedStatement nodeReferenceSelect
protected PreparedStatement nodeReferenceDelete
protected FileSystem blobFS
Constructor Detail |
public SimpleDbPersistenceManager()
SimpleDbPersistenceManager
instance.
Method Detail |
public String getUrl()
public void setUrl(String url)
public String getUser()
public void setUser(String user)
public String getPassword()
public void setPassword(String password)
public String getDriver()
public void setDriver(String driver)
public String getSchemaObjectPrefix()
public void setSchemaObjectPrefix(String schemaObjectPrefix)
public String getSchema()
public void setSchema(String schema)
public FileSystemResource get(String blobId) throws Exception
get
in interface BLOBStore
Exception
public String put(PropertyId id, int index, InputStream in, long size) throws Exception
put
in interface BLOBStore
Exception
public boolean remove(String blobId) throws Exception
remove
in interface BLOBStore
Exception
public void init(PMContext context) throws Exception
init
in interface PersistenceManager
Exception
public void close() throws Exception
close
in interface PersistenceManager
Exception
public void store(ChangeLog changeLog) throws ItemStateException
store
in interface PersistenceManager
ItemStateException
public NodeState load(NodeId id) throws NoSuchItemStateException, ItemStateException
load
in interface PersistenceManager
NoSuchItemStateException
ItemStateException
public PropertyState load(PropertyId id) throws NoSuchItemStateException, ItemStateException
load
in interface PersistenceManager
NoSuchItemStateException
ItemStateException
public void store(NodeState state) throws ItemStateException
PreparedStatement
s 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.
ItemStateException
public void store(PropertyState state) throws ItemStateException
PreparedStatement
s 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.
ItemStateException
public void destroy(NodeState state) throws ItemStateException
ItemStateException
public void destroy(PropertyState state) throws ItemStateException
ItemStateException
public NodeReferences load(NodeReferencesId targetId) throws NoSuchItemStateException, ItemStateException
load
in interface PersistenceManager
NoSuchItemStateException
ItemStateException
public void store(NodeReferences refs) throws ItemStateException
PreparedStatement
s 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.
ItemStateException
public void destroy(NodeReferences refs) throws ItemStateException
ItemStateException
public boolean exists(NodeId id) throws ItemStateException
exists
in interface PersistenceManager
ItemStateException
public boolean exists(PropertyId id) throws ItemStateException
exists
in interface PersistenceManager
ItemStateException
public boolean exists(NodeReferencesId targetId) throws ItemStateException
exists
in interface PersistenceManager
ItemStateException
protected void resetStatement(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(ResultSet rs)
protected void closeStream(InputStream in)
protected void closeStatement(Statement stmt)
protected void logException(String message, SQLException se)
protected static String buildBlobFilePath(String parentUUID, QName propName, int index)
protected void checkSchema() throws Exception
Exception
- if an error occurs
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |