Using a Java client with REST data services

The Java client application uses the eXtreme Scale EntityManager API to insert data into the grid.

About this task

The previous sections described how to create an eXtreme Scale grid and configure and start the eXtreme Scale REST data service. The Java client application uses the eXtreme Scale EntityManager API to insert data into the grid. It does not demonstrate how to use the REST interfaces. The purpose of this client is to demonstrate how the EntityManager API is used to interact with the eXtreme Scale grid, and allow modifying data in the grid. To view data in the grid using the REST data service, use a web browser or use the Visual Studio 2008 client application described in section .

Procedure

To quickly add content to the eXtreme Scale grid, run the following command:

  1. Open a command-line or terminal window and set the JAVA_HOME environment variable:
    • [Linux][Unix] export JAVA_HOME=<>
    • [Windows] set JAVA_HOME=<>
  2. cd /gettingstarted
  3. Insert some data into the grid. The data that is inserted will be retrieved later using a Web browser and the REST data service.
    • [Unix][Linux] ./runclient.sh load default
    • [Windows] runclient.bat load default
    Java client command syntax
    • [Unix][Linux] runclient.sh <command>
    • [Windows] runclient.bat <command>
    The following commands are available:
    • load default

      Loads a predefined set of Customer, Category and Product entities into the grid and creates a random set of Orders for each customer.

    • load category <categoryId> <categoryName> <firstProductId> <numProducts>

      Creates a product Category and a fixed number of Product entities in the grid. The firstProductId parameter identifies the id number of the the first product and each subsequent product is assigned the next id until the specified number of products is created.

    • load customer <companyCode> <contactName> <companyName> <numOrders> <firstOrderId> <shipCity> <maxItems> <discountPct>

      Loads a new Customer into the grid and creates a fixed set of Order entities for any random product currently loaded in the grid. The number of Orders is determined by setting the <numOrders> parameter. Each Order will have a random number of OrderDetail entities up to <maxItems>

    • display customer <companyCode>

      Display a Customer entity and the associated Order and OrderDetail entities.

    • display category <categoryId>

      Display a product Category entity and the associated Product entities.

Example

Running and building the sample grid and Java client with Eclipse

The REST data service getting started sample can be updated and enhanced using Eclipse. For details on how to setup your Eclipse environment see the text document: /gettingstarted/ECLIPSE_README.txt.

Once the WXSRestGettingStarted project is imported into Eclipse and is building successfully, the sample will automatically re-compile and the script files used to start the container server and client will automatically pick up the class files and XML files. The REST data service will also automatically detect any changes since the Web server is configured to read the Eclipse build directories automatically.
Important: When changing source or configuration files, both the eXtreme Scale container server and the REST data service application must be restarted. The eXtreme Scale container server must be started before the REST data service Web application.