net.sf.xbus.technical.ftp
Class FTPSender

java.lang.Object
  extended by net.sf.xbus.technical.ftp.FTPSender
All Implemented Interfaces:
TAResource, Sender, TextSender

public class FTPSender
extends java.lang.Object
implements Sender, TextSender, TAResource

FTPSender sends data to neighbor systems by accessing a FTP server and writing the data onto this server.


Constructor Summary
FTPSender(XBUSSystem destination)
          The constructor stores the destination, registers the FTPSender at the TAManager and opens the connection to the FTP server.
 
Method Summary
 void close()
          Closes the connection to the FTP server.
 void commit()
          Renames the temporary file to the original file name.
 java.lang.String execute(java.lang.String function, java.lang.String callData)
          Writes the data to the FTP server.
 java.lang.String getType()
          A Sender can send data either as a String or as an Object to the neighboring system.
 void open()
          Opens the connection to a FTP server, using the FTPConnection.
 void rollback()
          Deletes the temporary file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FTPSender

public FTPSender(XBUSSystem destination)
          throws XException
The constructor stores the destination, registers the FTPSender at the TAManager and opens the connection to the FTP server.

Parameters:
destination - where the data shall be send to
Throws:
XException - if something goes wrong
Method Detail

execute

public java.lang.String execute(java.lang.String function,
                                java.lang.String callData)
                         throws XException
Writes the data to the FTP server. A simple transaction logic is implemented: The data will be written to a temporary file. It will be moved to the original file name during commit().

Specified by:
execute in interface TextSender
Parameters:
function - ignored
callData - data to be written
Returns:
null
Throws:
XException - if something goes wrong

open

public void open()
          throws XException
Opens the connection to a FTP server, using the FTPConnection.

Specified by:
open in interface TAResource
Throws:
XException - if something goes wrong

close

public void close()
Closes the connection to the FTP server.

Specified by:
close in interface TAResource

commit

public void commit()
            throws XException
Renames the temporary file to the original file name. If the file already exists, it will be either deleted or renamed, depending on the ConflictResolution.

Specified by:
commit in interface TAResource
Throws:
XException - if something goes wrong

rollback

public void rollback()
              throws XException
Deletes the temporary file.

Specified by:
rollback in interface TAResource
Throws:
XException - if something goes wrong

getType

public java.lang.String getType()
Description copied from interface: Sender
A Sender can send data either as a String or as an Object to the neighboring system.
When working with Strings the Sender must fulfill two preconditions: When working with Objects the Sender must also fulfill two preconditions:

Specified by:
getType in interface Sender
Returns:
Constants.TYPE_TEXT
See Also:
Sender.getType()