|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.xmlBlaster.util.xbformat.MsgInfo
public class MsgInfo
Holds MsgUnits from socket or email protocol drivers with additional tranport
attributes.
This class creates and parses raw byte[] messages which can be used to
transfer over a socket connection or as email attachment.
MsgInfo instances may be reused, but are NOT reentrant (there are many
'global' variables)
Field Summary | |
---|---|
private java.util.Map |
bounceObjects
Transports information from receiver to response instance (Hack?) |
private byte |
byte4
flag field 4 |
private byte |
byte5
flag field 5 |
private boolean |
checksum
flag field number one |
private boolean |
compressed
flag field 2 |
static byte |
EXCEPTION_BYTE
|
private Global |
glob
|
static byte |
INVOKE_BYTE
|
private static java.util.logging.Logger |
log
|
private static java.lang.String |
ME
|
private MethodName |
methodName
|
private I_MsgInfoParser |
msgInfoParser
|
private java.util.Vector |
msgVec
Holding MsgUnitRaw objects which acts as a holder for the method arguments |
private I_PluginConfig |
pluginConfig
|
private I_ProgressListener |
progressListener
|
private java.lang.String |
requestId
|
protected boolean |
requestIdGuessed
Remember if we got an explicit requestId or if we extracted it from the email-sentDate |
static byte |
RESPONSE_BYTE
|
private java.lang.String |
sessionId
|
private byte |
type
flag field 3 |
private int |
version
flag field 6 |
Constructor Summary | |
---|---|
MsgInfo(Global glob)
The same instance object may be reused. |
|
MsgInfo(Global glob,
byte type,
MethodName methodName,
java.lang.String sessionId)
Create a raw message. |
|
MsgInfo(Global glob,
byte type,
MethodName methodName,
java.lang.String sessionId,
I_ProgressListener progressListener)
|
|
MsgInfo(Global glob,
byte type,
MethodName methodName,
java.lang.String sessionId,
I_ProgressListener progressListener,
java.lang.String msgInfoParserClassName)
|
|
MsgInfo(Global glob,
byte type,
java.lang.String requestId,
MethodName methodName,
java.lang.String sessionId,
I_ProgressListener progressListener)
|
|
MsgInfo(Global glob,
I_ProgressListener progressListener)
Ctor to parse messages with msgInfo.parse(iStream); |
Method Summary | |
---|---|
void |
addException(XmlBlasterException e)
Use for exception message NOTE: Exceptions don't return |
void |
addKeyAndQos(java.lang.String key,
java.lang.String qos)
Use for methods get, subscribe, unSubscribe, erase |
void |
addMessage(MsgUnitRaw msg)
Use for methods update, publish. |
void |
addMessage(MsgUnitRaw[] arr)
Use for methods update, publish. |
void |
addMessage(java.lang.String qos)
Add a QoS value, use for methods connect, disconnect, ping. |
void |
addMessage(java.lang.String[] qos)
Add a QoS array value. |
void |
addQos(java.lang.String[] qos)
|
byte[] |
createRawMsg()
Access the serialized message, ready to send over the wire. |
byte[] |
createRawMsg(java.lang.String className)
Access the serialized message, ready to send over the wire. |
java.lang.String |
createRequestId(java.lang.String prefix)
Use this when sending a message. |
MsgInfo |
createReturner(byte type)
Creates a new instance with the meta info from source. |
java.lang.String |
dump()
|
AttachmentHolder[] |
getBounceAttachments()
|
java.lang.Object |
getBounceObject(java.lang.String key)
|
java.util.Map |
getBounceObjects()
|
XmlBlasterException |
getException()
On errors. |
MsgUnitRaw[] |
getMessageArr()
Returns all messages as an array. |
java.util.Vector |
getMessages()
Returns all messages in a Vector |
MethodName |
getMethodName()
For example MethodName.PUBLISH |
java.lang.String |
getMethodNameStr()
Access the method name as a string |
I_MsgInfoParser |
getMsgInfoParser(java.lang.String className,
I_PluginConfig pluginConfig)
Note this method gets (returns) the associated I_MsgInfoParser if it was not initialized before. |
int |
getNumMessages()
|
I_PluginConfig |
getPluginConfig()
|
I_ProgressListener |
getProgressListener()
|
java.lang.String |
getQos()
Response is usually only a QoS |
java.lang.String[] |
getQosArr()
Response is usually only a QoS |
java.lang.String |
getRequestId()
Use this when receiving a message. |
long |
getRequestSequence()
The monoton increasing sequence number (extracted from the requestId which could in fact contain other things than just the long. |
java.lang.String |
getSecretSessionId()
The authentication sessionId |
byte |
getType()
|
static char |
getTypeChar(byte type)
Access the char representation to send over the wire. |
java.lang.String |
getTypeStr()
Similar to getType() but returns a nice human readable string for logging output |
static java.lang.String |
getTypeStr(byte type)
Similar to getType() but returns a nice human readable string for logging output |
(package private) long |
getUserDataLen()
Calculates the length of user data including null bytes and len field |
int |
getVersion()
|
void |
initialize()
This method allows to reuse a MsgInfo instance. |
boolean |
isChecksum()
|
boolean |
isCompressed()
|
static boolean |
isCompressed(java.lang.String fileName,
java.lang.String mimeType)
Guessing if attachment is compressed. |
boolean |
isException()
|
boolean |
isInvoke()
|
boolean |
isRequestIdGuessed()
Check if we got an explicit requestId or if we extracted it for example from the email-sentDate. |
boolean |
isResponse()
|
static void |
main(java.lang.String[] args)
java org.xmlBlaster.util.xbformat.MsgInfo java org.xmlBlaster.util.xbformat.MsgInfo org.xmlBlaster.util.xbformat.XmlScriptParser TODO: Put into test suite with xmlunit |
static MsgInfo[] |
parse(Global glob,
I_ProgressListener progressListener,
byte[] rawMsg,
java.lang.String className,
I_PluginConfig pluginConfig)
Convenience method. |
static MsgInfo[] |
parse(Global glob,
I_ProgressListener progressListener,
java.io.InputStream in,
java.lang.String className,
I_PluginConfig pluginConfig)
Convenience method. |
void |
removeMessage(MsgUnitRaw msg)
|
java.lang.Object |
setBounceObject(java.lang.String key,
java.lang.Object value)
You can use this as a generic store to convej stuff in MsgInfo. |
void |
setBounceObjects(java.util.Map bounceObjects)
Sets the given map. |
void |
setByte4(byte byte4)
|
void |
setByte5(byte byte5)
|
void |
setChecksum(boolean checksum)
Enable checksum? |
void |
setCompressed(boolean compressed)
Compress message? NOTE: This compressed flag is set if the SOCKET header is plain text and the MsgUnit[] is compressed. |
void |
setMethodName(MethodName methodName)
For example MethodName.PUBLISH |
void |
setMsgInfoParser(I_MsgInfoParser msgInfoParser)
|
void |
setMsgInfoParser(java.lang.String className)
|
void |
setPluginConfig(I_PluginConfig pluginConfig)
|
void |
setRequestId(java.lang.String requestId)
Set a unique ID (unique for this client), it will be bounced back with the return value or with an exception occurred during this request. |
void |
setRequestIdGuessed(boolean requestIdGuessed)
|
void |
setSecretSessionId(java.lang.String sessionId)
The authentication sessionId |
void |
setType(byte type)
|
void |
setVersion(int version)
|
long |
size()
The number of bytes of qos+key+content |
java.lang.String |
toLiteral()
Get the raw messages as a string, for tests and for dumping only |
static java.lang.String |
toLiteral(byte[] rawMsg)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String ME
private final Global glob
private static java.util.logging.Logger log
public static final byte INVOKE_BYTE
public static final byte RESPONSE_BYTE
public static final byte EXCEPTION_BYTE
private boolean checksum
private boolean compressed
private byte type
private byte byte4
private byte byte5
private int version
private java.lang.String requestId
protected boolean requestIdGuessed
private MethodName methodName
private java.lang.String sessionId
private I_ProgressListener progressListener
private java.util.Vector msgVec
private I_MsgInfoParser msgInfoParser
private I_PluginConfig pluginConfig
private java.util.Map bounceObjects
Constructor Detail |
---|
public MsgInfo(Global glob)
public MsgInfo(Global glob, I_ProgressListener progressListener)
public MsgInfo(Global glob, byte type, MethodName methodName, java.lang.String sessionId)
glob
- type
- methodName
- sessionId
- public MsgInfo(Global glob, byte type, MethodName methodName, java.lang.String sessionId, I_ProgressListener progressListener, java.lang.String msgInfoParserClassName) throws XmlBlasterException
XmlBlasterException
public MsgInfo(Global glob, byte type, MethodName methodName, java.lang.String sessionId, I_ProgressListener progressListener)
public MsgInfo(Global glob, byte type, java.lang.String requestId, MethodName methodName, java.lang.String sessionId, I_ProgressListener progressListener)
Method Detail |
---|
public MsgInfo createReturner(byte type)
type
- Please choose RESPONSE_BYTE or EXCEPTION_BYTE
public void initialize()
public static boolean isCompressed(java.lang.String fileName, java.lang.String mimeType)
fileName
- mimeType
-
public int getNumMessages()
public final void setType(byte type)
type
- The method type, e.g. MsgInfo.INVOKE_BYTEpublic final byte getType()
public static char getTypeChar(byte type)
type
-
public final java.lang.String getTypeStr()
public static final java.lang.String getTypeStr(byte type)
public final boolean isInvoke()
public final boolean isResponse()
public final boolean isException()
public final void setRequestId(java.lang.String requestId)
public final java.lang.String createRequestId(java.lang.String prefix)
Get a unique ID (unique for this client), it will be bounced back with the return value or with an exception occurred during this request
prefix
- If desired you can specify a prefix for the request ID, e.g.
"joe:"
public final java.lang.String getRequestId()
public final long getRequestSequence()
public final void setMethodName(MethodName methodName)
public final MethodName getMethodName()
public final java.lang.String getMethodNameStr()
public final void setSecretSessionId(java.lang.String sessionId)
public final java.lang.String getSecretSessionId()
public final void setChecksum(boolean checksum)
public final void setCompressed(boolean compressed)
public final void addKeyAndQos(java.lang.String key, java.lang.String qos) throws XmlBlasterException
java.lang.IllegalArgumentException
- if invoked multiple times
XmlBlasterException
public final void addException(XmlBlasterException e) throws XmlBlasterException
java.lang.IllegalArgumentException
- if invoked multiple times
XmlBlasterException
public final void addMessage(MsgUnitRaw msg)
public final void removeMessage(MsgUnitRaw msg)
public final void addMessage(MsgUnitRaw[] arr)
public final void addMessage(java.lang.String qos) throws XmlBlasterException
java.lang.IllegalArgumentException
- if invoked multiple times
XmlBlasterException
public final void addMessage(java.lang.String[] qos) throws XmlBlasterException
java.lang.IllegalArgumentException
- if invoked multiple times
XmlBlasterException
public final void addQos(java.lang.String[] qos) throws XmlBlasterException
XmlBlasterException
addMessage(String[] qos)
public final java.util.Vector getMessages()
public final MsgUnitRaw[] getMessageArr()
public final java.lang.String getQos()
java.lang.IllegalArgumentException
- if there is no QoS to getpublic final java.lang.String[] getQosArr()
java.lang.IllegalArgumentException
- if there is no QoS to getpublic final XmlBlasterException getException()
java.lang.IllegalArgumentException
- if there is no exception to getlong getUserDataLen()
java.lang.IllegalArgumentException
- Message size is limited to Integer.MAX_VALUE bytespublic long size()
public void setByte4(byte byte4)
byte4
- The byte4 to set.public void setByte5(byte byte5)
byte5
- The byte5 to set.public int getVersion()
public void setVersion(int version)
version
- The version to set.public final boolean isChecksum()
public final boolean isCompressed()
public I_MsgInfoParser getMsgInfoParser(java.lang.String className, I_PluginConfig pluginConfig) throws XmlBlasterException
className
- Can be nullpluginConfig
- Can be null
XmlBlasterException
public void setMsgInfoParser(I_MsgInfoParser msgInfoParser)
msgInfoParser
- The msgInfoParser to set.public void setMsgInfoParser(java.lang.String className) throws XmlBlasterException
msgInfoParser
- The msgInfoParser to set.
XmlBlasterException
public final java.lang.String dump()
public final java.lang.String toLiteral() throws XmlBlasterException
XmlBlasterException
public static java.lang.String toLiteral(byte[] rawMsg) throws XmlBlasterException
XmlBlasterException
public final byte[] createRawMsg() throws XmlBlasterException
XmlBlasterException
public final byte[] createRawMsg(java.lang.String className) throws XmlBlasterException
className
- The parser/serializer to use
XmlBlasterException
public static MsgInfo[] parse(Global glob, I_ProgressListener progressListener, java.io.InputStream in, java.lang.String className, I_PluginConfig pluginConfig) throws java.io.IOException, XmlBlasterException
in
- className
- Class implementing I_MsgInfoParser
Can be null to choose the default parser
java.io.IOException
XmlBlasterException
public static MsgInfo[] parse(Global glob, I_ProgressListener progressListener, byte[] rawMsg, java.lang.String className, I_PluginConfig pluginConfig) throws java.io.IOException, XmlBlasterException
className
- Class implementing I_MsgInfoParser
Can be null to choose the default parserpluginConfig
- The configuration of the plugin, can be null
java.io.IOException
XmlBlasterException
public java.util.Map getBounceObjects()
public AttachmentHolder[] getBounceAttachments()
public java.lang.Object getBounceObject(java.lang.String key)
public void setBounceObjects(java.util.Map bounceObjects)
public java.lang.Object setBounceObject(java.lang.String key, java.lang.Object value)
key
- The identifier of the object.value
- The bounceObjects to set, if null nothing happens.public I_ProgressListener getProgressListener()
public static void main(java.lang.String[] args)
public boolean isRequestIdGuessed()
public void setRequestIdGuessed(boolean requestIdGuessed)
requestIdGuessed
- The requestIdGuessed to set.public I_PluginConfig getPluginConfig()
public void setPluginConfig(I_PluginConfig pluginConfig)
|
xmlBlaster 2.2.0 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |