net.sf.xbus.protocol
Class MessageFactory

java.lang.Object
  extended by net.sf.xbus.protocol.MessageFactory

public class MessageFactory
extends java.lang.Object

The class MessageFactory is used to dynamically create messages. It implements the Factory Design-Pattern.


Field Summary
static int TRANSFORM_FROM_REQUEST
           
static int TRANSFORM_FROM_RESPONSE
           
 
Constructor Summary
MessageFactory()
           
 
Method Summary
static Message createApplicationMessage(XBUSSystem source)
          The appropriate Message -object for the given source will be created.
static Message createSenderMessage(XBUSSystem destination, Message sourceMessage, int convertFrom)
          The appropriate Message object which is needed to send a message to the given destination will be created.
static void transformResponse2Response(XBUSSystem source, XBUSSystem destination, Message sourceMessage, Message destinationMessage)
          Transforms the response of a source message to the response of a destination message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRANSFORM_FROM_REQUEST

public static final int TRANSFORM_FROM_REQUEST
See Also:
Constant Field Values

TRANSFORM_FROM_RESPONSE

public static final int TRANSFORM_FROM_RESPONSE
See Also:
Constant Field Values
Constructor Detail

MessageFactory

public MessageFactory()
Method Detail

createApplicationMessage

public static Message createApplicationMessage(XBUSSystem source)
                                        throws XException
The appropriate Message -object for the given source will be created. The name of the appropriate Message class is read from the Configuration.

Parameters:
source - the name of the system, from which the message was received
Throws:
XException

transformResponse2Response

public static void transformResponse2Response(XBUSSystem source,
                                              XBUSSystem destination,
                                              Message sourceMessage,
                                              Message destinationMessage)
                                       throws XException
Transforms the response of a source message to the response of a destination message.

Parameters:
source - the system name where the response of the source message is coming from
destination - the system name where the response of the destination message shall be sent to
sourceMessage - the Message from which the response to transform is taken.
destinationMessage - the Message whose response is filled
Throws:
XException

createSenderMessage

public static Message createSenderMessage(XBUSSystem destination,
                                          Message sourceMessage,
                                          int convertFrom)
                                   throws XException
The appropriate Message object which is needed to send a message to the given destination will be created. At this point either the request or the response of the incoming Message will be converted to the request of the outgoing Message.

Parameters:
destination - the name of the system where the message will be send to
sourceMessage - the Message from which the new Message will be initialized
convertFrom - flag wether the request or the response of the sourceMessage is used to fill the request of the new Message
Throws:
XException