public abstract class Port
extends java.lang.Object
Every port may have several message filters attached to it. They may be used
to filter messages, or to get information about messages, e.g. for counting
or statistics.
A port may also have one input message handler and one output message
handler. Message handlers are the interface between ports and entities.
Whenever a message has to be sent, the corresponding message handler is
called by the port.
The following protocol is used to exchange messages: If an entity has
prepared a new message to send, it calls the MessageIndication()-method of
its output port. The message then travels along the connected ports to the
destination input port. Finally, the HandleMsgIndication()-method of the
input message handler is responsible of handling the message. If it can
handle the message, it immediately calls the GetMessage()-method of the input
port, which passes the call to the output handler of the source port. The
HandleGetMessage()-method of this port must then supply the message (active
sender).
If GetMessage() is not called, the sender is blocked. A receiver port may
call IsMessageAvailable() which is passed from the input port to the
corresponding output port. There, the HandleIsMessageAvailable()-method of
the output message handler is called (active receiver). GetMessage() may only
be called within HandleMsgIndication() or after a successful
IsMessageAvaialbale()-call!
The port registers itself automatically at the port manager.
The difference between input and output ports is implemented by the introduction of two special port classes InputPort and OutputPort.
Modifier and Type | Field and Description |
---|---|
protected static java.util.logging.Logger |
LOG |
protected Entity |
owner |
protected java.lang.String |
portName |
Constructor and Description |
---|
Port(Entity owner,
java.lang.String portName) |
Modifier and Type | Method and Description |
---|---|
void |
addPortMonitor(PortMonitor monitor) |
abstract Port |
getConnectedPort()
Returns the connected port.
|
java.lang.String |
getDelimiter() |
java.lang.String |
getLocalName() |
Message |
getMessage() |
java.lang.String |
getName() |
Entity |
getOwner() |
protected abstract Message |
handleGetMessage() |
protected abstract boolean |
handleIsMessageAvailable() |
protected abstract void |
handleMessageIndication(Message msg) |
boolean |
isConnected()
Returns whether this port is connected to another port.
|
boolean |
isMessageAvailable() |
void |
messageIndication(Message message) |
void |
removePortMonitor(PortMonitor monitor) |
protected static final java.util.logging.Logger LOG
protected final java.lang.String portName
protected final Entity owner
public Port(Entity owner, java.lang.String portName)
public boolean isConnected()
public abstract Port getConnectedPort()
public void messageIndication(Message message)
public boolean isMessageAvailable()
public Message getMessage()
protected abstract Message handleGetMessage()
protected abstract boolean handleIsMessageAvailable()
protected abstract void handleMessageIndication(Message msg)
public void addPortMonitor(PortMonitor monitor)
public void removePortMonitor(PortMonitor monitor)
public Entity getOwner()
public java.lang.String getDelimiter()
public java.lang.String getLocalName()
public final java.lang.String getName()