|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:
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.idlFiles 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 *.javaFor 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 *.javaand replace <install>/BeanContext_2.2.2/classes in your CLASSPATH by <document_root>/classes
Example master_test.conf: master WebFlow server configuration file.
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.
To configure your slave server, please edit this file and set the values of
URL and WEBFLOW_IDL attributes.
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
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.
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:
accessing a WebFlow context
You can access all existing WebFlow contexts (both servers and "internal")
through the master server. To access the master server:
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.
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:===================
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:===================
testing WebFlow servers
Now, you are ready for the first
demo
GATEWAY SERVER:exist:true
SERVER IS READY FOR ACCEPTING USER COMMANDS.....
FactoryImpl: createProxy: after new proxy()_usermaster_test
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 serveral seconds.
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.
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
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.
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. WebFlow Contexts
A WebFlow context is a container object of type WebFlowContext
that extends BeanContextChild.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"));
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:
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 Pull Events
to be written Push Events
to be written
to be written Java Applets
to be written
WebFlow Events
to be written
WebFlow clients
Java Applications
By T.Haupt