|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.jackrabbit.core.journal.AbstractJournal
org.apache.jackrabbit.core.journal.DatabaseJournal
public class DatabaseJournal
Database-based journal implementation. Stores records inside a database table named
JOURNAL
, whereas the table GLOBAL_REVISION
contains the
highest available revision number. These tables are located inside the schema specified
in schemaObjectPrefix
.
revision
: the filename where the parent cluster node's revision
file should be written to; this is a required property with no default valuedriver
: the JDBC driver class name to use; this is a required
property with no default valueurl
: the JDBC connection url; this is a required property with
no default value schema
: the schema to be used; if not specified, this is the
second field inside the JDBC connection url, delimeted by colonsschemaObjectPrefix
: the schema object prefix to be used;
defaults to an empty stringuser
: username to specify when connectingpassword
: password to specify when connectingreconnectDelayMs
: number of milliseconds to wait before
trying to reconnect to the database.
Field Summary | |
---|---|
protected String |
insertRevisionStmtSQL
SQL statement appending a new record. |
protected String |
schemaObjectPrefix
Schema object prefix, bean property. |
protected String |
selectGlobalStmtSQL
SQL statement returning the global revision. |
protected String |
selectRevisionsStmtSQL
SQL statement returning all revisions within a range. |
protected String |
updateGlobalStmtSQL
SQL statement updating the global revision. |
Constructor Summary | |
---|---|
DatabaseJournal()
|
Method Summary | |
---|---|
protected void |
append(AppendRecord record,
InputStream in,
int length)
Append a record backed by a file. We have already saved away the revision for this record. |
protected void |
appending(AppendRecord record)
Notification method called by an appended record at creation time. Save away the locked revision inside the newly appended record. |
protected void |
buildSQLStatements()
Builds the SQL statements. |
void |
close()
Close this journal. |
protected String |
createSchemaSQL(String sql)
Creates an SQL statement for schema creation by variable substitution. |
protected void |
doLock()
Lock the journal revision. This journal is locked by incrementing the current value in the table named GLOBAL_REVISION , which effectively write-locks this
table. |
protected void |
doUnlock(boolean successful)
Unlock the journal revision. |
protected Connection |
getConnection()
Creates a new database connection. |
String |
getDriver()
Bean getters |
String |
getPassword()
|
long |
getReconnectDelayMs()
|
protected RecordIterator |
getRecords(long startRevision)
Return an iterator over all records after the specified revision. |
String |
getSchema()
|
String |
getSchemaObjectPrefix()
|
String |
getUrl()
|
String |
getUser()
|
protected void |
init()
Completes initialization of this database journal. |
void |
init(String id,
NamespaceResolver resolver)
Initialize journal. |
protected boolean |
schemaExists(DatabaseMetaData metaData)
Checks whether the required table(s) exist in the schema. |
void |
setDriver(String driver)
Bean setters |
void |
setPassword(String password)
|
void |
setReconnectDelayMs(long reconnectDelayMs)
|
void |
setSchema(String schema)
|
void |
setSchemaObjectPrefix(String schemaObjectPrefix)
|
void |
setUrl(String url)
|
void |
setUser(String user)
|
Methods inherited from class org.apache.jackrabbit.core.journal.AbstractJournal |
---|
createProducer, doSync, getConsumer, getId, getNamePathResolver, getProducer, getResolver, lockAndSync, register, sync, unlock, unregister |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected String selectRevisionsStmtSQL
protected String updateGlobalStmtSQL
protected String selectGlobalStmtSQL
protected String insertRevisionStmtSQL
protected String schemaObjectPrefix
Constructor Detail |
---|
public DatabaseJournal()
Method Detail |
---|
public void init(String id, NamespaceResolver resolver) throws JournalException
init
in interface Journal
init
in class AbstractJournal
id
- id this journal should use to write its own recordsresolver
- resolver used when reading/writing records
JournalException
- if an error occursprotected void init() throws JournalException
driver
and
url
have been specified and optionally deduces a valid
schema. Should be overridden by subclasses that use a different way to
create a connection and therefore require other arguments.
JournalException
- if initialization failsgetConnection()
protected Connection getConnection() throws SQLException
#init(String, org.apache.jackrabbit.name.NamespaceResolver)
or
when a connection has been dropped and must be reacquired. Base
implementation uses java.sql.DriverManager
to get the
connection. May be overridden by subclasses.
SQLException
- if an error occursinit()
protected RecordIterator getRecords(long startRevision) throws JournalException
getRecords
in class AbstractJournal
startRevision
- start point (exlusive)
JournalException
- if an error occursprotected void doLock() throws JournalException
GLOBAL_REVISION
, which effectively write-locks this
table. The updated value is then saved away and remembered in the
appended record, because a save may entail multiple appends (JCR-884).
doLock
in class AbstractJournal
JournalException
- if an error occursprotected void doUnlock(boolean successful)
doUnlock
in class AbstractJournal
successful
- flag indicating whether the update process was
successfulprotected void appending(AppendRecord record)
appending
in class AbstractJournal
record
- record that was appendedprotected void append(AppendRecord record, InputStream in, int length) throws JournalException
append
in class AbstractJournal
record
- record to appendin
- input streamlength
- number of bytes in input stream
JournalException
- if an error occurspublic void close()
protected boolean schemaExists(DatabaseMetaData metaData) throws SQLException
metaData
- database meta data
true
if the schema exists
SQLException
- if an SQL error occursprotected String createSchemaSQL(String sql)
sql
- a SQL string which may contain variables to substitute
protected void buildSQLStatements()
public String getDriver()
public String getUrl()
public String getSchema()
public String getSchemaObjectPrefix()
public String getUser()
public String getPassword()
public long getReconnectDelayMs()
public void setDriver(String driver)
public void setUrl(String url)
public void setSchema(String schema)
public void setSchemaObjectPrefix(String schemaObjectPrefix)
public void setUser(String user)
public void setPassword(String password)
public void setReconnectDelayMs(long reconnectDelayMs)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |