net.sf.xbus.technical.file
Class FileReceiver

java.lang.Object
  extended by net.sf.xbus.technical.file.FileBase
      extended by net.sf.xbus.technical.file.FileReceiver
All Implemented Interfaces:
TAResource, Receiver, ReceiverSingleInterface
Direct Known Subclasses:
FileByteArrayListReceiver, FileLineReaderReceiver, FileStreamReceiver

public class FileReceiver
extends FileBase
implements Receiver, TAResource, ReceiverSingleInterface

When the FileReceiver receives a request it reads the files into a String and calls the application layer.


Field Summary
protected  FileReceiverConfiguration mConfiguration
           
protected  java.lang.String mCopyname
          Full path name of the copy from the original file to be read.
 
Constructor Summary
FileReceiver()
           
 
Method Summary
 void close()
          Is not implemented for file system
 void commit()
          Implemented method commit from TAResource interface.
protected  boolean doReceive(XBUSSystem xbusSystem)
          Manages the process of receipt for several XBUSSystems.
 java.lang.String getConfigFilename()
           
 java.lang.String getOnError()
           
protected  java.lang.Object getRequestContent()
          getRequestContent delivers the content of the request.
 java.lang.String getType()
          A Receiver can receive data either as a String or as an Object from a neighboring system.
 void open()
          Is not implemented for file system
 void readConfiguration(java.lang.String systemName)
          Reads some entries from the configuration.
 void receive(java.lang.String systemName)
          This method manages all processes of the receipt for one as parameter given name of the neighbor-system.
 void rollback()
          Implemented method rollback from TAResource ignores all changes have made since the beginning of the process (transaction).
 
Methods inherited from class net.sf.xbus.technical.file.FileBase
copyFile, deleteFile, getEncoding, getFileLength, getLastByteOfFile, renameFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mConfiguration

protected FileReceiverConfiguration mConfiguration

mCopyname

protected java.lang.String mCopyname
Full path name of the copy from the original file to be read.
The filename is with current date expanded.

Constructor Detail

FileReceiver

public FileReceiver()
Method Detail

receive

public void receive(java.lang.String systemName)
This method manages all processes of the receipt for one as parameter given name of the neighbor-system.

First, the list of XBUSSystemfor this system is determined by replacing the markers for additional adresses.

After that for each XBUSSystem the method doReceive(XBUSSystem) is invoked to read the file and process its content.

Specified by:
receive in interface ReceiverSingleInterface
Parameters:
systemName - name of the interface definition
Throws:
XException - if something goes wrong
See Also:
XBUSSystem.getSystems(String, String)

readConfiguration

public void readConfiguration(java.lang.String systemName)
                       throws XException
Reads some entries from the configuration.

Parameters:
systemName -
Throws:
XException - if anything goes wrong

doReceive

protected boolean doReceive(XBUSSystem xbusSystem)
Manages the process of receipt for several XBUSSystems. This method does the following:
  1. replace placeholders in the filename with the dealer information
  2. create copy and backup files, depending on the final resolution
  3. read file into String
  4. call application layer - Adapter
  5. determine the resulting returncode

Parameters:
xbusSystem - name of the interface definition

getRequestContent

protected java.lang.Object getRequestContent()
                                      throws XException
getRequestContent delivers the content of the request. Subclasses may define their own request content.

Returns:
the interface file content as String but casted to Object for compliance reasons
Throws:
XException

commit

public void commit()
            throws XException
Implemented method commit from TAResource interface. The purpose of commit actions is to remove any backup information that had been created during process(tansaction).

Depending on the FinalResolution, the following acts commit all actions.

Resolution Acts
Preserve delete copy file
Rename delete backup copy
Delete  1. delete copy file
 2. delete backup copy

Specified by:
commit in interface TAResource
Throws:
XException - if any error occurs
See Also:
TAResource.commit()

rollback

public void rollback()
              throws XException
Implemented method rollback from TAResource ignores all changes have made since the beginning of the process (transaction).

Depending on the FinalResolution, the following acts roll back all modifications that have been made in the file system:

Resolution Acts
Preserve delete copy file
Rename  1. rename backup copy to the original file
 2. delete copy file
Delete  1. rename backup copy to the original file
 2. delete copy file

Specified by:
rollback in interface TAResource
Throws:
XException - if any error occurs
See Also:
TAResource.rollback()

open

public void open()
Is not implemented for file system

Specified by:
open in interface TAResource

getConfigFilename

public java.lang.String getConfigFilename()

getOnError

public java.lang.String getOnError()

close

public void close()
Is not implemented for file system

Specified by:
close in interface TAResource

getType

public java.lang.String getType()
Description copied from interface: Receiver
A Receiver can receive data either as a String or as an Object from a neighboring system.

Specified by:
getType in interface Receiver