com.softwareag.entirex.aci
Class BrokerMessage

java.lang.Object
  extended by com.softwareag.entirex.aci.BrokerMessage

public class BrokerMessage
extends java.lang.Object

This class encapsulates a single message, which will be sent to or received from another participant via the EntireX Broker.
The contents of a message is always a byte array. Constructors and methods, which provide a transformation between byte arrays and String objects, are available.
When the message has been created as the result of a successful receive or sendReceive call, the getService(), getConversation() and getUnitofWork() methods can be used to navigate to the context of the received message.


Constructor Summary
BrokerMessage()
          Creates a Message object with an empty message.
BrokerMessage(byte[] msg)
          Creates a Message object initialized with the passed byte array.
BrokerMessage(java.lang.String msg)
          Creates a BrokerMessage object initialized with the passed String object.
 
Method Summary
 byte[] getClientIAFToken()
          Gets the IAF Security Token for the client.
 java.lang.String getClientUID()
          Returns the client's user ID.
 Conversation getConversation()
          Returns the corresponding Conversation object.
 byte[] getMessage()
          Returns the current message as a byte array.
 BrokerService getService()
          Returns the BrokerService object to which the message belongs.
 UnitofWork getUnitofWork()
          Returns the corresponding UnitofWork object.
 void reply(BrokerMessage msg)
          Sends a reply to a previously received message.
 void setMessage(byte[] s)
          Sets the current message to the passed byte array.
 void setMessage(java.lang.String s)
          Sets the current message to the passed string.
 java.lang.String toString()
          Returns the current message as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BrokerMessage

public BrokerMessage()
Creates a Message object with an empty message.


BrokerMessage

public BrokerMessage(byte[] msg)
Creates a Message object initialized with the passed byte array.

Parameters:
msg - the message as byte array.

BrokerMessage

public BrokerMessage(java.lang.String msg)
Creates a BrokerMessage object initialized with the passed String object. The String object is converted to a byte array.

Parameters:
msg - the message as a String object.
Method Detail

toString

public java.lang.String toString()
Returns the current message as a string.

Overrides:
toString in class java.lang.Object
Returns:
The message data as a String or null.

getClientUID

public java.lang.String getClientUID()
Returns the client's user ID. Only available after a receive issued by a server application.

Returns:
The client's user ID as a string or null.

getMessage

public byte[] getMessage()
Returns the current message as a byte array.

Returns:
the message as a byte array or null.

setMessage

public void setMessage(byte[] s)
Sets the current message to the passed byte array.

Parameters:
s - the message as byte array.

setMessage

public void setMessage(java.lang.String s)
Sets the current message to the passed string.

Parameters:
s - the message as string.

getService

public BrokerService getService()
Returns the BrokerService object to which the message belongs. Only available when the Message object has been created by a receive or sendReceive call.

Returns:
a reference to the BrokerService object.

getConversation

public Conversation getConversation()
Returns the corresponding Conversation object.
If the message has been created by a receive or sendReceive call and if the message is part of a conversational communication, this method returns the corresponding Conversation object. Otherwise, null is returned.

Returns:
a reference to the Conversation object or null.

getUnitofWork

public UnitofWork getUnitofWork()
Returns the corresponding UnitofWork object.
If the message has been created by a receive call and if the message is part of a UnitofWork communication, this method returns the corresponding UnitofWork object. Otherwise, null is returned.

Returns:
a reference to the Conversation object or null.

reply

public void reply(BrokerMessage msg)
           throws BrokerException
Sends a reply to a previously received message.
If the message has been created by a receive or sendReceive call and if the message is either the only message of a non-conversational communication or if the message is part of a conversational communication, this method sends a reply back to the originator of this message.

Parameters:
msg - BrokerMessage to send.
Throws:
BrokerException - A Broker exception.
java.lang.IllegalArgumentException - Thrown if the parameter is invalid.

getClientIAFToken

public byte[] getClientIAFToken()
Gets the IAF Security Token for the client. Only available after a receive issued by a server application.

Returns:
the IAF Security Token for the client.