Class AbstractJournal
- java.lang.Object
-
- org.apache.jackrabbit.core.journal.AbstractJournal
-
- All Implemented Interfaces:
Journal
- Direct Known Subclasses:
DatabaseJournal
,FileJournal
,MemoryJournal
public abstract class AbstractJournal extends Object implements Journal
Base journal implementation.
-
-
Constructor Summary
Constructors Constructor Description AbstractJournal()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract 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 RecordProducer
createProducer(String identifier)
Create the record producer for a given identifier.protected abstract void
doLock()
Lock the journal revision.protected void
doSync(long startRevision)
Synchronize contents from journal.protected void
doSync(long startRevision, boolean startup)
protected abstract void
doUnlock(boolean successful)
Unlock the journal revision.RecordConsumer
getConsumer(String identifier)
Return the consumer given its identifier.String
getId()
Return this journal's identifier.NamePathResolver
getNamePathResolver()
Return this journal's NamePathResolver.RecordProducer
getProducer(String identifier)
Return the record producer for a given identifier.File
getRepositoryHome()
Return the repository home.NamespaceResolver
getResolver()
Return this journal's namespace resolver.String
getRevision()
void
init(String id, NamespaceResolver resolver)
Initialize journal.void
lockAndSync()
Lock the journal revision, disallowing changes from other sources untilunlock(boolean)
has been called, and synchronizes to the latest change.void
register(RecordConsumer consumer)
Register a record consumer.void
setInternalVersionManager(InternalVersionManagerImpl internalVersionManager)
Set the version manager.void
setRepositoryHome(File repHome)
Set the repository home.void
setRevision(String revision)
void
sync(boolean startup)
Synchronize contents from journal.protected boolean
syncAgainOnNewRecords()
Return a flag indicating whether synchronization should continue in a loop until no more new records are found.void
unlock(boolean successful)
Unlock the journal revision.boolean
unregister(RecordConsumer consumer)
Unregister a record processor.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.jackrabbit.core.journal.Journal
close, getInstanceRevision, getRecords, getRecords
-
-
-
-
Method Detail
-
init
public void init(String id, NamespaceResolver resolver) throws JournalException
Initialize journal.- Specified by:
init
in interfaceJournal
- Parameters:
id
- id this journal should use to write its own recordsresolver
- resolver used when reading/writing records- Throws:
JournalException
- if an error occurs
-
register
public void register(RecordConsumer consumer) throws JournalException
Register a record consumer.- Specified by:
register
in interfaceJournal
- Parameters:
consumer
- record consumer- Throws:
JournalException
- if an error occurs
-
unregister
public boolean unregister(RecordConsumer consumer)
Unregister a record processor.- Specified by:
unregister
in interfaceJournal
- Parameters:
consumer
- record processor to unregister- Returns:
true
if the consumer was previously registered;false
otherwise
-
getConsumer
public RecordConsumer getConsumer(String identifier)
Return the consumer given its identifier.- Parameters:
identifier
- identifier- Returns:
- consumer associated with identifier;
null
if no consumer is associated with identifier
-
getProducer
public RecordProducer getProducer(String identifier)
Return the record producer for a given identifier.- Specified by:
getProducer
in interfaceJournal
- Parameters:
identifier
- identifier- Returns:
- the record producer for a given identifier.
-
createProducer
protected RecordProducer createProducer(String identifier)
Create the record producer for a given identifier. May be overridden by subclasses.- Parameters:
identifier
- producer identifier
-
sync
public void sync(boolean startup) throws JournalException
Synchronize contents from journal. This will compare the journal's revision with the revisions of all registered consumers and invoke theirRecordConsumer.consume(org.apache.jackrabbit.core.journal.Record)
method when their identifier matches the one found in the records. The startup flag allow for a separate treatment of the initial sync when the cluster nodes starts up. This might be needed for example when there are a lot of old revisions in a database.- Specified by:
sync
in interfaceJournal
- Parameters:
startup
- indicates if the cluster node is syncing on startup or does a normal sync.- Throws:
JournalException
- if an error occurs
-
doSync
protected void doSync(long startRevision, boolean startup) throws JournalException
- Throws:
JournalException
-
doSync
protected void doSync(long startRevision) throws JournalException
Synchronize contents from journal. May be overridden by subclasses.- Parameters:
startRevision
- start point (exclusive)- Throws:
JournalException
- if an error occurs
-
syncAgainOnNewRecords
protected boolean syncAgainOnNewRecords()
Return a flag indicating whether synchronization should continue in a loop until no more new records are found. Subclass overridable.- Returns:
true
if synchronization should continue;false
otherwise
-
lockAndSync
public void lockAndSync() throws JournalException
Lock the journal revision, disallowing changes from other sources untilunlock(boolean)
has been called, and synchronizes to the latest change.- Throws:
JournalException
- if an error occurs
-
unlock
public void unlock(boolean successful)
Unlock the journal revision.- Parameters:
successful
- flag indicating whether the update process was successful
-
doLock
protected abstract void doLock() throws JournalException
Lock the journal revision. Subclass responsibility.- Throws:
JournalException
- if an error occurs
-
appending
protected void appending(AppendRecord record)
Notification method called by an appended record at creation time. May be overridden by subclasses to save some context information inside the appended record.- Parameters:
record
- record that was appended
-
append
protected abstract void append(AppendRecord record, InputStream in, int length) throws JournalException
Append a record backed by a file. On exit, the new revision must have been set inside the appended record. Subclass responsibility.- Parameters:
record
- record to appendin
- input streamlength
- number of bytes in input stream- Throws:
JournalException
- if an error occurs
-
doUnlock
protected abstract void doUnlock(boolean successful)
Unlock the journal revision. Subclass responsibility.- Parameters:
successful
- flag indicating whether the update process was successful
-
getId
public String getId()
Return this journal's identifier.- Returns:
- journal identifier
-
getResolver
public NamespaceResolver getResolver()
Return this journal's namespace resolver.- Returns:
- namespace resolver
-
getNamePathResolver
public NamePathResolver getNamePathResolver()
Return this journal's NamePathResolver.- Returns:
- name and path resolver
-
setRepositoryHome
public void setRepositoryHome(File repHome)
Set the repository home.- Parameters:
repHome
- repository home- Since:
- JR 1.5
-
setInternalVersionManager
public void setInternalVersionManager(InternalVersionManagerImpl internalVersionManager)
Set the version manager.
-
getRepositoryHome
public File getRepositoryHome()
Return the repository home.- Returns:
- the repository home
- Since:
- JR 1.5
-
getRevision
public String getRevision()
- Returns:
- the path of the cluster node's local revision file
-
setRevision
public void setRevision(String revision)
- Parameters:
revision
- the path of the cluster node's local revision file to set
-
-