|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.cysols.iodef.transport.IodefXMLFileSender
public abstract class IodefXMLFileSender
This class provides a IODEF message transfer API via network through the various ways. This class
is an abstract class and its concrete sub class implements transport method. An actual way to
transport messages is implemented in the method. It is possible to call sendAllXMLFiles method
after preparing the concrete transport mehotd; it will send XML files by using Email, FTP, etc.
By giving a Properties instance to its constructor, this class can have it as configuration
parameter and can use it in the sub class.
sendAllXMLFiles method calls transport method and moves the sent file to COMPLETE_DIR. The dierectory is obtained from the configuration parameter. The sent files will be preserved under the directory.
In sendAllXMLFiles method, "notifySuccess" method is called when the xml file is sent correctly or
"notifyFailure" method is called if it is unable to send the xml file. This abstract class has empty implementations
of them. The concrete sub class needs their orver-ridden methods in which Logging, Notification or something
will be implemented.
The concrete sub class of this abstract class will have the following implementation.
public class MyOwnSender extends IodefXMLFileSender {
public MyOwnSender(Properties prop) {
super(prop);
# Setting configuration parameters...
}
public void transport(File xmlFile) throws FileNotFoundException, XMLReaderException, TransportFailedException {
# Sending the xmlFile by using concrete way like EMail, FTP, etc
}
public void notifySuccess(File xmlFile) {
# Logging the succeeded message
}
public void notifyFailure(File xmlFile, Throwable e) {
# Logging the failure message.
}
public static void main(String[] args) {
IodefXMLFileSender sender = null;
Properties configuration = new Properties();
# Prepares parameters and sets it to the configuration instance.
sender = new MyOwnSender(configuration);
int result = sender.sendAllXMLFiles();
# Logging "result number files were sent"
}
}
| Field Summary | |
|---|---|
protected Properties |
configProp
A Properties instance variable in which configuration parameters for sending the xml file are kept. |
static String |
DEFAULT_COMPLETED_DIR
Default Completed directory in which the sent xml file is stored. |
| Constructor Summary | |
|---|---|
IodefXMLFileSender(Properties configProp)
A Properties instance is required to its constructor. |
|
IodefXMLFileSender(String configFilePath)
A constructor with the specified configuration file of IODEF transporting. |
|
| Method Summary | |
|---|---|
protected void |
copyToCompletedDir(File xmlFile)
Copies a xml file to the completed dir. |
File[] |
listQueueDir(String queueDir)
Returns an array of XML File instances from the specified Queue directory. |
void |
notifyFailure(File xmlFile,
Throwable e)
Called when the IODEF xml file could not be sent after sendAllXMLFiles method is called. |
void |
notifySuccess(File xmlFile)
Called when the IODEF xml file is sent correctly after sendAllXMLFiles method is called. |
int |
sendAllXMLFiles(File[] xmlFiles)
Sends the specified XML File instances. |
abstract void |
transport(File xmlFile)
Sends a mail with attaching the specifid file. |
void |
transport(String xmlFilePath)
Sends a XML file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_COMPLETED_DIR
protected Properties configProp
| Constructor Detail |
|---|
public IodefXMLFileSender(String configFilePath)
throws FileNotFoundException,
IOException
configFilePath - the file path of iodeftrans.conf.
FileNotFoundException - the specified file is missing.
IOException - unable to read the specified file.public IodefXMLFileSender(Properties configProp)
configProp - properties of the IODEF configuration parameters.
NullPointerException - thrown if the properties instance is NULL.| Method Detail |
|---|
public File[] listQueueDir(String queueDir)
queueDir - the specified Queue directory in which IODEF xml file is stored.
public int sendAllXMLFiles(File[] xmlFiles)
xmlFiles - an array of IODEF XML File instances to be sent.public void notifySuccess(File xmlFile)
xmlFile - the sent file instance.
public void notifyFailure(File xmlFile,
Throwable e)
xmlFile - the sent file instance.e - the cause of failure to store
public void transport(String xmlFilePath)
throws FileNotFoundException,
XMLReaderException,
TransportFailedException
xmlFilePath - a XML file path
FileNotFoundException - the specified file is missing.
XMLReaderException - the specfied XML file cannot be read correctly.
TransportFailedException - unable to send the xml file correctly.
public abstract void transport(File xmlFile)
throws FileNotFoundException,
XMLReaderException,
TransportFailedException
xmlFile - a XML File instance.
FileNotFoundException - the specified file is missing.
XMLReaderException - the specfied XML file cannot be read correctly.
TransportFailedException - unable to send the xml file correctly.
protected void copyToCompletedDir(File xmlFile)
throws FileNotFoundException,
IOException
xmlFile - the xml file which is moved to the completed dir.
FileNotFoundException - the specified file is missing.
IOException - thrown if IO Error occured.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||