A Guide to Porting JECho to Transports Other Than TCP



 

IMPORTANT: Source files for classes in package jecho.* are under $JECHO/src.  Source files for classes in package jecho.platform.* are under $JECHO/src/j2se (For example, if you want to modify JECho.platform.ConnectionThread.java, you will need to modify $JECHO/src/j2se/ConnectionThread.java. The copy under $JECHO/src will be overwritten during the rebuild).
 
 

Related Code Segments

Intitialization Phase:
jecho.Concentrator.start()
    jecho.platform.ConnectionThread.constructor()
        jecho.platform.JEChoServerSocket.constructor(port1, port2);
    jecho.platform.ConnectionThread.start()
        jecho.platform.JEChoServerSocket.accept();
 

Connection Establishment:
 

Passive side:
jecho.platform.ConnectionThread.run()
    jecho.platform.JEChoObjectInputStream.constructor()
    jecho.platform.JEChoObjectOutputStream.constructor()
    jecho.StreamEntry.constructor()
        jecho.platform.SelectThread.addInputStream()
            jecho.platform.SelectThread.constructor()
            jecho.platform.SelectHelpThread.constructor()

 
Active side:
jecho.StreamEntry.realGetStreams()
    jecho.platform.JEChoSocket.constructor()
    jecho.platform.JEChoObjectOutputStream.constructor()
    jecho.platform.JEChoObjectInputStream.constructor()
    jecho.StreamEntry.constructor()
        jecho.platform.SelectThread.addInputStream()
            jecho.platform.SelectThread.constructor()
            jecho.platform.SelectHelpThread.constructor()


Sending an event:
jecho.PushSupplierHandle.send()
    jecho.Concentrator.urgentGroupSend()
        jecho.SendRecv.sendObject()
           jecho.JEChoObjectOutputStream.writeObject()
jecho.PushSupplierHandle.flush()
    jecho.Concentrator.flush()
        jecho.JEChoObjectOutputStream.flush()

Receiving an event:
jecho.SelectThread.run()
  jecho.platform.JEChoObjectInputStream.readObject()
 



 

Necessary Modifications
 

jecho.platform.JEChoServerSocket.constructor(port1, port2)

jecho.platform.JEChoServerSocket should be modified to use the second port (currently treated as another TCP port but not really used) as the UDP port.

Jecho.platform.JEChoServerSocket.accept()

Should be modified in accordance with the above change.
jecho.platform.JEChoObjectInputStream.constructor()
Needs a UDP version of the jecho.platform.JEChoObjectInputStream class. Only difference will be in the constructor. The UDP version does not need to exchange OS support info with its corresponding output stream.


jecho.platform.JEChoObjectOutputStream.constructor()

Needs a UDP version of jecho.platform.JEChoObjectOutputStream. The simpliest way is to use a new class that extends it. three methods need to be rewritten: the constructor, the writeObject() method and the flush() method. In constructor, it does need to exchange standard object serialization support info with its corresponding output stream.

jecho.StreamEntry.constructor()

Add a line to invoke SelectThread.addInputStream() with the UDP object input stream as parameter, so that there will be threads listening to the UDP connection.

jecho.platform.JEChoSocket.constructor()

The JEChoSocket now contains a TCP socket and a UDP socket. Two new methods should be added to get the input stream and output stream for the UDP socket. For this purpose, there have to be two wrapper classes which implement java.io.InputStream and java.io.OutputStream, respectively, for the UDP socket. But both these wrapper classes need to implement only one method: read(byte[],int,int) for input stream and write(byte[],int,int) for output stream. (in addition to the changes in the constructors).

jecho.PushSupplierHandle.send()

Add a parameter to indicate that this is a UDP send.

jecho.Concentrator.urgentGroupSend()

Add a parameter for UDP send.

jecho.SendRecv.sendObject()

Add a parameter for UDP send. If UDP send, then use the UDP object output stream field in the StreamEntry to write the object to.

jecho.JEChoObjectOutputStream.writeObject()

This is the writeObject method for the UDP verison of the JEChoObjectOutputStream. Its difference from the current version is that no flush() should be called during the writing of an object. (Assume we don't need to split an object into multiple UDP packets).  

jecho.Concentrator.flush()

Flush the UDP object output stream as well.

jecho.platform.JEChoObjectInputStream.readObject()

Probably no change needed if an object is always in one packet.