disciple.core
Class Controller

java.lang.Object
  |
  +--disciple.core.Controller
All Implemented Interfaces:
CommandListener, ConnectionListener

public class Controller
extends java.lang.Object
implements CommandListener, ConnectionListener

The main task for the Controller is to act as the interface between the application and the middleware. It receives commands from the application and from the remote sites, executes them, and propagates to either remote sites or the application (depending on the source of the command). Possible listeners to the commands from the Controller are Repository, CommandHistory, and archiving and replay modules. Listener list should be implemented as an array for performance reasons.

Copyright (c) 2002 Rutgers, The State University of New Jersey

Since:
Disciple v3.0
Version:
$Revision: 1.2 $

Field Summary
protected  DataDistributor distributor_
           
protected  Repository repository_
           
 
Constructor Summary
Controller()
           
 
Method Summary
 void addCommandListener(CommandListener listener)
          Add a listener for incoming commands from all connections.
 void addConnection(Connection connection)
          Adds a connection (this is delegated to the DataDistributor) and adds the controller as a listener to the connection.
 void addConnectionListener(ConnectionListener listener)
          Add a listener for incoming connections.
 void addService(java.lang.String name, Service service)
          Adds a service to the list of services.
 void commandReceived(Command command)
          Implementation of the CommandListener interface.
 void connectionAdded(Connection connection, org.w3c.dom.Element status)
           
 void connectionChanged(Connection connection, org.w3c.dom.Element status)
           
 void connectionRemoved(Connection connection)
           
 Connection getConnection(java.lang.Object destination)
          Returns a connection by id.
 Connection[] getConnections()
          Returns all connections.
 DataDistributor getDataDistributor()
           
 javax.xml.parsers.DocumentBuilder getDocumentBuilder()
          Returns the DOM document builder instance.
 java.lang.Object getId()
          Gets the ID of this controller.
 Repository getRepository()
          Returns a handle to the repository.
 Service getService(java.lang.String name)
          Returns a handle to a service by name.
 void removeCommandListener(CommandListener listener)
          Removes a command listener.
 void removeConnection(Connection connection)
          Removes a connection and removes the controller as listener to the connection.
 void removeConnectionListener(ConnectionListener listener)
          Removes a Connection listener.
 void removeService(java.lang.String name)
          Removes a service.
 void sendCommand(Command command)
          The entry point for the application to send commands into the Disciple middleware.
 void sendCommand(Command command, Connection connection, int priority)
          The entry point for the application to send commands into the Disciple middleware.
 void setDataDistributor(DataDistributor distributor)
           
 void setDocumentBuilder(javax.xml.parsers.DocumentBuilder documentBuilder)
          Sets the DOM document builder.
 void setId(java.lang.Object id)
          Sets the ID of this controller.
 void setRepository(Repository repository)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

repository_

protected Repository repository_

distributor_

protected DataDistributor distributor_
Constructor Detail

Controller

public Controller()
Rose:
3CF80D89030F
Method Detail

setId

public void setId(java.lang.Object id)
Sets the ID of this controller. This id is stamped on all commands originating from this controller.


getId

public java.lang.Object getId()
Gets the ID of this controller.


sendCommand

public void sendCommand(Command command)
The entry point for the application to send commands into the Disciple middleware. The command is executed by the controller, and is sent to remote peers through the DataDistributor.

Rose:
3CE406690339

sendCommand

public void sendCommand(Command command,
                        Connection connection,
                        int priority)
The entry point for the application to send commands into the Disciple middleware. The command is executed by the controller, and is sent to the remote specified peer through the DataDistributor.

Parameters:
connection -
priority -

addCommandListener

public void addCommandListener(CommandListener listener)
Add a listener for incoming commands from all connections.

Parameters:
listener -
Rose:
3CE40DE00066

removeCommandListener

public void removeCommandListener(CommandListener listener)
Removes a command listener.

Parameters:
listener -
Rose:
3CE40DF30103

addConnectionListener

public void addConnectionListener(ConnectionListener listener)
Add a listener for incoming connections.

Parameters:
listener -

removeConnectionListener

public void removeConnectionListener(ConnectionListener listener)
Removes a Connection listener.

Parameters:
listener -

getRepository

public Repository getRepository()
Returns a handle to the repository.

Returns:
disciple.core.Repository
Rose:
3CF50163027A

setRepository

public void setRepository(Repository repository)
Parameters:
repository -
Since:
Disciple v3.0
Rose:
3D04D61E023F

setDataDistributor

public void setDataDistributor(DataDistributor distributor)
Parameters:
distributor -
Since:
Disciple v3.0
Rose:
3D04D63D0149

getDataDistributor

public DataDistributor getDataDistributor()

getService

public Service getService(java.lang.String name)
Returns a handle to a service by name.

Parameters:
name - the name of the service
Returns:
Service the service if present, else null
Rose:
3CF657AB00A3

addService

public void addService(java.lang.String name,
                       Service service)
Adds a service to the list of services. If the service implements the CommandListener interface, the service will also be added as a command listener.

Parameters:
name - the name of the service
service - the service
Rose:
3CF79E450005

removeService

public void removeService(java.lang.String name)
Removes a service.

Parameters:
name - the name of the service to remove
Rose:
3CF79E62016F

addConnection

public void addConnection(Connection connection)
Adds a connection (this is delegated to the DataDistributor) and adds the controller as a listener to the connection.

Parameters:
connection - the connection to be added
Rose:
3CF549D30186

removeConnection

public void removeConnection(Connection connection)
Removes a connection and removes the controller as listener to the connection.

Parameters:
connection - the connection to be removed
Rose:
3CF54BF90082

getConnection

public Connection getConnection(java.lang.Object destination)
Returns a connection by id.

Returns:
the Connection if found, else null

getConnections

public Connection[] getConnections()
Returns all connections.

Returns:
All connections

getDocumentBuilder

public javax.xml.parsers.DocumentBuilder getDocumentBuilder()
Returns the DOM document builder instance.


setDocumentBuilder

public void setDocumentBuilder(javax.xml.parsers.DocumentBuilder documentBuilder)
Sets the DOM document builder.


commandReceived

public void commandReceived(Command command)
Implementation of the CommandListener interface.

Clones the command, executes the original, notifies the controllers command listeners, and send the cloned command to the DataDistributor.

Specified by:
commandReceived in interface CommandListener
Parameters:
command - the received command.
Since:
Disciple v3.0
Rose:
3D04CFF0038E

connectionChanged

public void connectionChanged(Connection connection,
                              org.w3c.dom.Element status)
Specified by:
connectionChanged in interface ConnectionListener
Parameters:
connection -
status -

connectionAdded

public void connectionAdded(Connection connection,
                            org.w3c.dom.Element status)
Specified by:
connectionAdded in interface ConnectionListener
Parameters:
connection -
status -

connectionRemoved

public void connectionRemoved(Connection connection)
Specified by:
connectionRemoved in interface ConnectionListener
Parameters:
connection -


Copyright (c) 2003 Rutgers, The State University of New Jersey