XMLConfig
Configuration Management API for Java

XMLConfig Code Examples

The code examples can be found in "<XC_HOME>/examples" directory, where <XC_HOME> is the directory where XMLConfig is installed. See Installation Guide on how to install XMLConfig. Example 'cfgtest' needs to be compiled first before compiling any other examples.

This example shows how to use XMLConfig to define configuration sections and fields as well as how to read and write a configuration file with Java.

Source files: To compile:
    Under Windows:
    cd <XC_HOME>\examples\cfgtest
    javac -classpath ..\..\lib\xcxxx.jar -d ..\ *.java
    Under Unix:
    cd <XC_HOME>/examples/cfgtest
    javac -classpath ../../lib/xcxxx.jar -d ../ *.java
To run:
    Under Windows:
    cd <XC_HOME>\examples\cfgtest

    ' to create a new configuration file
    java -classpath ..\..\lib\xcxxx.jar;..\ cfgtest.ConfigTest -w foo.cfg

    ' to read from an existing configuration file
    java -classpath ..\..\lib\xcxxx.jar;..\ cfgtest.ConfigTest -r foo.cfg
    Under Unix:
    cd <XC_HOME>/examples/cfgtest

    ' to create a new configuration file
    java -classpath ../../lib/xcxxx.jar:../ cfgtest.ConfigTest -w foo.cfg

    ' to read from an existing configuration file
    java -classpath ../../lib/xcxxx.jar:../ cfgtest.ConfigTest -r foo.cfg

This example shows how to use XMLConfig to transfer Java objects from one host to the other over network.

Source files: To compile:
    Under Windows:
    cd <XC_HOME>\examples\cfgtrans
    javac -classpath ..\..\lib\xcxxx.jar -d ..\ *.java
    Under Unix:
    cd <XC_HOME>/examples/cfgtrans
    javac -classpath ../../lib/xcxxx.jar -d ../ *.java
To run:
    Under Windows:
    cd <XC_HOME>\examples\cfgtrans

    ' to start server
    java -classpath ..\..\lib\xcxxx.jar;..\ cfgtrans.ConfigServer

    ' to start client in another command prompt window
    java -classpath ..\..\lib\xcxxx.jar;..\ cfgtrans.ConfigClient localhost
    Under Unix:
    cd <XC_HOME>/examples/cfgtrans

    ' to start server
    java -classpath ../../lib/xcxxx.jar:../ cfgtrans.ConfigServer &

    ' to start client
    java -classpath ../../lib/xcxxx.jar:../ cfgtrans.ConfigClient localhost

This example shows how to use XMLConfig to serialize Java objects, then store and retrieve those serialized Java objects to and from database.

In order to run this example, you need to have 'MySQL' database and Mark Matthews' MySQL JDBC Driver installed. Those can be found at:
Source files: To compile:
    Under Windows:
    cd <XC_HOME>\examples\cfgdb
    javac -classpath ..\..\lib\xcxxx.jar -d ..\ *.java
    Under Unix:
    cd <XC_HOME>/examples/cfgdb
    javac -classpath ../../lib/xcxxx.jar -d ../ *.java
To run:
    Under Windows:
    cd <XC_HOME>\examples\cfgdb

    ' to write configuration to database
    java -classpath ..\..\lib\xcxxx.jar;..\ cfgdb.ConfigDB w

    ' to read configuration from database
    java -classpath ..\..\lib\xcxxx.jar;..\ cfgdb.ConfigTest r
    Under Unix:
    cd <XC_HOME>/examples/cfgdb

    ' to write configuration to database
    java -classpath ../../lib/xcxxx.jar:../ cfgdb.ConfigDB w

    ' to read configuration from database
    java -classpath ../../lib/xcxxx.jar:../ cfgdb.ConfigDB r

©1998-2002 Sunwest Technologies.