Prism.conn.distribution.bottom
Class BottomBorderConnector

java.lang.Object
  |
  +--Prism.framework.Brick
        |
        +--Prism.framework.Connector
              |
              +--Prism.conn.distribution.bottom.BottomBorderConnector
All Implemented Interfaces:
ArchitectureEventConstants, Prism.conn.distribution.bottom.BBCConstants, Prism.conn.distribution.bottom.ConnectorConstants, IConnector, ScaffoldConstants

public class BottomBorderConnector
extends Connector
implements Prism.conn.distribution.bottom.ConnectorConstants, Prism.conn.distribution.bottom.BBCConstants

This class is used on JVM platform, for establishing connection(s) using sockets. A BottomBorderConnector receives requests from other processes and dispatches notifications to connected processes. It maintaines a list of connections that are established. The connector listens for possible connections in an endless loop. It is IMPORTANT to note that parameters to messages being sent using this border connector have to be serializable (i.e., they have to implement a Serializable interface)

Version:
0.1
Author:
Marija Mikic-Rakic
See Also:
Connector

Field Summary
static int ACTIVE
           
static int BOTTOM_BROADCAST
          Broadcast notifications to all attached components and connectors
static int BOTTOM_GROUPCAST
          Groupcast notifications and requests to all attached components and connectors that belong to the specified group.
static int BOTTOM_UNICAST
          Unicast notifications to the fully resolved brick object
static int BROADCAST
          Broadcast notifications and requests to all attached components and connectors
 Prism.conn.distribution.bottom.BottomConnection currentConnection
           
static int GROUPCAST
          Groupcast notifications and requests to all attached components and connectors that belong to the specified group.
static int INACTIVE
           
static int TIME_BETWEEN_PINGS
           
static int TOP_BROADCAST
          Broadcast requests to all attached components and connectors
static int TOP_GROUPCAST
          Groupcast requests to all attached components and connectors that belong to the specified group.
static int TOP_UNICAST
          Unicast requests to the fully resolved brick object
static int UNICAST
          Unicast notifications and requests to the fully resolved brick object
static int WAIT_FOR_RECONNECTION
           
 
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
BottomBorderConnector(java.lang.String name, int portNum, java.lang.String lpn)
          constructor
 
Method Summary
 boolean getFlagPing()
           
 void handle(Notification n)
          This method hanles a given notification by dispatching it to all active socket connections.
 void handle(Request r)
          This method is invoked by the Connection object, once a request is received via the network.
 int hasActiveConnections()
          This method returns the index of the first ACTIVE connection in the connection collection
 int hasInactiveConnections()
          This method returns the index of the first INACTIVE connection in the connection collection
 void identifyMyself()
           
 void setFlagPing(boolean value)
           
 void start()
          This method is called by the framework (if the architecture's start method is called) The method binds this connector to the given port and is always ready to accept new connections.
 void stopWorking()
          This method will stop the connector from accepting new connections.
 void updateConnections(Prism.conn.distribution.bottom.BottomConnection newconn)
           
 void writeDisconnInfo()
           
 
Methods inherited from class Prism.framework.Connector
addToBottom, addToTop, getBottom, getTop, handle, hasBottom, hasTop, removeFromBottom, removeFromTop, toString, toString
 
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
 

Field Detail

currentConnection

public Prism.conn.distribution.bottom.BottomConnection currentConnection

BROADCAST

public static final int BROADCAST
Broadcast notifications and requests to all attached components and connectors

UNICAST

public static final int UNICAST
Unicast notifications and requests to the fully resolved brick object

GROUPCAST

public static final int GROUPCAST
Groupcast notifications and requests to all attached components and connectors that belong to the specified group.

TOP_BROADCAST

public static final int TOP_BROADCAST
Broadcast requests to all attached components and connectors

TOP_UNICAST

public static final int TOP_UNICAST
Unicast requests to the fully resolved brick object

TOP_GROUPCAST

public static final int TOP_GROUPCAST
Groupcast requests to all attached components and connectors that belong to the specified group.

BOTTOM_BROADCAST

public static final int BOTTOM_BROADCAST
Broadcast notifications to all attached components and connectors

BOTTOM_UNICAST

public static final int BOTTOM_UNICAST
Unicast notifications to the fully resolved brick object

BOTTOM_GROUPCAST

public static final int BOTTOM_GROUPCAST
Groupcast notifications and requests to all attached components and connectors that belong to the specified group.

ACTIVE

public static final int ACTIVE

WAIT_FOR_RECONNECTION

public static final int WAIT_FOR_RECONNECTION

INACTIVE

public static final int INACTIVE

TIME_BETWEEN_PINGS

public static final int TIME_BETWEEN_PINGS
Constructor Detail

BottomBorderConnector

public BottomBorderConnector(java.lang.String name,
                             int portNum,
                             java.lang.String lpn)
constructor
Parameters:
name - name of this bottom border connector
portNum - the port number this Bottom Border Connector is going to be binded to
Method Detail

start

public void start()
This method is called by the framework (if the architecture's start method is called) The method binds this connector to the given port and is always ready to accept new connections.
Overrides:
start in class Brick

handle

public void handle(Request r)
This method is invoked by the Connection object, once a request is received via the network.
Overrides:
handle in class Connector
Parameters:
r - Request to be handled

handle

public void handle(Notification n)
This method hanles a given notification by dispatching it to all active socket connections.
Overrides:
handle in class Connector
Parameters:
n - Notification to be dispatched

hasActiveConnections

public int hasActiveConnections()
This method returns the index of the first ACTIVE connection in the connection collection
Returns:
Index of first ACTIVE connection or -1 in case there are no active connections

hasInactiveConnections

public int hasInactiveConnections()
This method returns the index of the first INACTIVE connection in the connection collection
Returns:
Index of first INACTIVE connection or -1 in case there are no inactive connections

stopWorking

public void stopWorking()
This method will stop the connector from accepting new connections.

setFlagPing

public void setFlagPing(boolean value)
Parameters:
value -  

getFlagPing

public boolean getFlagPing()

writeDisconnInfo

public void writeDisconnInfo()

updateConnections

public void updateConnections(Prism.conn.distribution.bottom.BottomConnection newconn)

identifyMyself

public void identifyMyself()