Prism.framework
Class Architecture

java.lang.Object
  |
  +--Prism.framework.Brick
        |
        +--Prism.framework.Architecture
All Implemented Interfaces:
IArchitecture, IComponent, IConnector, IPeerConnector, ScaffoldConstants
Direct Known Subclasses:
ArchitectureAdapter

public abstract class Architecture
extends Brick
implements IArchitecture, IComponent, IConnector, IPeerConnector

Base class for the Prism Architecture. This class is a component by itself that can be a part of another Prism architecture. It is responsible for keeping state of the components and connectors that are currently part of this Prism architecture.

Version:
0.1
Author:
Nikunj Mehta, Marija Mikic-Rakic

Fields inherited from class Prism.framework.Brick
bottomId, myId, name, scaffold, sideId, topId
 
Fields inherited from interface Prism.framework.ScaffoldConstants
DISPATCH, MONITOR, SCHEDULER
 
Constructor Summary
Architecture()
          An empty constructor that gives an architecture the name "Prism Architecture".
Architecture(java.lang.String str)
          This constructor sets the name of this architecture to str.
 
Method Summary
 void add(Brick b)
          This method will add a component instance comp to the architecture enabling comp to send/recieve messages from this architecture.
 Brick getBrickByInstanceName(java.lang.String instName)
           
 DynamicArray getComponents()
          This method returns the array of components.
 Brick getReference(java.lang.String componentName)
          This method returns a reference of a component with a given name (if it exists)
 void handle(Message r)
          This method will define the action to be taken by this architecture when it recieves a message from another component/connector attached to it.
 void peerUnweld(Brick b1, Brick b2)
          This method unwelds two bricks in peer-to-peer configuration Since there is no notion of top or bottom in peer interactions, the order of the parameters is irrelevant
 void peerWeld(Brick b1, Brick b2)
          This method welds two bricks in peer-to-peer configuration Since there is no notion of top or bottom in peer interactions, the order of the parameters is irrelevant
 void remove(Brick b)
          This method removes b from the architecture and thereby preventing b from receiving anymore messages from this architecture.
 void start()
          This method must be called to start the architecture and the threads that run in the architecture.
 java.lang.String toString()
          This method outputs the contents of the architecture object to a string
 void unweld(Brick b1, Brick b2)
          This method unwelds two bricks in top-to-bottom configuration
 void weld(Brick b1, Brick b2)
          This method joins the top of comp to the bottom of conn.
 
Methods inherited from class Prism.framework.Brick
add, fireEvent, getBottomId, getSideId, getTopId, setBottomId, setName, setNameAfterTheFact, setScaffold, setSideId, setTopId
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface Prism.framework.IComponent
send, send, send, setBottom, setSide, setTop
 
Methods inherited from interface Prism.framework.IConnector
addToBottom, addToTop, removeFromBottom, removeFromTop
 
Methods inherited from interface Prism.framework.IPeerConnector
addToSide, removeFromSide
 

Constructor Detail

Architecture

public Architecture()
An empty constructor that gives an architecture the name "Prism Architecture".

Architecture

public Architecture(java.lang.String str)
This constructor sets the name of this architecture to str.
Parameters:
str - The name of this architecture. It cannot be a null value
Method Detail

getComponents

public DynamicArray getComponents()
This method returns the array of components.
Returns:
DynamicArray of components

getBrickByInstanceName

public Brick getBrickByInstanceName(java.lang.String instName)

start

public void start()
This method must be called to start the architecture and the threads that run in the architecture. This method will in turn call the start() method of each component and connector in the architecture. It will then create a pre-defined number of threads and start each one of them. Finally it synchronizes all the threads on a semaphore and continues execution.
Overrides:
start in class Brick

handle

public void handle(Message r)
This method will define the action to be taken by this architecture when it recieves a message from another component/connector attached to it.
Overrides:
handle in class Brick
Following copied from class: Prism.framework.Brick
Parameters:
m - Message object to be handled

add

public void add(Brick b)
This method will add a component instance comp to the architecture enabling comp to send/recieve messages from this architecture.
Specified by:
add in interface IArchitecture
Parameters:
comp - A brick object to be added

weld

public void weld(Brick b1,
                 Brick b2)
This method joins the top of comp to the bottom of conn.
Specified by:
weld in interface IArchitecture
Parameters:
b2 - A brick object to be at the top.
b1 - A brick object to be at the bottom.

unweld

public void unweld(Brick b1,
                   Brick b2)
This method unwelds two bricks in top-to-bottom configuration
Parameters:
b2 - A brick object to be at the top.
b1 - A brick object to be at the bottom.

peerWeld

public void peerWeld(Brick b1,
                     Brick b2)
This method welds two bricks in peer-to-peer configuration Since there is no notion of top or bottom in peer interactions, the order of the parameters is irrelevant
Parameters:
b2 - A brick object 2. (it can only be a peer connector or a component)
b1 - A brick object 1. (it can only be a peer connector or a component)

peerUnweld

public void peerUnweld(Brick b1,
                       Brick b2)
This method unwelds two bricks in peer-to-peer configuration Since there is no notion of top or bottom in peer interactions, the order of the parameters is irrelevant
Parameters:
b2 - A brick object 2. (it can only be a peer connector or a component)
b1 - A brick object 1. (it can only be a peer connector or a component)

remove

public void remove(Brick b)
This method removes b from the architecture and thereby preventing b from receiving anymore messages from this architecture. If b is not found to be a part of this architecture then the method does nothing and returns.
Specified by:
remove in interface IArchitecture
Parameters:
comp - A brick object that cannot be null.

toString

public java.lang.String toString()
This method outputs the contents of the architecture object to a string
Overrides:
toString in class java.lang.Object

getReference

public Brick getReference(java.lang.String componentName)
This method returns a reference of a component with a given name (if it exists)
Parameters:
componentName - Name of the component