net.sf.xbus.protocol.xml
Class XMLMessageAbstract

java.lang.Object
  extended by net.sf.xbus.protocol.Message
      extended by net.sf.xbus.protocol.xml.XMLMessageAbstract
All Implemented Interfaces:
ObjectMessage, TextMessage, XMLMessage
Direct Known Subclasses:
ByteArrayListMessage, CSVMessage, RecordTypeMessage, SOAPMessage, XBUSXMLMessage, XMLMessageImplementation

public abstract class XMLMessageAbstract
extends Message
implements TextMessage, ObjectMessage, XMLMessage

XMLMessage is the base class for all messages in the XML format.

It holds the XML data internally as an org.w3c.dom.Document. Therefore it is more efficient to work with the Document representation than with the String representation. When working with String representation, parsing and serializing is done internally.


Constructor Summary
XMLMessageAbstract(java.lang.String function, XBUSSystem source, java.lang.String id)
          This constructor initializes the new XMLMessage with the given parameters.
XMLMessageAbstract(XBUSSystem source)
          This constructor stores the source, creates an unique identifier for the message and initializes the requestTimestamp.
 
Method Summary
protected  javax.xml.parsers.DocumentBuilder getDocumentBuilder(XBUSSystem system)
          Returns an adequate DocumentBuilder for this message
 org.w3c.dom.Document getRequestDocument(XBUSSystem system)
          Returns the request XML data as a org.w3c.dom.Document.
 java.lang.Object getRequestObject(XBUSSystem system)
          Gets the object from an incomimg message.
 java.lang.String getRequestText(XBUSSystem source)
          Gets the text of the incoming message.
 org.w3c.dom.Document getResponseDocument()
          Returns the response XML data as a org.w3c.dom.Document.
 java.lang.Object getResponseObject()
          Gets the object of the outgoing message.
 java.lang.String getResponseText()
          Gets the text of the outgoing message.
protected  org.w3c.dom.Document parseXML(java.lang.String xml, XBUSSystem system)
          Parses the given XML string.
protected static java.lang.String serializeXML(org.w3c.dom.Document doc, java.lang.String systemID)
          Serializes the given org.w3c.dom.Document.
 void setRequestDocument(org.w3c.dom.Document doc, XBUSSystem source)
          Sets the request XML data as a org.w3c.dom.Document.
 void setRequestObject(java.lang.Object object, XBUSSystem source)
          Sets the object from an incomimg message.
 void setRequestText(java.lang.String text, XBUSSystem source)
          Sets the text of the incoming message.
 void setResponseDocument(org.w3c.dom.Document doc, XBUSSystem destination)
          Sets the response XML data as a org.w3c.dom.Document.
 void setResponseObject(java.lang.Object object, XBUSSystem destination)
          Sets the object of the outgoing message.
 void setResponseText(java.lang.String text, XBUSSystem destination)
          Sets the text of the outgoing message.
protected abstract  void synchronizeRequestFields(XBUSSystem system)
          After setting the request data, both setRequestText and setRequestDocument, some fields of the Message must be synchronized with the request data.
protected abstract  void synchronizeResponseFields(XBUSSystem system)
          After setting the response data, both setResponseText and setResponseDocument, some fields of the Message must be synchronized with the response data.
 
Methods inherited from class net.sf.xbus.protocol.Message
getErrorcode, getErrortext, getFunction, getId, getRequestTimestamp, getResponseTimestamp, getReturncode, getShortname, getSource, setErrorcode, setErrortext, setFunction, setId, setResponseTimestamp, setReturncode, setShortname
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLMessageAbstract

public XMLMessageAbstract(XBUSSystem source)
This constructor stores the source, creates an unique identifier for the message and initializes the requestTimestamp. It is used when constructing a new XMLMessage from the data of a receiver.

Parameters:
source - the system where the message is coming from

XMLMessageAbstract

public XMLMessageAbstract(java.lang.String function,
                          XBUSSystem source,
                          java.lang.String id)
This constructor initializes the new XMLMessage with the given parameters. It is used when constructing a new XMLMessage by converting it from another Message.

Parameters:
function - the function of the other Message
source - the source of the other Message
id - the id of the other Message
Method Detail

getRequestText

public java.lang.String getRequestText(XBUSSystem source)
                                throws XException
Gets the text of the incoming message. It is the result of the serialization of the internally used org.w3c.dom.Document.

Specified by:
getRequestText in interface TextMessage
Parameters:
source - ignored
Returns:
the request XML document as a String
Throws:
XException

setRequestText

public void setRequestText(java.lang.String text,
                           XBUSSystem source)
                    throws XException
Sets the text of the incoming message. After parsing the XML string, the information is internally stored in a org.w3c.dom.Document.

Specified by:
setRequestText in interface TextMessage
Parameters:
text - a XML document from the request
source - system where the request is coming from
Throws:
XException

getResponseText

public java.lang.String getResponseText()
                                 throws XException
Gets the text of the outgoing message. It is the result of the serialization of the internally used org.w3c.dom.Document.

Specified by:
getResponseText in interface TextMessage
Returns:
the response XML document as a String
Throws:
XException

setResponseText

public void setResponseText(java.lang.String text,
                            XBUSSystem destination)
                     throws XException
Sets the text of the outgoing message. After parsing the XML string, the information is internally stored as a org.w3c.dom.Document.

Specified by:
setResponseText in interface TextMessage
Parameters:
text - a XML document from the response
destination - system where the response is coming from
Throws:
XException

getRequestDocument

public org.w3c.dom.Document getRequestDocument(XBUSSystem system)
Returns the request XML data as a org.w3c.dom.Document.

Specified by:
getRequestDocument in interface XMLMessage
Parameters:
system - reference to the system for which the message is meant
Returns:
the content of the request

setRequestDocument

public void setRequestDocument(org.w3c.dom.Document doc,
                               XBUSSystem source)
                        throws XException
Sets the request XML data as a org.w3c.dom.Document.

Specified by:
setRequestDocument in interface XMLMessage
Parameters:
doc - the content of the request
source - system where the request is coming from
Throws:
XException

getResponseDocument

public org.w3c.dom.Document getResponseDocument()
Returns the response XML data as a org.w3c.dom.Document.

Specified by:
getResponseDocument in interface XMLMessage
Returns:
the content of the response

setResponseDocument

public void setResponseDocument(org.w3c.dom.Document doc,
                                XBUSSystem destination)
                         throws XException
Sets the response XML data as a org.w3c.dom.Document.

Specified by:
setResponseDocument in interface XMLMessage
Parameters:
doc - the content of the response
destination - system where the response is coming from
Throws:
XException

getRequestObject

public java.lang.Object getRequestObject(XBUSSystem system)
                                  throws XException
Description copied from interface: ObjectMessage
Gets the object from an incomimg message.

Specified by:
getRequestObject in interface ObjectMessage
Parameters:
system - reference to the system for which the message is meant
Returns:
the content of the request
Throws:
XException
See Also:
ObjectMessage.getRequestObject(net.sf.xbus.base.xbussystem.XBUSSystem)

setRequestObject

public void setRequestObject(java.lang.Object object,
                             XBUSSystem source)
                      throws XException
Description copied from interface: ObjectMessage
Sets the object from an incomimg message.

Specified by:
setRequestObject in interface ObjectMessage
Parameters:
object - the content of the request
source - system where the request is coming from
Throws:
XException
See Also:
ObjectMessage.setRequestObject(java.lang.Object, net.sf.xbus.base.xbussystem.XBUSSystem)

getResponseObject

public java.lang.Object getResponseObject()
                                   throws XException
Description copied from interface: ObjectMessage
Gets the object of the outgoing message.

Specified by:
getResponseObject in interface ObjectMessage
Returns:
the content of the response
Throws:
XException
See Also:
ObjectMessage.getResponseObject()

setResponseObject

public void setResponseObject(java.lang.Object object,
                              XBUSSystem destination)
                       throws XException
Description copied from interface: ObjectMessage
Sets the object of the outgoing message.

Specified by:
setResponseObject in interface ObjectMessage
Parameters:
object - the content of the response
destination - system where the response is coming from
Throws:
XException
See Also:
ObjectMessage.setResponseObject(java.lang.Object, net.sf.xbus.base.xbussystem.XBUSSystem)

synchronizeRequestFields

protected abstract void synchronizeRequestFields(XBUSSystem system)
                                          throws XException
After setting the request data, both setRequestText and setRequestDocument, some fields of the Message must be synchronized with the request data.

Throws:
XException

synchronizeResponseFields

protected abstract void synchronizeResponseFields(XBUSSystem system)
                                           throws XException
After setting the response data, both setResponseText and setResponseDocument, some fields of the Message must be synchronized with the response data.

Throws:
XException

parseXML

protected org.w3c.dom.Document parseXML(java.lang.String xml,
                                        XBUSSystem system)
                                 throws XException
Parses the given XML string.

Throws:
XException

getDocumentBuilder

protected javax.xml.parsers.DocumentBuilder getDocumentBuilder(XBUSSystem system)
                                                        throws XException
Returns an adequate DocumentBuilder for this message

Throws:
XException

serializeXML

protected static java.lang.String serializeXML(org.w3c.dom.Document doc,
                                               java.lang.String systemID)
                                        throws XException
Serializes the given org.w3c.dom.Document.

Throws:
XException