Prism.framework
Class PeerConnector

java.lang.Object
  |
  +--Prism.framework.Brick
        |
        +--Prism.framework.PeerConnector
All Implemented Interfaces:
ArchitectureEventConstants, IPeerConnector, ScaffoldConstants
Direct Known Subclasses:
PeerConnectorThread

public class PeerConnector
extends Brick
implements IPeerConnector, ArchitectureEventConstants

A connector provides interaction and mediation services to attached components. The connector is connected to a set of components. The semantics of this connector is to dispatch all the messages it receives to all other components to which it is attached. Note that this connector only dispatches peer messages and cannot be used for requests/notifications.

Version:
0.1
Author:
Marija Mikic-Rakic

Fields inherited from class Prism.framework.Brick
bottomId, myId, name, scaffold, sideId, topId
 
Fields inherited from interface Prism.framework.ArchitectureEventConstants
NOTIF_BEING_HDLD, NOTIF_HDLD, NOTIF_RECD, NOTIF_SENT, PEER_BEING_HDLD, PEER_HDLD, PEER_RECD, PEER_SENT, REQ_BEING_HDLD, REQ_HDLD, REQ_RECD, REQ_SENT
 
Fields inherited from interface Prism.framework.ScaffoldConstants
DISPATCH, MONITOR, SCHEDULER
 
Constructor Summary
PeerConnector(java.lang.String str)
          Constructor for connector that defines a simple connector with the given name
 
Method Summary
 void addToSide(Brick t)
          Connect the component to the lPeer of this connector
 java.lang.Object getSide()
          Get the connector at the side
 void handle(Message m)
          Both connectors and components need to handle messages.
 void handle(Peer p)
          Direct the peer to all the bricks attached to the connector other than the source brick
 boolean hasSide()
          Find out if the brick has connected bricks at its side
 void removeFromSide(Brick t)
          Remove the component from the side of this connector
 java.lang.String toString()
          Create the stringified object with recursive description
 java.lang.String toString(boolean recurse)
          Create the stringified object
 
Methods inherited from class Prism.framework.Brick
add, fireEvent, getBottomId, getSideId, getTopId, setBottomId, setName, setNameAfterTheFact, setScaffold, setSideId, setTopId, start
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PeerConnector

public PeerConnector(java.lang.String str)
Constructor for connector that defines a simple connector with the given name
Parameters:
str - String name of the connector
Method Detail

handle

public void handle(Peer p)
Direct the peer to all the bricks attached to the connector other than the source brick
Parameters:
p - Peer to be sent to attached bricks

addToSide

public void addToSide(Brick t)
Connect the component to the lPeer of this connector
Specified by:
addToSide in interface IPeerConnector
Parameters:
t - Brick to be added to the lPeer

removeFromSide

public void removeFromSide(Brick t)
Remove the component from the side of this connector
Specified by:
removeFromSide in interface IPeerConnector
Parameters:
t - Brick to be added to the lPeer

hasSide

public boolean hasSide()
Find out if the brick has connected bricks at its side
Returns:
boolean whether there are connectors at the side

getSide

public java.lang.Object getSide()
Get the connector at the side
Returns:
Object the side connector

toString

public java.lang.String toString(boolean recurse)
Create the stringified object
Parameters:
recurse - boolean whether to recurse through the stringified connector description

toString

public java.lang.String toString()
Create the stringified object with recursive description
Overrides:
toString in class java.lang.Object

handle

public void handle(Message m)
Description copied from class: Brick
Both connectors and components need to handle messages. handle is used to despatch messages in a loosely coupled manner.
Overrides:
handle in class Brick
Following copied from class: Prism.framework.Brick
Parameters:
m - Message object to be handled