CORBA SAMPLE CODE: STATION
MONITOR
INTRODUCTION
The Station Monitor example shows off a simple CORBA client/server
interactions. It supports two scenarios. In the first scenario,
a Java applet talks to a back-end server object called the "station".
In the second scenario, a Java client application receives callbacks from
an intermediary object called the "collector" who periodically polls running
stations and passes information to the client.
All objects in this example are written in Java. Batch
files have been provided for running and building the example on Windows
NT. However, the example can still be manually built and run on any
UNIX workstation running the Enterprise Server.
TABLE OF CONTENTS
STATION MONITOR
DESIGN
SCENARIO
The Station Monitor example is based around the concept of a manufacturing
station. Imagine a factory that produces widgets using an assembly
line. The assembly line is composed of a series of work stations,
each of which accomplishes some small part of the manufacturing process
by taking parts from an input bin, doing something to them, and putting
the result into an output bin. The output bin would then becomes
the input bin for the next station down the line. Each station has
different operational characteristics which can be tracked over time, such
as the number of parts in the input or output bins, the rate at which parts
are processed, and so forth.
This code example implements a simple station monitor applet that is
capable of monitoring the status of a single station, and a standalone
Java application that monitors multiple stations at once.
CORBA OBJECTS
Station
The Station object is a standalone Java application whose purpose is
to monitor the characteristics of a station. When queried through
its get_status() method, the station object returns to the caller
the current status of the station in the form of a structure. In
"real life", the station object would probably get the current station
status from a database, or from querying a set of hardware sensors set
up to monitor the station. In this example, the station object simulates
the operation of a station. It has a thread named SimTimer
(StationServer.java) that calls a private method on the station
object (updateIt)once per second. The updateIt()
method then updates the current station status based on assumptions of
the initial input bin size and time to complete a single operation.
These assumptions are settable through command-line options.
If started with the "-r" option, the Station will register itself with
a running Collector object (see below)
The Station object is implemented in the following source files:
-
mfgDemo.idl: Contains the Station object's interface definition
in IDL
-
StationSource/StationImpl.java: Implementation of the Station
object
-
StationSource/StationServer.java: Server startup, Station instantiation
and registration with the ORB and Web Naming service
-
StationSource/StationOptions.java: Command-line option processing
Collector
Single-Station Display Applet
Multiple-Station Display Client
RUNNING
THE STATION MONITOR
PRE-REQUISITES
The Station Monitor example comes pre-compiled, so you don't need to
build it in order to run it. However, you must have the following:
On the Enterprise Server Machine:
-
Windows NT
-
Enterprise Server 3.0
-
Web naming needs to be configured so that IORs can be written to the directory
tree starting at iiop_objects.
-
Click here for information on configuring
Web Naming on the Enterprise server.
-
A standalone Java VM supporting the JDK1.1 installed. (Ex: JDK1.1.X
from JavaSoft, or Symantec's Visual Cafe for Java 1.1)
-
The Java VM is used by idl2java to process the IDL file
-
Your CLASSPATH should include the following directories (in this order)
-
<JDK 1.1 Libraries> (Location dependent on your vendor.)
-
<Enterprise Server Install Directory>\wai\java\nisb.zip
-
<Enterprise Server Install Directory>\wai\java\wai.zip
-
Your PATH should include the directory for your Java VM (So that
you can just type "java" to run it)
On the Client Machine (Perhaps the same machine as the server machine)
-
Communicator 4.0.X installed and configured
STARTING STATIONS
AND THE COLLECTOR
Before you can run either the Single-Station Monitor applet or the
Multi-Station Monitor client, you have to start the collector (for the
multi-station case) and one or more stations. A batch file has been
provided that will automatically start the collector and two default
stations ("StationR" and "StationT"):
-
Bring-up a DOS-box and verify that your PATH and CLASSPATH are correctly
set
-
Navigate to the root demo directory
-
Type "run" from the root demo directory.
-
The Collector and stations will each start in a separate, minimized DOS
box
-
NOTE: If the collector and stations start and then immediately exit, your
web server has not been properly configured for Web Naming. Follow
this link to a document on configuring
Web Naming.
SINGLE
STATION DISPLAYAPPLET
To run the single-station display applet:
-
From Communicator, navigate to the demo directory and select the file "sglStClasses.html".
MULTIPLE
STATION MONITOR CLIENT
(COMMAND-LINE)
To start the multiple-station monitor client:
-
Bring-up a DOS-box and verify that your PATH and CLASSPATH are correctly
set
-
Type "runmmclt" from the root demo directory
-
The monitor will start. Press Ctl-C to quit it.
BUILDING
THE STATION MONITOR
PRE-REQUISITES
To build the station monitor example, you will need to have the following:
-
Enterprise Server 3.0
-
A standalone Java VM supporting the JDK1.1. (Ex: JDK1.1.X from JavaSoft,
or Symantec's Visual Cafe for Java 1.1)
-
Your CLASSPATH should include the following directories (in this order)
-
<JDK 1.1 Libraries> (Location dependent on your vendor.)
-
<Enterprise Server Install Directory>\wai\java\nisb.zip
-
<Enterprise Server Install Directory>\wai\java\wai.zip
-
Your PATH should include:
-
The directory for your Java VM (So that you can just type "java"
to run it)
-
The directory for your Java compiler (javac)
FILE AND
DIRECTORY STRUCTURE
The station monitor example has the following directory structure:
-
<root dir>: Batch files to run and build example.
HTML files for running applet. Readme. IDL source file.
-
amd: Source files for a freeware progress
bar widget
-
classes: Directory tree of class files created from the
example source
-
Docs: Other useful documents
-
CollectorSource: Source files for the Collector
-
MonitorSource: Source files for the Single-Station Monitor
applet and Multi-Station Monitor Client
-
StationSource: Source files for the Station
BUILDING
Three DOS batch files have been created to help you build the sample
code.
-
makeidl.bat: Calls the idl2java IDL
compiler to generate CORBA object stubs and skeletons
-
make.bat: Calls the Java compiler to compile
the source files
-
makeclean.bat: Removes the class files and generated
source files
Once you have your environment set-up according to the above pre-requisites,
do the following to build the example code:
-
Open a DOS box and verify your PATH and CLASSPATH variables are correctly
set
-
Navigate to the example code root directory
-
Type "makeidl" to call the IDL compiler
-
Type "make" to compile all the source
REFERENCE
CREDITS
-
The progress bar widget used in the Station Monitor applet was created
by Adam Doppelt, who has graciously made it available to development community,
along with other useful Java widgets. Check out his home
page and give him your support.
DOCUMENTATION
-
Netscape
ISB for Java Programmer's Guide - provides information on how to develop
and program distributed object-based applications in Java for Windows and
UNIX platforms using the Netscape Internet Service Broker. Last updated
8/4/97.
-
Netscape
ISB for Java Reference Guide - provides reference information on the
commands, utilities and interfaces included with the Netscape Internet
Service Broker for Java under Windows and UNIX operating systems. Preliminary,
last updated 5/97.
BATCH FILE SOURCES
makeidl.bat
idl2java -no_comments -no_examples -no_tie mfgDemo.idl
make.bat
mkdir classes
javac -d classes CollectorSource\*.java
javac -d classes StationSource\*.java
javac -d classes MonitorSource\*.java
makeclean.bat
rmdir /s /q classes
rmdir /s /q StationModule
rmdir /s /q CollectorModule
rmdir /s /q MonitorModule
run.bat
set CLASSPATHSAV=%CLASSPATH%
set CLASSPATH=classes;%CLASSPATH%
set CORBAOPTS=-DDISABLE_ORB_LOCATOR
start "Collector" /min java %CORBAOPTS% CollectorModule.CollectorServer
-n Collector
start "StationR" /min java %CORBAOPTS% StationModule.StationServer
-n StationR -i R -d "Airplane Assembly" -u 100 -t 4 -s 5 -r -c Collector
start "StationT" /min java %CORBAOPTS% StationModule.StationServer
-n StationT -i T -d "Airplane Finishing" -u 25 -t 8 -s 5 -r -c Collector
set CLASSPATH=%CLASSPATHSAV%
runmmclt.bat