The middleware (WebFlow)

Overview

Installation

Download

Download
BeanContext_2.2.2.tar (current release) and untar it to a selected directory (use Winzip or similar utility on NT, or
tar -xvf BeanContext_2.2.2.tar on Unix system). Location of the unpacked directory (BeanContext_2.2.2) is irrelevant. It can be C:\webflow, or /home/webflow, or whatever that is convenient for you. The actual location of the BeanContext_2.2.2 we will denote as <install>. We will refer to it when discussing how to configure WebFlow.

Contents of BeanContext_2.2.2.tar

      |BeanContex_2.2.2>
           |
           | -- |generated>
           | -- |classes>
           | -- |demo> 
           |       |
           |       |-- |generated>
           |       |-- modules.idl
           |       |-- Makefile
           |       |-- moduleImpl.java 
           | -- BC.idl
           | -- Makefile
           | -- master_test.conf
           | -- slave_test.conf
           | -- slave_testNT.conf
           | -- test_client.java
           | -- WebFlow.java
(see also
a screen capture)

Directory BeanContext_2.2.2 contains:

Compile WebFlow

Make sure that you have set your environment correctly. You need: NOTE:

Compilation is done in two steps:

idl compilation using jidl compiler that comes with ORBacus (ORBacus/bin/jidl.exe). jidl compiler takes an idl file as an input and generates a number of ORB related java source files, including interfaces of all objects defined in the idl file. Compile BC.idl using the following command:

 jidl --tie  --output-dir generated BC.idl
Files generated by jidl are stored in BeanContext_2.2.2/generated/WebFlow and BeanContext_2.2.2/generated/WebFlow/event. This is because of

java compilation using javac compiler that comes with JDK 1.2. First compile all files generated by the jidl compiler, BeanContext_2.2.2/generated/WebFlow/*.java and BeanContext_2.2.2/generated/WebFlow/event/*.java. Next, compile all java files in BeanContext_2.2.2. Make sure that you use -d switch of javac compiler to get all compiled classes in BeanContext_2.2.2/classes directory, that is,

javac  -d ..\classes \ 
 generated\WebFlow\*.java generated\WebFlow\event\*.java *.java

Note:
Compilation can be simplified by using the make utility. An exampe Makefile included in the distribution looks like that:

all 
 jidl --tie  --output-dir generated BC.idl 
 javac  -d ../classes \ 
 generated/WebFlow/*.java generated/WebFlow/event/*.java *.java
For WindowsNT, make sure that you use "\" rather than "/". Here we assume that you have make utility installed on your system (it comes, for example, with Microsoft Visual C++)

Note:
There is no need to recompile the WebFlow. The existing classes are ready for use (as soon as you add BeanContext_2.2.2/classes to your $CLASSPATH).

Note:
For clients implemented as Java Applets the directory classes (currently in <install>/BeanContext_2.2.2/) must be inside your web server document tree (see section Clients implemented as Applets for details).
Effectively, it means that you have to modify your Makefile to:

DIR = <document_root>/classes
all 
 jidl --tie  --output-dir generated BC.idl 
 javac  -d $(DIR) \ 
 generated/WebFlow/*.java generated/WebFlow/event/*.java *.java
and replace <install>/BeanContext_2.2.2/classes in your CLASSPATH by <document_root>/classes

Configure WebFlow

You configure WebFlow by creating server configuration file. There are two types of servers: master server that writes its IOR to a file within your Web server's document tree, and slave servers that read this file thorugh a URL connection.

Example master_test.conf: master WebFlow server configuration file.

ServerName=master_test
File=/npac/home/webflow/WEBFLOW/JIGSAW/Jigsaw/WWW/IOR/testmaster.txt 
URL=none 
PARENT=none
WEBFLOW_IDL=/npac/home/webflow/WEBFLOW/BeanContext_2.2.2
Modules:===================
ServerName
arbitrary string (that can be used as a file name)
file
location where the master server will write its IOR (interoperable object reference). Since it is to be accesses by slave servers and clients through url, the file must be located inside Web Server's document tree.
URL
ignored by the master server.
PARENT
ignored by the master server.
WEBFLOW_IDL
path to BC.idl file (<install>/BeanContext_2.2.2)

To configure your master server, please edit this file and set the values of file and WEBFLOW_IDL attributes.

Example of slave_test.conf: slave WebFlow server configuration file.

slave_test.conf
ServerName=slave_test
File=none 
URL=http://osprey4.npac.syr.edu:8001/IOR/testmaster.txt
PARENT=master_test
WEBFLOW_IDL=/npac/home/webflow/WEBFLOW/BeanContext_2.2.2
Modules:===================
ServerName
arbitrary string (that can be used as a file name)
file
ignored by a slave server.
URL
url to IOR file written by the master server.
PARENT
name of the parent server (you can build a tree of servers, arbitarily deep)
WEBFLOW_IDL
path (thus not filename) of BC.idl.

To configure your slave server, please edit this file and set the values of URL and WEBFLOW_IDL attributes.

testing WebFlow servers

  1. customize WebFlow servers configuration files
  2. open a new window (Command Prompt window on WindowsNT)
  3. execute command: java WebFlow.Server master_test.conf
  4. once the master server is up and running, make sure that your Web Server is up
  5. open a new window
  6. execute command: java WebFlow.Server slave_test.conf
    • a lot of cryptic text will be generated in the window, also you will see new messages printed to the master WebFlow server window. The last line should read
      ERVER IS READY FOR ACCEPTING USER COMMANDS.....
      GATEWAY SERVER:exist:true
      Slave Webflow: sent addWFServer request
      They can come in a different order, as they are generated by three different processes. Be patinet, starting a server takes time. It depends on speed of your machine. It may take several sececonds.
    • any error messages, java exceptions, etc. are signatures of a failure. Double check configuration files and $CLASSPATH, and restart. If you cannot make it running please save the output, and send it with your *.conf files to T. Haupt
  7. once both master and slave server are running, you may run the test client code
  8. open a new window (third one) and execute command java WebFlow.client url of the master ior file. The url is identical to that you specified in the save_test.conf file
  9. the client will connect to your slave server, create a new context within the slave context, shut down both slave and master servers, and finally write to the output stream message "TEST COMPLETED".
    Example output:
    osprey4:/project/gateway/WebFlow/Releases/WebFlow_2.2.1% java WebFlow.Client http://osprey4.npac.syr.edu:8001/IOR/testmaster.txt
    Slave WebFlow is getting IOR from url:http://osprey4.npac.syr.edu:8001/IOR/testmaster.txt
    IOR:000000000000001f49444c3a576562466c6f772f576562466c6f77436f6e746578743a312e30000000000001000000000000003400010000000000156f7370726579342e6e7061632e7379722e6564750000aef0000000100000000037b096a80006ca4800000001
    Client: Connected to the Master Server
    Client: Connected to the Slave Server
    create a subContext
    Failure? false
    Client: SubContext created
    TEST COMPLETED
    
    Note: there should be no null pointer exceptions. If you got one, please double check your configuration files and $CLASSPATH
  10. this concludes the test. Slave_server, and master_server should be shut down at this time (you should have the prompt at their windows).
Now, you are ready for the first demo

WebFlow API

View
JavaDoc for BeanContext_2.2.2

Starting a WebFlow Server

Master server: You start the master server using command
java WebFlow.Server master.conf
where master.conf is
a master configuration file. This process must have privilege to write its IOR.

You cannot instantiate a master server more than once (it will fire an exception if you do). To run two master servers concurrently, you must set different names in their configuration files (as well as the file attribute, otherwise one server will overwrite the IOR of the other).

Slave server: You start the slave server using command

java WebFlow.Server slave.conf
where slave.conf is a slave configuration file. The web server to which the master wrote its IOR must be up.

That is, the procedure of starting a slave server is identical to that of starting the master server. The only difference is different configuration file.

You can start and arbitrary number of slaves of a given master, as long as you assign them different names in their configuration files.

In addition, you can start a slave of a slave, by specifing accordingly the PARENT atribute in its configuration file. Say, if the master server name is "master", slave server name is "slave", you can start "slave-slave" by specifying its PARENT as master/slave, and slave-slave-slave by setting its PARENT to /master/slave/slave-slave.

WebFlow Contexts

A WebFlow context is a container object of type WebFlowContext that extends BeanContextChild.class.

creating a new WebFlow context

A WebFlow context can be started as a separate process (then we call it a WebFlow server) or be added as a child to an existing contexts. Starting the server is described in section Starting a WebFlow Server above. You can add a new context to existing one by invoking a method of the WebFlowContext class:

org.omg.CORBA.Object addNewContext("context_name");
To use methods of the newly created context you must narrow it first:
org.omg.CORBA.Object o = addNewContext("context_name");
WebFlowContext c = WebFlowContextHelper.narrow(o);
or simply
WebFlowContext c = WebFlowContextHelper.narrow(addNewContext("context_name"));

accessing a WebFlow context

You can access all existing WebFlow contexts (both servers and "internal") through the master server. To access the master server:

Here is an example code to do that:
       String ior = readIORfromURL(url);
       try {  
       org.omg.CORBA.Object MasterObj=orb.string_to_object(ior);
       WebFlowContext Master = WebFlowContextHelper.narrow(MasterObj);  
       }
       catch (Exception e) {System.out.println("connection failure "+e);}
Note: You can create an IOR file for any CORBA object by invoking ORB method
String orb.object_to_string(org.omg.CORBA.Object o);
and use this IOR to connect to this object.

Once you have acccess to the master server, you can use its methods to access other contexts by invoking

org.omg.CORBA.Object o = Master.getContext("context_name");
WebFlowContext slave = WebFlowContextHelper.narrow(o);
and it does not matter whether the slave contex is running as a separate process (i.e., as the slave Server) or it is an internal context created by addNewContext method. Referring to the example in section Starting a WebFlow Server, you can access the slave-slave-slave context (which happens to be a server) using
org.omg.CORBA.Object o = Master.getContext("master/slave/slave-slave/slave-slave-slave");
Note: It works only "down-the-tree".

Selected methods of the WebFlowContext class

The full list of WebFlowContext class can be found in JavaDoc for BeanContext_2.2.2. Here we list a few most commonly used ones:

String c.getObjectID();
retuns the name of the context c
org.omg.CORBA.Object[] c.toArray();
returns all children of a givent context c (child contexts and modules)
org.omg.CORBA.Object c.getParent();
returns the parent context
org.omg.CORBA.Object c.getKeyedChild(String name);
returns child object (context or module) named "name" (but not grandchildren!)
void c.removeMyself();
removes itself together with all hierarchy of objects pending on it; if the context is a server, it terminates the process together with all processes pending on it, such as ir (interface depository).
org.omg.CORBA.Object c.addNewModule(String name);
add a new module to the context (see section WebFlow modules for details
void c.removeModule(String name);
removes the module from the context (see section WebFlow modules for details
void c.attachPullEvent(org.omg.CORBA.Object s, String eventName,org.omg.CORBA.Object d, String methodName);
attaches a pull event (see section WebFlow events for details
void c.attachPushEvent(org.omg.CORBA.Object s, String eventName,org.omg.CORBA.Object d, String methodName);
attaches a push event (see section WebFlow events for details
void c.detachPullEvent(org.omg.CORBA.Object s, String eventName,org.omg.CORBA.Object d, String methodName);
detaches a pull event (see section WebFlow events for details
void c.detachPushEvent(org.omg.CORBA.Object s, String eventName,org.omg.CORBA.Object d, String methodName);
detaches a push event (see section WebFlow events for details

WebFlow Modules

A WebFlow module is an object of type WebFlowContext that extends BeanContextChildSupport.class.

creating a new WebFlow module

to be written

adding a WebFlow module to a context

to be written

removing a WebFlow module from a context

to be written

interactions between modules

to be written

WebFlow Events

to be written

Pull Events

to be written

Push Events

to be written

WebFlow clients

Java Applications

to be written

Java Applets

to be written


By T.Haupt