Prism.framework
Class Component

java.lang.Object
  |
  +--Prism.framework.Brick
        |
        +--Prism.framework.Component
All Implemented Interfaces:
ArchitectureEventConstants, IComponent, ScaffoldConstants
Direct Known Subclasses:
BottomComponent, ComponentThread, Forwarder, LeftComponent, RightComponent, TopComponent

public abstract class Component
extends Brick
implements IComponent, ArchitectureEventConstants

This class defines the basic Prism component and the send methods that allow any class extending this one to interact with the architecture. The usual practice is to create a component in your own architecture by extending this class and implementing the handle methods for a request/notification.

Version:
0.1
Author:
Nikunj Mehta, Marija 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
Component(java.lang.String name)
          This constructor just calls on the Brick(String) constructor.
 
Method Summary
 java.lang.Object getBottom()
          Get the connector at the bottom
 java.lang.Object getSide()
          Get the connector at the side
 java.lang.Object getTop()
          Get the connector at the top
 void handle(Message m)
          Call the appropriate handle method depending on the type of the message
 void handle(Notification n)
          Handling of Notifications.
 void handle(Peer p)
          Handling of Peer messages.
 void handle(Request r)
          Handling of requests.
 boolean hasBottom()
          Find out if the brick has connected bricks at its bottom
 boolean hasSide()
          Find out if the brick has connected bricks at its side
 boolean hasTop()
          Find out if the brick has connected bricks at its top
 void send(Notification n)
          This method sends the Notification n down the C2 architecture that this component is a part of.
 void send(Peer r)
          This method sends the peer message through the Prism architecture that this component is a part of.
 void send(Request r)
          This method sends the request r up the Prism architecture that this component is a part of.
 void setBottom(IConnector conn)
          Set the connector at the bottom
 void setBottomFree()
          Set the connector at the bottom to null
 void setSide(IPeerConnector conn)
          Set the connector at the side
 void setSideFree()
          Set the connector at the side to null
 void setTop(IConnector conn)
          Set the connector at the top
 void setTopFree()
          Set the connector at the top to null
 java.lang.String toString()
          Generate a string version of the component's internal state
 
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

Component

public Component(java.lang.String name)
This constructor just calls on the Brick(String) constructor.
Parameters:
name - String: the name of this component object.
Method Detail

send

public void send(Request r)
This method sends the request r up the Prism architecture that this component is a part of.
Specified by:
send in interface IComponent
Parameters:
r - a Request to be sent to the connector above.

send

public void send(Peer r)
This method sends the peer message through the Prism architecture that this component is a part of.
Specified by:
send in interface IComponent
Parameters:
r - a Peer to be sent to the connector on the side.

send

public void send(Notification n)
This method sends the Notification n down the C2 architecture that this component is a part of.
Specified by:
send in interface IComponent
Parameters:
n - a Notification object to be sent to the connector below.

handle

public void handle(Request r)
Handling of requests. This is application specific code and should be implemented by subclasses of this class
Parameters:
r - Request to be handled

handle

public void handle(Notification n)
Handling of Notifications. This is application specific code and should be implemented by subclasses of this class
Parameters:
n - Notification to be handled

handle

public void handle(Peer p)
Handling of Peer messages. This is application specific code and should be implemented by subclasses of this class
Parameters:
p - Peer message to be handled

handle

public void handle(Message m)
Call the appropriate handle method depending on the type of the message
Overrides:
handle in class Brick
Parameters:
m - Message to be handled

hasTop

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

hasBottom

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

hasSide

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

getTop

public java.lang.Object getTop()
Get the connector at the top
Returns:
Object the top connector

getBottom

public java.lang.Object getBottom()
Get the connector at the bottom
Returns:
Object the bottom connector

getSide

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

setTop

public void setTop(IConnector conn)
Set the connector at the top
Specified by:
setTop in interface IComponent
Parameters:
conn - IConnector the top connector

setBottom

public void setBottom(IConnector conn)
Set the connector at the bottom
Specified by:
setBottom in interface IComponent
Parameters:
conn - IConnector the bottom connector

setSide

public void setSide(IPeerConnector conn)
Set the connector at the side
Specified by:
setSide in interface IComponent
Parameters:
conn - IConnector the side connector

setBottomFree

public void setBottomFree()
Set the connector at the bottom to null

setTopFree

public void setTopFree()
Set the connector at the top to null

setSideFree

public void setSideFree()
Set the connector at the side to null

toString

public java.lang.String toString()
Generate a string version of the component's internal state
Overrides:
toString in class java.lang.Object
Returns:
String internal state of the component represented as a string