All Examples
package examples.rmi.stock
about this package
The examples.rmi.examples.stock package illustrates how you
might write a distributed application that uses an applet that
exports a remote object to receive stock updates from a stock
server. In this example, the applet displays the stock data
dynamically as notifications are received from the server. This
package was adapted with very few changes from the original example
Stock package included with the JavaSoft RMI distribution.
Also included in this directory are build scripts for Windows NT, Microsoft
SDK for Java, and UNIX. The scripts compile the files in this directory and
run the RMI compiler on the implementation class.
There are detailed instructions on converting Sun RMI classes to use
WebLogic RMI in the Developers Guide. The instructions here are brief
and assume that you have or will look at the Developers Guide.
The classes and interfaces that you will compile and run for this
example are as follows:
- StockNotify is the remote interface for StockWatch.
- StockWatch is the remote interface for StockServer.
- Stock is the serializable object containing stock data.
- StockApplet (implements StockNotify) registers
with StockServer for stock updates displays stock notifications as
they are received.
- StockServer (implements StockWatch) sends
notifications of stock updates to remote objects that have registered
to receive updates.
This applet will not work if you are running the server using JDK 1.2 or
later since the web-browser is running an incompatible 1.1 JVM. If you wish to
deploy applets from a server running with JDK 1.2, we suggest you use the
Java Plug-in.
how to use this package
- Set up your development environment as described in
Setting your development environment.
- If you are not going to be running the browser client and server on the same machine
(using "localhost" to call up the StockApplet.html file), you will need to modify the "host" variable
in StockServer.java to refer to the name of the machine running WebLogic
Server.
- If you are not going to be using 7001 as the WebLogic listen port
(weblogic.system.ListenPort), you will
need to modify the "port" variable in
StockServer.java to refer to the appropriate port number.
- The build scripts are:
- build.cmd - JavaSoft JDK running on NT
- buildms.cmd - Microsoft SDK for Java
- build.sh - UNIX
Run the appropriate build script as shown in this
example for the JavaSoft JDK running on NT:
$ build
- Copy the StockApplet.HTML file to your registered WebLogic document
root, weblogic/myserver/public_html, by default.
- In the copy of the HTML file
that calls the applet, adjust the serverPort parameter to the
port where your WebLogic Server is listening, and the CODEBASE if necessary.
The HTML file is shipped with the CODEBASE set
to "classes/".
If you are having problems, see
Troubleshooting CODEBASE.
- Register the StockServer class as an RMI startup class in the
weblogic.properties file with this entry:
weblogic.system.startupClass.stock=examples.rmi.stock.StockServer
- Start WebLogic Server in your development shell.
- Call the applet from a browser. Make sure your browser doesn't have the
WebLogic classes in its CLASSPATH, if you're using a browser on the same
machine that is hosting your WebLogic Server. Use a URL like:
http://WebLogicURL:Port/StockApplet.html
- WebLogicURL
- Domain address of the WebLogic Server
- Port
- Port that is listening for connections
(weblogic.system.ListenPort)
there's more . . .
Read more about this WebLogic service in the Developers Guide,
Using
WebLogic RMI.