|
||||||||||
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 String |
cleanRevisionStmtSQL
SQL statement removing a set of revisions with from the journal table. |
protected String |
getLocalRevisionStmtSQL
SQL statement returning the local revision of this cluster node. |
protected String |
insertLocalRevisionStmtSQL
SQL statement for inserting the local revision of this cluster node. |
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 |
selectMinLocalRevisionStmtSQL
SQL statement returning the minimum of the local revisions. |
protected String |
selectRevisionsStmtSQL
SQL statement returning all revisions within a range. |
protected String |
updateGlobalStmtSQL
SQL statement updating the global revision. |
protected String |
updateLocalRevisionStmtSQL
SQL statement for updating the local revision of this cluster node. |
Constructor Summary | |
---|---|
DatabaseJournal()
|
Method Summary | |
---|---|
protected void |
append(AppendRecord record,
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 String |
createSchemaSQL(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 Connection |
getConnection()
Creates a new database connection. |
String |
getDriver()
Bean getters |
InstanceRevision |
getInstanceRevision()
Gets the instance that manages the cluster node's local revision. |
boolean |
getJanitorEnabled()
|
int |
getJanitorFirstRunHourOfDay()
|
int |
getJanitorSleep()
|
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 void |
initInstanceRevisionAndJanitor()
Initialize the instance revision manager and the janitor thread. |
void |
setDriver(String driver)
Bean setters |
void |
setJanitorEnabled(boolean enabled)
|
void |
setJanitorFirstRunHourOfDay(int hourOfDay)
|
void |
setJanitorSleep(int sleep)
|
void |
setPassword(String password)
|
void |
setReconnectDelayMs(long reconnectDelayMs)
|
void |
setSchema(String schema)
|
void |
setSchemaObjectPrefix(String schemaObjectPrefix)
|
void |
setUrl(String url)
|
void |
setUser(String user)
|
protected boolean |
tableExists(DatabaseMetaData metaData,
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 String selectRevisionsStmtSQL
protected String updateGlobalStmtSQL
protected String selectGlobalStmtSQL
protected String insertRevisionStmtSQL
protected String selectMinLocalRevisionStmtSQL
protected String cleanRevisionStmtSQL
protected String getLocalRevisionStmtSQL
protected String insertLocalRevisionStmtSQL
protected String updateLocalRevisionStmtSQL
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 void initInstanceRevisionAndJanitor() throws Exception
JournalException
- on error
Exception
public InstanceRevision getInstanceRevision() throws JournalException
Journal
JournalException
- on errorprotected Connection getConnection() throws 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
SQLException
- if the connection could not be establishedinit()
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 tableExists(DatabaseMetaData metaData, String tableName) 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 boolean getJanitorEnabled()
public int getJanitorSleep()
public int getJanitorFirstRunHourOfDay()
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)
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 |