站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 3.2.7 messaging API Documentation 英文版文档

BaseMsg (JBoss Messaging API) - JBoss 3.2.7 messaging API Documentation 英文版文档


org.jboss.mq.il.uil2.msgs
Class BaseMsg

java.lang.Object
  extended byorg.jboss.mq.il.uil2.msgs.BaseMsg
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
AcknowledgementRequestMsg, AddMsg, BrowseMsg, CheckIDMsg, CheckUserMsg, CloseMsg, ConnectionTokenMsg, CreateDestMsg, DeleteSubscriptionMsg, DeleteTemporaryDestMsg, EnableConnectionMsg, GetIDMsg, PingMsg, ReceiveMsg, ReceiveRequestMsg, SubscribeMsg, TemporaryDestMsg, TransactMsg, UnsubscribeMsg

public class BaseMsg
extends Object
implements Runnable

The base msg class for all msgs used by the UIL2 invoker. Msgs consist of a msg type, id and exception and can operate as two way items that are sent with the request content and received with the reply content for the request. Such round-trip behavior is based on matching the request msgID with the reply msgID. The msgID parameter is segmented into value 1 to 2147483647 for client originated msgs and -1 to -2147483647 for server originated msgs.

The message is a Runnable to avoid constructing a Runnable object when asynchronously handling the message from the ReadTask.

Version:
$Revision: 1.1.4.4 $
Author:
Scott.Stark@jboss.org, Adrian.Brock@HappeningTimes.com

Field Summary
 Exception error
          Any error thrown by the remote side
 int msgID
          A msg id used to associated a reply with its request
 int msgType
          The MsgTypes constant representing the type of the msg
 
Constructor Summary
BaseMsg(int msgType)
           
BaseMsg(int msgType, int msgID)
           
 
Method Summary
static BaseMsg createMsg(int msgType)
          Create a BaseMsg subclass based on the msgType.
 boolean equals(Object o)
          Equality is based on BaseMsg.msgID
 Exception getError()
          Access any exception associated with the msg
 int getMsgID()
          Access the msgID, initializing it if it has not been set yet.
 int getMsgType()
           
 int hashCode()
          Hash code is simply the msgID
 void read(ObjectInputStream in)
          Read the hasError flag and optionally the error.
 void run()
           
 void setError(Throwable e)
          Set an exception that should be used as the msg return value.
 void setHandler(SocketManager.ReadTask handler)
           
 void setMsgID(int msgID)
          Set the msgID.
static void setUseJMSServerMsgIDs(boolean flag)
          Set the msgID parameter range.
 String toString()
           
static String toString(int msgType)
          Translate a msgType into its string menmonic.
 void trimReply()
          Trim the message when replying
 void write(ObjectOutputStream out)
          Write the msgType, msgID, hasError flag and optionally the error
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

msgType

public int msgType
The MsgTypes constant representing the type of the msg


msgID

public int msgID
A msg id used to associated a reply with its request


error

public Exception error
Any error thrown by the remote side

Constructor Detail

BaseMsg

public BaseMsg(int msgType)

BaseMsg

public BaseMsg(int msgType,
               int msgID)
Method Detail

setUseJMSServerMsgIDs

public static void setUseJMSServerMsgIDs(boolean flag)
Set the msgID parameter range. If false, the msgID is segmented into the range 1 to 2147483647 and if true, the rangs is -1 to -2147483647. The JMS server sets this to true and clients default to false.

Parameters:
flag -

createMsg

public static BaseMsg createMsg(int msgType)
                         throws IllegalArgumentException
Create a BaseMsg subclass based on the msgType.

Parameters:
msgType - A MsgTypes.m_xxx constant
Returns:
the derived BaseMsg
Throws:
IllegalArgumentException - thrown for a msgType that does not match any MsgTypes.m_xxx constant

toString

public static String toString(int msgType)
Translate a msgType into its string menmonic.

Parameters:
msgType - A MsgTypes.m_xxx constant
Returns:
the string form of the MsgTypes.m_xxx constant

getMsgType

public int getMsgType()

getMsgID

public int getMsgID()
Access the msgID, initializing it if it has not been set yet. This is used by the SocketManager.internalSendMessage to setup the unique msgID for a request msg.

Returns:
the msgID value

setMsgID

public void setMsgID(int msgID)
Set the msgID. This is used by the SocketManager read task to populate a msg with its request ID.

Parameters:
msgID - the msgID read off the socket

getError

public Exception getError()
Access any exception associated with the msg

Returns:

setError

public void setError(Throwable e)
Set an exception that should be used as the msg return value.

Parameters:
e -

equals

public boolean equals(Object o)
Equality is based on BaseMsg.msgID

Parameters:
o - a BaseMsg
Returns:
true if o.msgID == msgID

hashCode

public int hashCode()
Hash code is simply the msgID

Returns:

toString

public String toString()

trimReply

public void trimReply()
Trim the message when replying


write

public void write(ObjectOutputStream out)
           throws IOException
Write the msgType, msgID, hasError flag and optionally the error

Parameters:
out -
Throws:
IOException

read

public void read(ObjectInputStream in)
          throws IOException,
                 ClassNotFoundException
Read the hasError flag and optionally the error. This method is not a complete analog of write because the SocketManager read task reads the msgType and msgID off of the socket.

Parameters:
in -
Throws:
IOException
ClassNotFoundException

setHandler

public void setHandler(SocketManager.ReadTask handler)

run

public void run()
Specified by:
run in interface Runnable


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.