public abstract class Transport extends Object
Transport.java
The abstract superclass of Journal Transport objects. It enforces the constructors of subclasses, by requiring parent, server, etc.
Sub-classes must implement the four life-cycle methods:
openFile,
getWriter, closeFile, and
shutdown. Each of these should call
testStateChange before operating, in case the
Transport is in an invalid state for that operation. The exception is
getWriter, which does not change the Transport state,
and should call testWriterState instead.
| Modifier and Type | Class and Description |
|---|---|
static class |
Transport.State
The states of in the life-cycle of a Transport.
|
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
crucial
If this transport throws an Exception, is it a crucial problem?
|
protected Map<String,String> |
parameters
The parameters that were passed to this Transport for its use.
|
protected TransportParent |
parent
The parent can format a file header or footer.
|
| Constructor and Description |
|---|
Transport(Map<String,String> parameters,
boolean crucial,
TransportParent parent) |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
closeFile()
Subclasses should implement this to close a logical journal file.
|
Transport.State |
getState() |
abstract XMLEventWriter |
getWriter()
Subclasses should implement this to provite an
XMLEventWriter for
the JournalWriter to write to. |
boolean |
isCrucial() |
abstract void |
openFile(String repositoryHash,
String filename,
Date currentDate)
Subclasses should implement this to create a new logical journal file.
|
void |
setState(Transport.State newState)
Subclasses should call this to change the current state, after the
operation has been performed.
|
abstract void |
shutdown()
Subclasses should implement this to close any resources associated with
the Transport (unless it is already shut down).
|
void |
testStateChange(Transport.State desiredState)
Subclasses should call this before attempting an operation that will
change the current state, so if the change is not permitted, it will not
be performed.
|
protected void |
testWriterState()
Subclasses should call this before executing a
getWriter request. |
protected final Map<String,String> parameters
protected final boolean crucial
protected final TransportParent parent
public Transport(Map<String,String> parameters, boolean crucial, TransportParent parent) throws JournalException
JournalExceptionpublic boolean isCrucial()
public void testStateChange(Transport.State desiredState) throws JournalException
Subclasses should call this before attempting an operation that will change the current state, so if the change is not permitted, it will not be performed.
Note that a redundant call to Shutdown is not considered an error.
JournalExceptionprotected void testWriterState()
throws JournalException
getWriter request. This insures that the Transport
is in the proper state.JournalExceptionpublic void setState(Transport.State newState) throws JournalException
JournalExceptionpublic Transport.State getState()
public abstract void openFile(String repositoryHash, String filename, Date currentDate) throws JournalException
testStateChange before performing
the operation, and call
TransportParent.writeDocumentHeader(XMLEventWriter, String, Date)
to do the formatting.JournalExceptionpublic abstract XMLEventWriter getWriter() throws JournalException
XMLEventWriter for
the JournalWriter to write to. Check testWriterState() before
performing the operation.JournalExceptionpublic abstract void closeFile()
throws JournalException
testStateChange before performing the
operation, and call
TransportParent.writeDocumentTrailer(XMLEventWriter) to do the
formatting.JournalExceptionpublic abstract void shutdown()
throws JournalException
testStateChange before performing the
operation.JournalExceptionCopyright © 2013 DuraSpace. All Rights Reserved.