Config Demo  Locate

Overview  Locate

This demo shows how a service may store or retrieve its own configuration. A service's configuration is persistent - it is untouched by server reboots.

The service used in this demo is a currency convertor, storing the currencies and translation rates in its configuration. The currencies and translation rates are adjustable as part of the service's interface. This would of course have to be a separate interface with strict access control in a real world deployment.

The client can be called with no arguments in which case the default action is taken - attempt to convert 1000 CZK (Czech Crowns) to USD (United States Dollars), set the conversion rate of the two currencies above to 1 USD = 34 CZK, and then convert 10 USD to CZK.

The first call in the default action will yield null because the conversion rate is not set yet.

The client can also be called with three arguments to convert an arbitrary combination: the first argument is the source currency name, the second is the target currency name and the third is the amount to convert.

Following example will convert 10 US Dollars to Czech Korunas (include wasp.jar and build\client\classes in your classpath).

java demo.advanced.config.client.ConfigClient USD CZK 10

Using run.sh (run.bat) the syntax is:

run.sh run_client_convert USD CZK 10

To set an arbitrary rate, the client can be called with four arguments. The first argument should be the string "set_rate", the second argument is the source currency name, the third argument is the target currency name, and the fourth argument is the rate. This example will set the conversion rate 1 USD == 34 CZK.

java demo.advanced.config.client.ConfigClient set_rate USD CZK 34

Using run.sh (run.bat) the first parameter is hidden in the run target name and the syntax is:

run.sh run_client_set_rate USD CZK 34

Demo Package Description  Locate

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

File or directoryDescription
src/demo/advanced/config/server/CurrencyConvertor.java

Currency convertor interface

src/demo/advanced/config/server/ConfigService.java

Service implementation

src/demo/advanced/config/server/Rate.java

Configuration interface for a single rate

src/demo/advanced/config/server/RateSet.java

Configuration interface for the whole rateset

src/demo/advanced/config/server/RateSet.mapping

Mapping of Java Beans properties to configuration names

src/demo/advanced/config/client/ConfigClient.java

The client implementation

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. Compile the server classes.

    Windows: run.bat make_server
    Linux:   ./run.sh make_server
    
  2. Run the ConfigServer (it starts SESJ and publishes ConfigService class).

    Windows: run.bat run_server
    Linux:   ./run.sh run_server (use a new terminal)
    

    You can look at ConfigService WSDL on 'http://localhost:6060/demo/advanced/ConfigService/wsdl' from the browser.

  3. Make the client classes.

    Windows: run.bat make_client
    Linux:   ./run.sh make_client
    
  4. Run the ConfigClient (it calls ConfigService).

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

    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 the ConfigService.

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

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

    Windows: run.bat make_client
    Linux:   ./run.sh make_client
    
  5. Run the ConfigClient (it calls ConfigService).

    Windows: run.bat run_client
    Linux:   ./run.sh run_client
    
  6. Undeploy the ConfigService from the SESJ.

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