ProductBrowser example demonstrates heterogeneous client access by using both a .NET client and a Java client to interact with a Java cache server and exchange data between the clients. Both clients have
Product for their
DataSerializable class, and the .NET client implements a cache listener to display events as they occur.
ProductBrowser to put product data into the cache server from one client, retrieve the data in another client, make modifications, then update the clients with the new data. The example is located in
ProductBrowser example runs both a .NET client and a Java client with a GemFire Java cache server. The example uses
product.xml to configure the Java cache server. When the Java cache server starts,
product.xml creates a
root region named
In the procedures, the lines you type are shown in a
boldface fixed font. System output is in a
regular fixed font.
Examples that interact with a Java cache server require specific environment configurations so the Java cache server will run properly. Follow the configuration steps listed below that apply to your operating system:
bin/setenvscript for your system. Refer to the developer's guide if you need help with this step.
GF_JAVA_HOMEenvironment variables to your installed Java JRE or JDK. See the Installation chapter of the GemFire Enterprise System Administrator's Guide for the versions of Java that are compatible with GemFire Enterprise. The
JAVA_HOMEsetting is for your applications, and
GF_JAVA_HOMEis for the GemFire scripts. You must have a compatible Java JRE or JDK installed and you must set
GF_JAVA_HOMEto point to it.
$JAVA_HOME/binto the start of your
The following is a list of the environment configuration commands for the
ProductBrowser example. Choose the set of commands that are appropriate for your operating system. The text that you type is shown in bold.
These configurations only need to be performed for the sessions that invoke the Java cache server.
Bourne and Korn shells (sh, ksh, bash)
% cd GemFireInstallDirectory
% . bin/setenv.sh
% JAVA_HOME=<installed JRE PATH>; export JAVA_HOME
% GF_JAVA_HOME=$JAVA_HOME; export GF_JAVA_HOME
% PATH=$JAVA_HOME/bin:$PATH; export PATH
> cd GemFireInstallDirectory
> set JAVA_HOME=<installed JRE PATH>
> set GF_JAVA_HOME=%JAVA_HOME%
> set PATH=%JAVA_HOME%\bin;%PATH%
To start the cache server for the
ProductBrowser example, create a session and complete the following steps. Throughout this example, when you're prompted to enter the native client directory, replace the
NativeClient_xxxx with the actual four-digit product version number.
Configure the session environment according to the steps listed in Configuring the Environment.
defaultConfigdirectory as its configuration file. Enter the entire
cacheserver startcommand below on a single line, replacing the
NativeClient_xxxxwith the actual four-digit product version:
cacheserver start -dir=
The cache server is initialized using the settings in the
product.xml file. A message similar to the following appears, indicating that the cache server is running:
Cacheserver pid: 2120 status: running
The Java client uses
productClient.jar in the
lib directory. To start the Java client:
Create another session and configure its environment by entering the following command:
Add the classes for
productClient.jar to your
CLASSPATH by entering the following in a single line:
set CLASSPATH=<full path to NativeClient_xxxx>\examples\cli_ProductBrowser\
ProductBrowser Java client is initialized and connects with the cache server. In a moment, the following prompt appears:
Enter the operation to execute. 'Get' to find an object, 'Put' to insert/update an object, or 'Exit' to end:
To complete the client setup, start the .NET client by following these steps:
The Product Browser form appears. The form consists of a set of fields where you enter product data. The Event Message area is a cache listener interface that displays events as they occur in the clients.
Enter data in the Product Browser form and put the data into the cache.
In the Product Browser form:
Days to Mfg
Putbutton to enter the data into the cache server.
Next, specify the Product ID to update the Java client with the data you entered in the Product Browser form
In the Java client:
101for the Product ID that was defined in the Product Browser:
Enter the Product ID to search for: 101
The data associated with Product ID 101 is retrieved from the cacheserver:
Product ID = 101
Product Name = widget
Product Number = 123
Color = Black
Stock Level = 15
Reorder Point = 10
Product Cost = 1.5
List Price = 5.0
Available as of = 3/15
Discontinue as of = 9/12
Enter some new product values into the Java client and see both the original and the new values displayed in the .NET client (Product Browser).
In the Java client:
Stock Level (int):
Reorder Point (int):
Product Cost (double):
List Price (double):
Available as of (string):
Discontinue as of (string):
Look at the Product Browser. Its Event Message area displays the original values for Product ID 101, along with the updated values that you just entered in the Java client.
cacheserver stop -dir=defaultConfig
Now close the cache server session:
End the Java client, then close its session:
Close the .NET client session:
X' button in the right part of its titlebar, or by clicking the icon in the left part of its titlebar and then clicking
This product ships configured to run with default system properties. If you need to run in a non-default configuration, GemFire also takes a system-level configuration file. Copy the
gfcpp.properties file into your
cli_ProductBrowser directory from the
defaultSystem directory. Edit the
gfcpp.properties file in your
cli_ProductBrowser directory as needed. For example, to change the name of the
cache.xml file, uncomment this line and change the file name:
Copyright © 2005-2008 by GemStone Systems, Inc. All rights reserved. GemStone®, GemFire®, and the GemStone logo are trademarks or registered trademarks of GemStone Systems, Inc. All other trade names or trademarks are the property of their respective owners. Information in this document is subject to change without notice.