net.sf.xbus.base.deletedMessageStore
Class DeletedMessageStore

java.lang.Object
  extended by net.sf.xbus.base.deletedMessageStore.DeletedMessageStore

public class DeletedMessageStore
extends java.lang.Object

DeletedMessageStore manages the saving of messages before they are deleted in case of an error.

It implements a Singleton pattern, where there is one instance per thread.


Method Summary
static java.lang.String[] getDeletedMessageFilenames()
          Reads the name of all files containing deleted messages.
static java.lang.String getDirectory()
          Reads the name of the directory of the deleted messages out of the configuration.
static DeletedMessageStore getInstance()
          Returns an instance of the DeletedMessageStore.
static java.lang.String resendDeletedMessage(java.lang.String filename)
          Reads a deleted message and makes a new attempt to send it to its destinations.
 void setMessage(java.lang.Object message)
          Set the message that shall be saved.
 void setSystem(XBUSSystem system)
          Sets the system that has received the message.
 boolean writeMessage()
          Writes the name of the system, its additional addresses and the message into a XML file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static DeletedMessageStore getInstance()
Returns an instance of the DeletedMessageStore. A new instance will be created if there is none existing for this thread.

Returns:
an instance of the DeletedMessageStore

setMessage

public void setMessage(java.lang.Object message)
Set the message that shall be saved. The XML file will contain the String representation of this object.

Parameters:
message - the message to be saved

setSystem

public void setSystem(XBUSSystem system)
Sets the system that has received the message.

Parameters:
system - the receiving message

writeMessage

public boolean writeMessage()
Writes the name of the system, its additional addresses and the message into a XML file. The name of the directory is read out of the configuration. The filename is system.getCompleteName().xml.timestamp.

Returns:
true if the writing has been successful, false if there has been a problem

getDeletedMessageFilenames

public static java.lang.String[] getDeletedMessageFilenames()
                                                     throws XException
Reads the name of all files containing deleted messages.

Returns:
an array with the name of all files containing deleted messages
Throws:
XException - if any error occures

resendDeletedMessage

public static java.lang.String resendDeletedMessage(java.lang.String filename)
Reads a deleted message and makes a new attempt to send it to its destinations.

Parameters:
filename - the name of a file containing a deleted message
Returns:
a message of success or failure

getDirectory

public static java.lang.String getDirectory()
                                     throws XException
Reads the name of the directory of the deleted messages out of the configuration.

Returns:
the name of the directory containing the deleted messages
Throws:
XException - if any error occures