Webflow Tutorial


Developing Modules

Using Default Ports

    In order to make the module developement easier, two default Port implementations are provided with the Webflow distribution. An InputPort class which receives data and an OutputPort class which sends data. Both these classes takes any Serializable data as arguments to their send and receive methods. Thus module developers can make use of these two ports for sending any serializable data between modules. For eg., the image filter demo modules use a data type, ImgData, which implements serializable interface. The InputPort and OutputPort classes are then used as follows :

          InputPort inport; //inport declaration
          OutputPort outport; // Outport declaration

          outport = new OutputPort("ImgData"); // in module's initialize method
          mm.putPortID(outport.getPortID());
          inport = new InputPort("ImgData");
          mm.putPortID(inport.getPortID()):

          ImgData imgdat = (ImgData) inport.receive(); // In run method
          outport.send(imgdat);// inside run method

    Note : Here imgdat is a serializable data type which implements the Serializable interface.

Creating Ports

    If a developer needs to implement a special or custom port class follow these directions. All ports are derived from Port class . The main methods in the Port class are:

    A simple integer port has been used for the adder class . The basic integer port sends and recieves an Integer object since the send and receive functions of the Port class deal with the Object class . When the IntPort object is created, the constructor of the Port class is called which registers the port with the ConnectionManager and gives a unique portID to the port. This id is retrieved using the getPortID() method in the initialize method of the module . This portID is what is stored in the MetaModule and it is what is used for making connections between modules.

    The destroy method is used when the module terminates and is used to deregister the port.

    The send and recieve methods are implemented in the following way in the IntPort class 1.

  1. Send Method
  2. The send method as defined by the Port class takes an Object as its parameter:

    In the IntPort class this Object is an Integer object which contains the integer data to be transmitted through the port. To get the Socket of the port the getSocket method is called . A new output stream is created through which the data is sent:

  3. Recieve Method
  4. It returns an object of class Object:

    In the IntPort class this Object is an Integer object which contains integer data recieved . As usual the getSocket method retrieves the Socket and a new input stream is created through which data is read:

Adding Modules

    Once you have compiled the new module succesfully, put your module into some directory present in the server's CLASSPATH environment variable. (For eg. $WEBFLOW_HOME/webflow/modules ). Make sure you have the proper package name depending on where your module class is and put this fully qualified name of your module into the modules.txt file present in the $WEBFLOW_HOME directory.

    The first entry in the modules.txt file is the fully qualified name of your module, next is the hostname of the machine where your module is going to be run, the port number of your webflow server is next, and finally the module representation class.(The module representation class is the icon(image) that you will see on the webflow editor window. You can use your own or use one of the representation classes used in the demo. (For eg: webflow.frontend.SinglePortRep class can be used and this class displays the name of your class on the representation icon with a single port, DualPortRep takes can be used for modules with an input and output port) So, for eg: if your module's fully qualified name is webflow.modules.myTest.myModule and if you are using the module representation class webflow.frontend.SinglePortRep and your webflow server is running on the host myhost.edu on port 8888, then you would have an entry in the modules.txt file as follows

    webflow.modules.myTest.myModule myhost.edu 8888 webflow.frontend.SinglePortRep

    Now start the webflow demo and the new entry in the modules.txt file should show up in the webflow modules tree pallete. Click and run the module as you do in the demo programs.