org.fcrepo.server.journal.readerwriter.multicast
Class Transport

java.lang.Object
  extended by org.fcrepo.server.journal.readerwriter.multicast.Transport
Direct Known Subclasses:
LocalDirectoryTransport, RmiTransport

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.

Version:
$Id: Transport.java,v 1.3 2007/06/01 17:21:31 jblake Exp $
Author:
jblake

Nested Class Summary
static class Transport.State
          The states of in the life-cycle of a Transport.
 
Field Summary
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 Summary
Transport(Map<String,String> parameters, boolean crucial, TransportParent parent)
           
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parameters

protected final Map<String,String> parameters
The parameters that were passed to this Transport for its use.


crucial

protected final boolean crucial
If this transport throws an Exception, is it a crucial problem?


parent

protected final TransportParent parent
The parent can format a file header or footer.

Constructor Detail

Transport

public Transport(Map<String,String> parameters,
                 boolean crucial,
                 TransportParent parent)
          throws JournalException
Throws:
JournalException
Method Detail

isCrucial

public boolean isCrucial()

testStateChange

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.

Throws:
JournalException

testWriterState

protected void testWriterState()
                        throws JournalException
Subclasses should call this before executing a getWriter request. This insures that the Transport is in the proper state.

Throws:
JournalException

setState

public void setState(Transport.State newState)
              throws JournalException
Subclasses should call this to change the current state, after the operation has been performed.

Throws:
JournalException

getState

public Transport.State getState()

openFile

public abstract void openFile(String repositoryHash,
                              String filename,
                              Date currentDate)
                       throws JournalException
Subclasses should implement this to create a new logical journal file. Check testStateChange before performing the operation, and call TransportParent.writeDocumentHeader(XMLEventWriter, String, Date) to do the formatting.

Throws:
JournalException

getWriter

public abstract XMLEventWriter getWriter()
                                  throws JournalException
Subclasses should implement this to provite an XMLEventWriter for the JournalWriter to write to. Check testWriterState() before performing the operation.

Throws:
JournalException

closeFile

public abstract void closeFile()
                        throws JournalException
Subclasses should implement this to close a logical journal file. Check testStateChange before performing the operation, and call TransportParent.writeDocumentTrailer(XMLEventWriter) to do the formatting.

Throws:
JournalException

shutdown

public abstract void shutdown()
                       throws JournalException
Subclasses should implement this to close any resources associated with the Transport (unless it is already shut down). Check testStateChange before performing the operation.

Throws:
JournalException


Copyright © 2011 DuraSpace. All Rights Reserved.