jegg.impl
Class PortImpl

java.lang.Object
  extended byjegg.impl.PortImpl
All Implemented Interfaces:
Port

public final class PortImpl
extends java.lang.Object
implements Port

Used to deliver a message to an egg. Each Egg instance has just one message port instance that other eggs can use to send it messages. Any message that is written to an egg port will be delivered, asynchronously, to the egg that the port belongs to.

An egg can publish its port in the JEgg port registry so that other eggs will be able to send it messages (see Egg.publishPort()).


Method Summary
 void connect(Port port)
          Add a port to the list of ports that broadcast messages will be sent to.
 void disconnect(Port port)
          Remove a connected port.
 java.lang.Object getId()
          Return the ID of the egg that owns this port.
 java.lang.Class[] getInterface()
          Return the set of message types understood by the egg associated with this message port.
 void send(Message m)
          Deliver a message to the egg that owns this port.
 void send(java.lang.Object o)
          Deliver an object as a message to the egg that owns this port.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInterface

public java.lang.Class[] getInterface()
Description copied from interface: Port
Return the set of message types understood by the egg associated with this message port.

Specified by:
getInterface in interface Port
Returns:
non-null and non-empty array of class objects.

getId

public java.lang.Object getId()
Description copied from interface: Port
Return the ID of the egg that owns this port.

Specified by:
getId in interface Port

send

public final void send(java.lang.Object o)
                throws PortException
Deliver an object as a message to the egg that owns this port.

Specified by:
send in interface Port
Parameters:
o - the object to send to this port's owner. The object will be delivered wrapped in a Message instance.
Throws:
PortException

send

public final void send(Message m)
                throws PortException
Deliver a message to the egg that owns this port.

Specified by:
send in interface Port
Throws:
PortException

connect

public final void connect(Port port)
Add a port to the list of ports that broadcast messages will be sent to.

Parameters:
port - xx

disconnect

public final void disconnect(Port port)
Remove a connected port.



Copyright © 2004 . All Rights Reserved.