cz.zcu.fav.kiv.jsim.ipc
Class JSimMessage

java.lang.Object
  extended by cz.zcu.fav.kiv.jsim.ipc.JSimMessage
Direct Known Subclasses:
JSimAssymetricMessage, JSimIndirectMessage, JSimSymmetricMessage

public abstract class JSimMessage
extends java.lang.Object

A message is a piece of data sent from a process to another one. A message can have its sending and receiving process specified or not. Depending on the sender and receiver specification, the message can be sent directly between two processes or indirectly via a message box. So the following types of messages can be distinguished:

  1. Symmetric messages: They have both the sender and the receiver specified, they can therefore be sent directly from a process to another or indirectly via a message box.
  2. Assymetric messages: They have only the sender or the receiver specified. If the receiver is specified, the message can be sent directly to a process. If the sender is specified, the receiver can use a receive function that filters messages by their sender. They can also be sent indirectly.
  3. Indirect messages: They have neither the sender nor the receiver specified. They can be sent indirectly only, i.e. via a message box.
This class is abstract, you are not allowed to create instances of it. Look for non-abstract subclasses that can be instantiated.

Since:
J-Sim version 0.3.0
Version:
J-Sim version 0.6.0
Author:
Jarda KAČER

Field Summary
static int ANY_MESSAGE_TYPE
          This constant specifies that no message type filter should be used upon message reception.
protected  java.lang.Object data
          The data sent inside the message.
static int DEFAULT_JSIM_MESSAGE_TYPE
          The default message type.
protected  int messageType
          Type of the message.
private  JSimProcess realSender
          The process that actually sent the message.
protected  JSimProcess receiver
          The process to whom this message is to be sent.
protected  JSimProcess sender
          The sending process.
static JSimProcess UNKNOWN_RECEIVER
          This constant specifies an unknown receiver.
static JSimProcess UNKNOWN_SENDER
          This constant specifies an unknown sender.
 
Constructor Summary
JSimMessage(JSimProcess sender, JSimProcess receiver, java.lang.Object data)
          Creates a new message with the specified sender, receiver, and user data.
JSimMessage(JSimProcess sender, JSimProcess receiver, java.lang.Object data, int messageType)
          Creates a new message with the specified sender, receiver, user data, and message type.
 
Method Summary
 java.lang.Object getData()
          Returns the user data that this message carries.
 int getMessageType()
          Returns the type of the message.
 JSimProcess getRealSender()
          Returns the process that actually sent the message.
 JSimProcess getReceiver()
          Returns the receiver of the message.
 JSimProcess getSender()
          Returns the sender of the message.
 void setRealSender(JSimProcess realSender)
          Sets the real sender when the message is being sent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN_SENDER

public static final JSimProcess UNKNOWN_SENDER
This constant specifies an unknown sender.


UNKNOWN_RECEIVER

public static final JSimProcess UNKNOWN_RECEIVER
This constant specifies an unknown receiver.


ANY_MESSAGE_TYPE

public static final int ANY_MESSAGE_TYPE
This constant specifies that no message type filter should be used upon message reception.

See Also:
Constant Field Values

DEFAULT_JSIM_MESSAGE_TYPE

public static final int DEFAULT_JSIM_MESSAGE_TYPE
The default message type. If the user does not specifies his/her own message type, this value will be used.

See Also:
Constant Field Values

sender

protected JSimProcess sender
The sending process. Can be set to UNKNOWN_SENDER if the user does not want to publish it.


receiver

protected JSimProcess receiver
The process to whom this message is to be sent. Can be set to UNKNOWN_RECEIVER if any process can receive the message via a message box.


data

protected java.lang.Object data
The data sent inside the message.


messageType

protected int messageType
Type of the message. The default value is DEFAULT_JSIM_MESSAGE_TYPE. Message types can be useful if you want to filter incoming messages by a criterion.


realSender

private JSimProcess realSender
The process that actually sent the message. Since the sender can be unknown, this field is necessary to determine the sender that can get suspended in case of a blocking send operation.

Constructor Detail

JSimMessage

public JSimMessage(JSimProcess sender,
                   JSimProcess receiver,
                   java.lang.Object data)
Creates a new message with the specified sender, receiver, and user data. The default value of message type will be used.

Parameters:
sender - The sending process. Need not be specified.
receiver - The receiver. Need not be specified.
data - User data that the message will carry.

JSimMessage

public JSimMessage(JSimProcess sender,
                   JSimProcess receiver,
                   java.lang.Object data,
                   int messageType)
            throws JSimInvalidParametersException
Creates a new message with the specified sender, receiver, user data, and message type.

Parameters:
sender - The sending process. Need not be specified.
receiver - The receiver. Need not be specified.
data - User data that the message will carry.
messageType - The type of the message. Must be non-negative.
Throws:
JSimInvalidParametersException - This exception is thrown out if the message type is negative.
Method Detail

getData

public java.lang.Object getData()
Returns the user data that this message carries.

Returns:
The user data that this message carries.

getMessageType

public int getMessageType()
Returns the type of the message.

Returns:
The type of the message.

getRealSender

public JSimProcess getRealSender()
Returns the process that actually sent the message. The real sender is always known, even if the sender was not specified upon message creation. However, the message must be sent first to know the real sender. If it has not been sent yet, this method will return null.

Returns:
The process that actually sent the message or null.

setRealSender

public void setRealSender(JSimProcess realSender)
Sets the real sender when the message is being sent. This method is invoked by the sending process.

Parameters:
realSender - The process that is just now sending the message.

getSender

public JSimProcess getSender()
Returns the sender of the message. The sender need not always be an existing process.

Returns:
The sender of the message.

getReceiver

public JSimProcess getReceiver()
Returns the receiver of the message. The receiver need not always be an existing process.

Returns:
The receiver of the message.


Copyright © 2000-2006 University of West Bohemia. Licensed under the Academic Free License v. 2.1. Build date 20060812.