|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectAMETAS.data.AMETASMessage
Message object. Place User merely communicate by sending and receiving these objects. All AMETAS messages are instances of this class. The message exchange is organized by the PostOffice of the place which stores deposited messages and holds them for retrieval by the recipient.
A message consists of a fixed-format header and a payload (aka body). Each message may be specified by the category, the subcategory, and further elements in the body. The first element of the body is commonly a String which is called specification. The first body object, however, need not necessarily be such a String. Furthermore, it is up to the application to evaluate other parts of the body to derive the message type.
There are six message categories which are predefined in this class. They declare the origin of the message. The specification may then refine this simple classification and help the recipient to correctly process the message.
Note that by using Strings for the specification, the risk of unintentional reuse of the same specification is smaller than when using numbers. Furthermore, Strings are easier to read, preventing programming errors. However, you must make sure that the sender actually knows the Strings which are used in your messages. See the respective explanations in the context of the Hybrid type system.Some important notes on header fields.
There is no constructor offering to set the sender ID. Although there is a method which seems to allow that, it is useless to call this method because the Place User driver will fill in this field. This is not only easier for the implementor; it also prevents errors or spoofing.
The category field cannot be set by the Place User; it is set by the driver. All agents and user adapters always send APPLICATION messages, regardless of the recipient. Services only send SERVICE messages. Only the place is able to set the category itself, so producing PLACE or SECURITY messages.
The subcategory field specifies the meaning of this message in terms of how it should control the processing, regardless of the contents or the category. Normal messages are REQUESTs, but the subcategory may be set to RESPONSE to give the receiver a hint that this message is a response to a prior request. An INIT message always goes to a Place User just after creation but before invocation. Finally, EXIT_SESSION is important for ServiceManagers which, on receiving, terminate the session of a service object with a client.
The option field is currently used to mark the message as to not being delivered to the sender itself, even though the sender could match the receiver mask. Future extensions may add other options here.
| Field Summary | |
static short |
APPLICATION
Message category declaring an agent or user adapater as origin. |
static short |
DELBY_ANY_PLACEUSER
Delete information on general deletability. |
static short |
DELBY_NOONE
Delete information for non-deletability. |
static short |
DELBY_RECEIVER
Delete information on receiver deletability. |
static short |
DELBY_SENDER
Delete information on sender deletability. |
static java.lang.String |
ERR_AGENT_NOT_ACK
Specification of the category PLACE, sent on reject of an agent. |
static java.lang.String |
ERR_BAD_SERVICE_PARAMS
Specification of the category SERVICE, sent on invalid parameters. |
static java.lang.String |
ERR_INVOKE
Specification of the category PLACE, sent on execution error. |
static java.lang.String |
ERR_NO_CONNECT
Specification of the category PLACE, sent on a failed connection attempt. |
static java.lang.String |
ERR_NO_PNS
Specification of the category PLACE, sent on failing PlaceNameService. |
static java.lang.String |
ERR_NO_SERVICE_PARAMS
Specification of the category SERVICE, sent on missing parameters. |
static java.lang.String |
ERR_PARAM_MISMATCH
Specification of the category SERVICE, sent on invalid request parameters. |
static java.lang.String |
ERR_UNAUTHORIZED_ACCESS
Specification of the categories PLACE or SERVICE, sent on unauthorized access. |
static java.lang.String |
ERR_UNKNOWN_HOST
Specification of the category PLACE, sent on unknown target host. |
static java.lang.String |
ERR_UNKNOWN_PLACE
Specification of the category PLACE, sent on unknown place name. |
static java.lang.String |
ERR_UNKNOWN_PROTOCOL
Specification of the category PLACE, sent on unknown migration protocol. |
static short |
ERROR
Subcategory which announces an application-dependent error condition. |
static long |
ERROR_TTL
Expiration time for error messages. |
static short |
EXIT_SESSION
Subcategory which is used for terminating a session between two Place Users. |
static short |
INFO
Subcategory which declares this message to be an informational message. |
static java.lang.String |
INFO_KILLED_PU_LIST
Specification of the category PLACE, sent on killed Place Users. |
static java.lang.String |
INFO_PLACE_SHUTDOWN
Specification of the category PLACE on place shutdown. |
static java.lang.String |
INFO_RELAYED_PLACE_ACTIVE
Specification of the category PLACE, sent on temporary place restart. |
static short |
INIT
Subcategory which declares this message to be an initialization message. |
static short |
MANAGER_STARTUP
Subcategory which refers to the ServiceManager startup. |
static short |
MESSAGE
Message category which declares further messages to be included in this message. |
static int |
OPT_NONE
Option value for no option set. |
static int |
OPT_NOTME
Option value for no self addressing. |
static short |
PLACE
Message category declaring the place as origin. |
static short |
REQUEST
Subcategory which declares this message to be a request. |
static short |
RESPONSE
Subcategory which declares this message to be a response. |
static short |
SECURITY
Message category declaring the security subsystem as origin. |
static short |
SERVICE
Message category declaring a service as origin. |
static long |
SERVICE_REQUEST_TTL
Expiration time for service requests. |
static long |
SERVICE_STARTUP_TTL
Expiration time for service manager startup messages. |
static short |
TRADING
Message category declaring the mediation subsystem as origin. |
static short |
UNSPECIFIED
Subcategory which does not provide any further specification. |
| Constructor Summary | |
AMETASMessage(AMETASPlaceUserID idReceiver,
AMETASMessageID midInReplyTo,
long nTTL,
java.lang.Object[] aBody)
Creates a new message, initializing it with the provided values. |
|
AMETASMessage(AMETASPlaceUserID idReceiver,
AMETASMessageID midInReplyTo,
java.lang.Object[] aBody)
Creates a new message, initializing it with the provided values. |
|
AMETASMessage(AMETASPlaceUserIDMask idmReceiver,
AMETASMessageID midInReplyTo,
java.lang.Object[] aBody)
Creates a new message, initializing it with the provided values. |
|
AMETASMessage(AMETASPlaceUserIDMask idm,
AMETASMessageID midInReplyTo,
short nDelBy,
long nTTL,
int nOptions,
java.lang.Object[] aBody)
Creates a new message, initializing it with the provided values. |
|
AMETASMessage(AMETASPlaceUserID idReceiver,
java.lang.Object[] aBody)
Creates a new message, initializing it with the provided values. |
|
| Method Summary | |
static java.lang.String |
categoryToString(short nCategory)
Translates the category into a readable String. |
java.lang.Object |
clone()
Creates a clone of this message. |
static java.lang.String |
deletableToString(short nDeletable)
Translates the deletable information into a readable String. |
java.lang.Object[] |
getBody()
Returns the body Object array. |
java.lang.Object |
getBodyObj(int nIndex)
Returns the object at a given position in the message body. |
int |
getBodySize()
Delivers the number of objects in the payload array. |
java.util.Vector |
getBodyVector()
Returns the body as a vector. |
short |
getCategory()
Returns the category of this message. |
short |
getDeletable()
Returns the deletability information. |
java.lang.String |
getDeliveryPlace()
Returns the place name where this message has been retrieved. |
AMETASMessageID |
getID()
Returns the ID of this message. |
java.lang.Object |
getNextBodyObj(boolean bReset)
Delivers the next element of the body Object array. |
int |
getOptions()
Returns the options. |
AMETASPrivilegeList |
getPrivileges()
Returns the privileges of the sender at the moment of submission. |
int |
getReceiverContextID()
Returns the receiver context ID. |
AMETASPlaceUserIDMask |
getReceiverMask()
Returns the receiver mask. |
AMETASMessageID |
getRepliedMsg()
Returns the ID of the message which is replied by this message. |
int |
getSenderContextID()
Returns the sender context ID. |
AMETASPlaceUserID |
getSenderID()
Returns the ID of the message sender. |
java.lang.String |
getSenderPlace()
Deprecated. The concept of remote messages should be replaced by a pure agent-based solution. |
java.lang.String |
getSpecification()
Delivers the specification of this message. |
short |
getSubcategory()
Returns the subcategory of this message. |
long |
getTimeStamp()
Returns the timestamp of this message. |
long |
getTTL()
Returns the Time-To-Live of this message. |
boolean |
includesOption(int nOption)
Checks whether a given option has been set. |
boolean |
isRemote()
Deprecated. The concept of remote messages should be replaced by a pure agent-based solution. |
static java.lang.String |
optionsToString(int nOptions)
Translates the options into a readable String. |
boolean |
senderHasPrivilege(java.lang.String sPrivilegeName)
Checks whether the given privilege is contained in the set of privileges of the sender. |
void |
setBody(java.lang.Object[] aBody)
Sets the message payload. |
void |
setCategory(short nCategory)
Sets the message category. |
void |
setDeletable(short nDelBy)
Defines who may delete this message. |
void |
setDeliveryPlace(java.lang.String sPlaceName)
Sets the delivery place. |
void |
setInReplyTo(AMETASMessageID midInReplyTo)
Defines which message this message is related to. |
void |
setOptions(int nOptions)
Declares the options. |
void |
setPrivileges(AMETASPrivilegeList prl)
Defines the list of privileges. |
void |
setReceiver(AMETASPlaceUserID idReceiver)
Sets the receiver. |
void |
setReceiverContextID(int nContextID)
Defines the receiver context. |
void |
setReceiverMask(AMETASPlaceUserIDMask idmReceiver)
Sets the receiver mask. |
void |
setSenderContextID(int nContextID)
Defines the sender context. |
void |
setSenderID(AMETASPlaceUserID id)
Sets the sender ID. |
void |
setSenderPlace(java.lang.String sSenderPlace)
Deprecated. The concept of remote messaging should be replaced by a pure agent-based solution. |
void |
setSubcategory(short nSubcategory)
Sets the subcategory of this message. |
void |
setTTL(long nTTL)
Sets the Time-To-Live of this message. |
static java.lang.String |
subcatToString(short nSubcategory)
Translates the subcategory into a readable String. |
java.lang.String |
toString()
Returns a String representation of this message. |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final short PLACE
public static final short SERVICE
public static final short APPLICATION
public static final short SECURITY
public static final short TRADING
public static final short MESSAGE
public static final short UNSPECIFIED
public static final short MANAGER_STARTUP
public static final short REQUEST
public static final short RESPONSE
public static final short INIT
requestPUStartup and spawnAgent.
public static final short EXIT_SESSION
public static final short ERROR
public static final short INFO
public static final java.lang.String ERR_PARAM_MISMATCH
public static final java.lang.String ERR_NO_SERVICE_PARAMS
public static final java.lang.String ERR_BAD_SERVICE_PARAMS
public static final java.lang.String ERR_AGENT_NOT_ACK
public static final java.lang.String ERR_NO_CONNECT
public static final java.lang.String ERR_UNKNOWN_HOST
public static final java.lang.String ERR_UNKNOWN_PLACE
public static final java.lang.String ERR_UNKNOWN_PROTOCOL
public static final java.lang.String ERR_UNAUTHORIZED_ACCESS
public static final java.lang.String ERR_INVOKE
public static final java.lang.String ERR_NO_PNS
public static final java.lang.String INFO_KILLED_PU_LIST
public static final java.lang.String INFO_PLACE_SHUTDOWN
public static final java.lang.String INFO_RELAYED_PLACE_ACTIVE
public static final short DELBY_NOONE
public static final short DELBY_SENDER
public static final short DELBY_RECEIVER
public static final short DELBY_ANY_PLACEUSER
public static final long ERROR_TTL
public static final long SERVICE_REQUEST_TTL
public static final long SERVICE_STARTUP_TTL
public static final int OPT_NONE
public static final int OPT_NOTME
| Constructor Detail |
public AMETASMessage(AMETASPlaceUserID idReceiver,
java.lang.Object[] aBody)
idReceiver - ID of the receiver.aBody - Payload of the message. If null, an empty Object array is filled in.
public AMETASMessage(AMETASPlaceUserID idReceiver,
AMETASMessageID midInReplyTo,
java.lang.Object[] aBody)
idReceiver - ID of the receiver.midInReplyTo - Message ID of the message which is replied by this message.aBody - Payload of the message. If null, an empty Object array is filled in.
public AMETASMessage(AMETASPlaceUserIDMask idmReceiver,
AMETASMessageID midInReplyTo,
java.lang.Object[] aBody)
idmReceiver - ID mask of the receivers.midInReplyTo - Message ID of the message which is replied by this message.aBody - Payload of the message. If null, an empty Object array is filled in.
public AMETASMessage(AMETASPlaceUserID idReceiver,
AMETASMessageID midInReplyTo,
long nTTL,
java.lang.Object[] aBody)
midInReplyTo - Message ID of the message which is replied by this message.nTTL - Timeout in milliseconds after which the message is removed from the mailbox.aBody - Payload of the message. If null, an empty Object array is filled in.
public AMETASMessage(AMETASPlaceUserIDMask idm,
AMETASMessageID midInReplyTo,
short nDelBy,
long nTTL,
int nOptions,
java.lang.Object[] aBody)
midInReplyTo - Message ID of the message which is replied by this message.nDelBy - Who may delete this message.nTTL - Timeout in milliseconds after which the message is removed from the mailbox.nOptions - Options.aBody - Payload of the message. If null, an empty Object array is filled in.| Method Detail |
public void setSenderID(AMETASPlaceUserID id)
id - Sender ID.public void setReceiverMask(AMETASPlaceUserIDMask idmReceiver)
idmReceiver - Receiver mask.public void setReceiver(AMETASPlaceUserID idReceiver)
idReceiver - Receiver ID.public void setInReplyTo(AMETASMessageID midInReplyTo)
midInReplyTo - ID of the message which this message replies to.AMETASContextpublic void setCategory(short nCategory)
nCategory - Category.public void setSubcategory(short nSubcategory)
nSubcategory - Subcategory.public void setTTL(long nTTL)
nTTL - Timeout in milliseconds.public void setDeletable(short nDelBy)
nDelBy - Determines who may delete the message: the sender, the receiver, or both. When the
TTL time expires, the message is removed from the mailbox in any case.public void setOptions(int nOptions)
nOptions - Optionen.public void setSenderPlace(java.lang.String sSenderPlace)
sSenderPlace - Remote place name.public void setPrivileges(AMETASPrivilegeList prl)
prl - List of privileges of the sender.public void setBody(java.lang.Object[] aBody)
aBody - Message body.public void setSenderContextID(int nContextID)
nContextID - Context ID.AMETASContextpublic void setReceiverContextID(int nContextID)
nContextID - Context ID.AMETASContextpublic void setDeliveryPlace(java.lang.String sPlaceName)
sPlaceName - Place name.public int getBodySize()
public java.lang.Object getBodyObj(int nIndex)
throws java.lang.ArrayIndexOutOfBoundsException
nIndex - Array index of the object.
java.lang.ArrayIndexOutOfBoundsException - when the index does not point into the body Object array.public java.lang.Object getNextBodyObj(boolean bReset)
bReset to true
will reset the array cursor to the first element. Using this method, the body of the
message may conveniently be read by successive calls.
bReset - If true, the array cursor is reset to 0 before reading the array element.
public java.lang.String getSpecification()
public AMETASPlaceUserID getSenderID()
public AMETASPlaceUserIDMask getReceiverMask()
public AMETASMessageID getRepliedMsg()
AMETASContextpublic short getDeletable()
public long getTTL()
public short getCategory()
public short getSubcategory()
public int getOptions()
public java.util.Vector getBodyVector()
public java.lang.Object[] getBody()
public long getTimeStamp()
public AMETASMessageID getID()
public boolean isRemote()
public java.lang.String getSenderPlace()
public AMETASPrivilegeList getPrivileges()
public boolean includesOption(int nOption)
nOption - Option to be tested.
public int getSenderContextID()
AMETASContextpublic int getReceiverContextID()
AMETASContextpublic java.lang.String getDeliveryPlace()
public boolean senderHasPrivilege(java.lang.String sPrivilegeName)
sPrivilegeName - Name of a privilege, like "NETACC".
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
java.lang.CloneNotSupportedException - if the message contains nonserializable components.public static java.lang.String categoryToString(short nCategory)
nCategory - Category as numerical constant.
public static java.lang.String subcatToString(short nSubcategory)
nSubcategory - Subcategory as a numerical constant.
public static java.lang.String deletableToString(short nDeletable)
nDeletable - Deletability as a numerical constant.
public static java.lang.String optionsToString(int nOptions)
public java.lang.String toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||