This demo shows how remote references work. The server acts as a Counter factory, creating counters on request. Each counter can return or increase its value. Additionally the factory can hold a CounterService reference and exchange it with the client.
The client creates two counters, increases them a few times showing that they are in fact independent, then calls the second one as many times as you specify in the first command-line parameter. It then swaps it with the holder function of the factory.
Initially, when the server is started, the holder doesn't hold anything so the first run will return null after the exchange. In subsequent runs the client calls the swapped counter. When the holder on the server receives a counter, it logs the received counter's value.
In addition to the files described in Files and Directories, this demo contains:
File or directory | Description |
---|---|
src/demo/advanced/remotereferences/server/ | Server source code |
src/demo/advanced/remotereferences/client/ | Client source code |
You can run the demo using the "run.sh" (for UNIX) or "run.bat" (for Windows) scripts. Running the script without arguments prints out a help message on screen.
The demo can be run in two different ways:
To use Runtime Publishing, follow these steps:
Be sure that you have not started SESJ.
Compile the server classes.
Windows: run.bat make_server Linux: ./run.sh make_server
Run CounterServer (it starts SESJ and publishes CounterFactory class) ...
Windows: run.bat run_server Linux: ./run.sh run_server (use a new terminal)
You can look at CounterFactory WSDL on http://localhost:6060/demo/advanced/remotereferences/CounterFactoryService/wsdl from your browser.
Make client classes.
Windows: run.bat make_client Linux: ./run.sh make_client
Run the CounterClient (it calls CounterFactory and deals with created CounterServices) ...
Windows: run.bat run_client Linux: ./run.sh run_client
If you use the run.sh or run.bat script to run the client, you can specify the number of second counter increases like this:
run.sh run_client 10
Please note that by default, the remote references on the server expire after 10 minutes since the last call.
If you wish to follow the progress of the invocation with SoapSpy, perform the following:
Run server_java60/bin/soapspy.bat or soapspy.sh. This will bring up the SoapSpy GUI.
Start spying by selecting Start Spying from the Spy menu or by clicking the spy icon in the main pane.
Run the client using the run spy_client command instead of run_client.
To run using Persistent Deployment:
Be sure that you've started SESJ.
Compile and pack the server classes.
Windows: run.bat make_service Linux: ./run.sh make_service
Deploy the CounterFactory service on the SESJ.
Windows: run.bat deploy_service Linux: ./run.sh deploy_service
Make the client classes.
Windows: ./run.bat make_client Linux: ./run.sh make_client
Run CounterClient (it calls CounterService).
Windows: ./run.bat run_client Linux: ./run.sh run_client
If you use the run.sh or run.bat script to run the client, you can specify the number of second counter increases as shown below:
run.sh run_client 10
Please note that by default the remote references on the server expire after 10 minutes since the last call to them.
Undeploy the CounterFactory service from the SESJ.
Windows: run.bat undeploy_service Linux: ./run.sh undeploy_service