com.monica.javacom.protocol
Class MJCLoopBackProtocol

java.lang.Object
  |
  +--com.monica.javacom.protocol.MJCLoopBackProtocol
All Implemented Interfaces:
MJCReader, MJCServerManager, java.lang.Runnable

public class MJCLoopBackProtocol
extends java.lang.Object
implements MJCServerManager, MJCReader, java.lang.Runnable

Class for implementing a basic loopback at the server side. This class acts as a top level layer int the MJC hierarchy on the server side. Accepted connections will be forwarded to the destination host.


Constructor Summary
MJCLoopBackProtocol(int workPort, java.lang.String forwardToHost, int forwardToPort, int adminPort)
          Default constructor.
 
Method Summary
 void connectionClosedEvent(MJCReadable readable)
          Indicates that the source connection of the specified MJCReadable has been closed.
 void errorEvent(java.lang.String errorDescription, MJCReadable readable)
          Indicates that there was an error in the source connection of the specified MJCReadable.
 MJCConfiguration getConfiguration()
          Returns the MJCConfiguration with which this object is customized.
 MJCReadable getReadable()
          Returns the MJCReadable from which data will be read.
 java.lang.String getReaderName()
          Returns the MJC name of the MJCReader.
 java.lang.String getReaderVersion()
          Returns the MJC version of the MJCReader.
 java.lang.String getServerManagerName()
          Returns the MJC name of the MJCServerManager.
 java.lang.String getServerManagerVersion()
          Returns the MJC version of the MJCServerManager.
 void newClientHasArrivedEvent(MJCTransport server, MJCTransport client)
          This method will be invoked from the MJCTransport when a new client arrives.
 void readEvent(MJCReadable readable)
          Indicates that there is data available from the specified MJCReadable.
 void run()
          Entry point for the thread for each client.
 void setConfiguration(MJCConfiguration configuration)
          Sets the MJCConfiguration for this object.
 void setConfigurationInput(java.lang.String is)
          Sets the customization file that will be sent through the network for clients to allow them basic configuration via the server.
 void setReadable(MJCReadable readable)
          Sets the MJCReadable from which data has to be read.
 void start()
          This method starts the application.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MJCLoopBackProtocol

public MJCLoopBackProtocol(int workPort,
                           java.lang.String forwardToHost,
                           int forwardToPort,
                           int adminPort)
Default constructor. Workport (where the connections will be accepted), the name of the host to forward to, and the destination port as well as the admin port have to be specified.
Parameters:
int - workPort: the port number where the clients connect
String - forwardToHost: the host to forward to
int - forwardToPort: the port to forward to
int - adminPort: the administration port
Method Detail

setConfigurationInput

public void setConfigurationInput(java.lang.String is)
Sets the customization file that will be sent through the network for clients to allow them basic configuration via the server.
Parameters:
String - is: the location of the customization file

start

public void start()
This method starts the application.
Specified by:
start in interface MJCServerManager

run

public void run()
Entry point for the thread for each client.
Specified by:
run in interface java.lang.Runnable

setConfiguration

public void setConfiguration(MJCConfiguration configuration)
Sets the MJCConfiguration for this object.
Parameters:
MJCConfiguration - configuration: the MJCConfiguration object for the customization

getConfiguration

public MJCConfiguration getConfiguration()
Returns the MJCConfiguration with which this object is customized.
Returns:
MJCConfiguration: the MJCConfiguration with which this object is customized

getServerManagerName

public java.lang.String getServerManagerName()
Returns the MJC name of the MJCServerManager.
Specified by:
getServerManagerName in interface MJCServerManager
Returns:
String: the MJC name of the MJCServerManager

getServerManagerVersion

public java.lang.String getServerManagerVersion()
Returns the MJC version of the MJCServerManager.
Specified by:
getServerManagerVersion in interface MJCServerManager
Returns:
String: the MJC version of the MJCServerManager

newClientHasArrivedEvent

public void newClientHasArrivedEvent(MJCTransport server,
                                     MJCTransport client)
This method will be invoked from the MJCTransport when a new client arrives.
Specified by:
newClientHasArrivedEvent in interface MJCServerManager
Parameters:
MJCTransport - server: the server that has accepted the client
MJCTrabsport - client: the accepted client

getReaderName

public java.lang.String getReaderName()
Returns the MJC name of the MJCReader.
Specified by:
getReaderName in interface MJCReader
Returns:
String: the MJC name of the MJCReader

getReaderVersion

public java.lang.String getReaderVersion()
Returns the MJC version of the MJCReader.
Specified by:
getReaderVersion in interface MJCReader
Returns:
String: the MJC version of the MJCReader

readEvent

public void readEvent(MJCReadable readable)
Indicates that there is data available from the specified MJCReadable.
Specified by:
readEvent in interface MJCReader
Parameters:
MJCReadable - readable: there is data available from the readable

connectionClosedEvent

public void connectionClosedEvent(MJCReadable readable)
Indicates that the source connection of the specified MJCReadable has been closed.
Specified by:
connectionClosedEvent in interface MJCReader
Parameters:
MJCReadable - readable: the MJCReadable whose source connection has been closed

errorEvent

public void errorEvent(java.lang.String errorDescription,
                       MJCReadable readable)
Indicates that there was an error in the source connection of the specified MJCReadable.
Specified by:
errorEvent in interface MJCReader
Parameters:
String - errorDescription: the error message
MJCReadable - readable: the MJCReadable where the error occured

setReadable

public void setReadable(MJCReadable readable)
Sets the MJCReadable from which data has to be read.
Specified by:
setReadable in interface MJCReader
Parameters:
MJCReadable - readable: the MJCReadable from which data has to be read

getReadable

public MJCReadable getReadable()
Returns the MJCReadable from which data will be read.
Specified by:
getReadable in interface MJCReader
Returns:
MJCReadable: the MJCReadable from which data will be read