Remote References Passing Demo  Locate

Overview  Locate

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.

Demo Package Description  Locate

In addition to the files described in Files and Directories, this demo contains:

File or directoryDescription
src/demo/advanced/remotereferences/server/

Server source code

src/demo/advanced/remotereferences/client/

Client source code

Building and Running Demos  Locate

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:

Runtime Publishing  Locate

To use Runtime Publishing, follow these steps:

  1. Be sure that you have not started SESJ.

  2. Compile the server classes.

    Windows: run.bat make_server
    Linux:   ./run.sh make_server
    
  3. 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.

  4. Make client classes.

    Windows: run.bat make_client
    Linux:   ./run.sh make_client
    
  5. 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:

    1. Run server_java60/bin/soapspy.bat or soapspy.sh. This will bring up the SoapSpy GUI.

    2. Start spying by selecting Start Spying from the Spy menu or by clicking the spy icon in the main pane.

    3. Run the client using the run spy_client command instead of run_client.

Persistent Deployment  Locate

To run using Persistent Deployment:

  1. Be sure that you've started SESJ.

  2. Compile and pack the server classes.

    Windows: run.bat make_service
    Linux:   ./run.sh make_service
    
  3. Deploy the CounterFactory service on the SESJ.

    Windows: run.bat deploy_service
    Linux:   ./run.sh deploy_service
    
  4. Make the client classes.

    Windows: ./run.bat make_client
    Linux:   ./run.sh make_client
    
  5. 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.

  6. Undeploy the CounterFactory service from the SESJ.

    Windows: run.bat undeploy_service
    Linux:   ./run.sh undeploy_service