|
||||||||||
| 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.
driver: 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.janitorEnabled: specifies whether the clean-up thread for the
journal table is enabled (default = false)janitorSleep: specifies the sleep time of the clean-up thread
in seconds (only useful when the clean-up thread is enabled, default = 24 * 60 * 60,
which equals 24 hours)janitorFirstRunHourOfDay: specifies the hour at which the clean-up
thread initiates its first run (default = 3 which means 3:00 at night)JNDI can be used to get the connection. In this case, use the javax.naming.InitialContext as the driver, and the JNDI name as the URL. If the user and password are configured in the JNDI resource, they should not be configured here. Example JNDI settings:
<param name="driver" value="javax.naming.InitialContext" /> <param name="url" value="java:comp/env/jdbc/Test" />*
| Nested Class Summary | |
|---|---|
class |
DatabaseJournal.DatabaseRevision
This class manages the local revision of the cluster node. |
class |
DatabaseJournal.RevisionTableJanitor
Class for maintaining the revision table. |
| Field Summary | |
|---|---|
protected java.lang.String |
cleanRevisionStmtSQL
SQL statement removing a set of revisions with from the journal table. |
protected java.lang.String |
getLocalRevisionStmtSQL
SQL statement returning the local revision of this cluster node. |
protected java.lang.String |
insertLocalRevisionStmtSQL
SQL statement for inserting the local revision of this cluster node. |
protected java.lang.String |
insertRevisionStmtSQL
SQL statement appending a new record. |
protected java.lang.String |
schemaObjectPrefix
Schema object prefix, bean property. |
protected java.lang.String |
selectGlobalStmtSQL
SQL statement returning the global revision. |
protected java.lang.String |
selectMinLocalRevisionStmtSQL
SQL statement returning the minimum of the local revisions. |
protected java.lang.String |
selectRevisionsStmtSQL
SQL statement returning all revisions within a range. |
protected java.lang.String |
updateGlobalStmtSQL
SQL statement updating the global revision. |
protected java.lang.String |
updateLocalRevisionStmtSQL
SQL statement for updating the local revision of this cluster node. |
| Constructor Summary | |
|---|---|
DatabaseJournal()
|
|
| Method Summary | |
|---|---|
protected void |
append(AppendRecord record,
java.io.InputStream in,
int length)
Append a record backed by a file. |
protected void |
appending(AppendRecord record)
Notification method called by an appended record at creation time. |
protected void |
buildSQLStatements()
Builds the SQL statements. |
void |
close()
Close this journal. |
protected java.lang.String |
createSchemaSQL(java.lang.String sql)
Creates an SQL statement for schema creation by variable substitution. |
protected void |
doLock()
Lock the journal revision. |
protected void |
doUnlock(boolean successful)
Unlock the journal revision. |
protected java.sql.Connection |
getConnection()
Creates a new database connection. |
java.lang.String |
getDriver()
Bean getters |
InstanceRevision |
getInstanceRevision()
Gets the instance that manages the cluster node's local revision. |
boolean |
getJanitorEnabled()
|
int |
getJanitorFirstRunHourOfDay()
|
int |
getJanitorSleep()
|
java.lang.String |
getPassword()
|
long |
getReconnectDelayMs()
|
protected RecordIterator |
getRecords(long startRevision)
Return an iterator over all records after the specified revision. |
java.lang.String |
getSchema()
|
java.lang.String |
getSchemaObjectPrefix()
|
java.lang.String |
getUrl()
|
java.lang.String |
getUser()
|
protected void |
init()
Completes initialization of this database journal. |
void |
init(java.lang.String id,
NamespaceResolver resolver)
Initialize journal. |
protected void |
initInstanceRevisionAndJanitor()
Initialize the instance revision manager and the janitor thread. |
void |
setDriver(java.lang.String driver)
Bean setters |
void |
setJanitorEnabled(boolean enabled)
|
void |
setJanitorFirstRunHourOfDay(int hourOfDay)
|
void |
setJanitorSleep(int sleep)
|
void |
setPassword(java.lang.String password)
|
void |
setReconnectDelayMs(long reconnectDelayMs)
|
void |
setSchema(java.lang.String schema)
|
void |
setSchemaObjectPrefix(java.lang.String schemaObjectPrefix)
|
void |
setUrl(java.lang.String url)
|
void |
setUser(java.lang.String user)
|
protected boolean |
tableExists(java.sql.DatabaseMetaData metaData,
java.lang.String tableName)
Checks whether the required table(s) exist in the schema. |
| Methods inherited from class org.apache.jackrabbit.core.journal.AbstractJournal |
|---|
createProducer, doSync, getConsumer, getId, getNamePathResolver, getProducer, getRepositoryHome, getResolver, getRevision, lockAndSync, register, setRepositoryHome, setRevision, sync, unlock, unregister |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String selectRevisionsStmtSQL
protected java.lang.String updateGlobalStmtSQL
protected java.lang.String selectGlobalStmtSQL
protected java.lang.String insertRevisionStmtSQL
protected java.lang.String selectMinLocalRevisionStmtSQL
protected java.lang.String cleanRevisionStmtSQL
protected java.lang.String getLocalRevisionStmtSQL
protected java.lang.String insertLocalRevisionStmtSQL
protected java.lang.String updateLocalRevisionStmtSQL
protected java.lang.String schemaObjectPrefix
| Constructor Detail |
|---|
public DatabaseJournal()
| Method Detail |
|---|
public void init(java.lang.String id,
NamespaceResolver resolver)
throws JournalException
init in interface Journalinit in class AbstractJournalid - id this journal should use to write its own recordsresolver - resolver used when reading/writing records
JournalException - if an error occurs
protected 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 void initInstanceRevisionAndJanitor()
throws java.lang.Exception
JournalException - on error
java.lang.Exception
public InstanceRevision getInstanceRevision()
throws JournalException
Journal
JournalException - on error
protected java.sql.Connection getConnection()
throws java.sql.SQLException,
JournalException
#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.
JournalException - if the driver could not be loaded
java.sql.SQLException - if the connection could not be establishedinit()
protected RecordIterator getRecords(long startRevision)
throws JournalException
getRecords in class AbstractJournalstartRevision - start point (exlusive)
JournalException - if an error occurs
protected 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 AbstractJournalJournalException - if an error occursprotected void doUnlock(boolean successful)
doUnlock in class AbstractJournalsuccessful - flag indicating whether the update process was
successfulprotected void appending(AppendRecord record)
appending in class AbstractJournalrecord - record that was appended
protected void append(AppendRecord record,
java.io.InputStream in,
int length)
throws JournalException
append in class AbstractJournalrecord - record to appendin - input streamlength - number of bytes in input stream
JournalException - if an error occurspublic void close()
protected boolean tableExists(java.sql.DatabaseMetaData metaData,
java.lang.String tableName)
throws java.sql.SQLException
metaData - database meta data
true if the schema exists
java.sql.SQLException - if an SQL error occursprotected java.lang.String createSchemaSQL(java.lang.String sql)
sql - a SQL string which may contain variables to substitute
protected void buildSQLStatements()
public java.lang.String getDriver()
public java.lang.String getUrl()
public java.lang.String getSchema()
public java.lang.String getSchemaObjectPrefix()
public java.lang.String getUser()
public java.lang.String getPassword()
public long getReconnectDelayMs()
public boolean getJanitorEnabled()
public int getJanitorSleep()
public int getJanitorFirstRunHourOfDay()
public void setDriver(java.lang.String driver)
public void setUrl(java.lang.String url)
public void setSchema(java.lang.String schema)
public void setSchemaObjectPrefix(java.lang.String schemaObjectPrefix)
public void setUser(java.lang.String user)
public void setPassword(java.lang.String password)
public void setReconnectDelayMs(long reconnectDelayMs)
public void setJanitorEnabled(boolean enabled)
public void setJanitorSleep(int sleep)
public void setJanitorFirstRunHourOfDay(int hourOfDay)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||