DConfig 
SourceForge.net Logo PHP Logo

Dynamic Configuration Toolkit

Getting Started

1. Prerequisites
2. Run Desktop DConfig GUI Editor
3. Run Web Demo
4. Build and Run from Source Code
5. A Quick Start Java Example

To get started with DConfig, the easiest way is to run the precompiled examples or build from source code.

1. Prerequisites      

JDK - Java SE 5.0 is required, which can be downloaded from http://java.sun.com/javase/downloads/index.jsp.

2. Run Desktop DConfig GUI Editor      

Download dconfig*-bin.zip
unzip the file to a local folder. Open a terminal or command window.

For Linux,

cd /path/to/unzipped/folder
cd dconfig-ui
chmod u+x *.sh

./dconfig-ui.sh demo derby	Run DConfig GUI Editor as demo mode with embedded Derby database.
                                No database setup is needed.

./dconfig-ui.sh demo hsqldb	Run DConfig GUI Editor as demo mode with embedded Hsqldb database.
                                No database setup is needed.

./dconfig-ui.sh demo h2         Run DConfig GUI Editor as demo mode with embedded H2 database.
                                No database setup is needed.

./dconfig-ui.sh                 Run DConfig GUI Editor (need database setup,
                                see Database Setup section)

For Windows,

cd \path\to\unzipped\folder
cd dconfig-ui

dconfig-ui.bat demo derby	Run DConfig GUI Editor as demo mode with embedded Derby database.
                                No database setup is needed.

dconfig-ui.bat demo hsqldb	Run DConfig GUI Editor as demo mode with embedded Hsqldb database.
                                No database setup is needed.

dconfig-ui.bat demo h2          Run DConfig GUI Editor as demo mode with embedded H2 database.
                                No database setup is needed.

dconfig-ui.bat                  Run DConfig GUI Editor (need database setup,
                                see Database Setup section)

When the DConfig GUI Editor starts up, you should see something like this:
Dconfig-Getting-Started

verbose, an optional command line argument, can be issued when running as demo mode. Additional information will be shown on the command console while the Editor is running.

For Linux,

./dconfig-ui.sh demo derby verbose
./dconfig-ui.sh demo hsqldb verbose
./dconfig-ui.sh demo h2 verbose

For Windows,

dconfig-ui.bat demo derby verbose
dconfig-ui.bat demo hsqldb verbose
dconfig-ui.bat demo h2 verbose

3. Run Web Demo      

This demo shows how DConfig integrates with web application. Please look at Web Demo for dedtails.

4. Build and Run from Source code      

ANT Build Tool - In order to compile the project or to run the sample applications from source code, you need to have the ANT build tool 1.6.5 or later installed on your system.

You can get a copy of this tool and details about how to use it at this address: http://ant.apache.org/.

There are several ANT specific tasks inside the build.xml file. Each task has a description explaining what it does and the list of all available tasks inside the build.xml file can be obtained by launching "ant -p" from the command line.

ant -p

Buildfile: build.xml

Main targets:

 all          Default target, call clean, ui-jnlp, webdemo, javadoc, db
 clean        Removes build artifacts
 compile-lib  Compile lib module
 compile-ui   Compile ui modules
 db           Copy dconfig-db to dist/dconfig-db
 deploy       Deploy dconfig-webdemo.war to deploy.home defined in build.properties, default to Tomcat
 javadoc      Call javadoc-lib, javadoc-ui
 javadoc-lib  Create DConfig lib javadoc
 javadoc-ui   Create DConfig ui javadoc
 lib          Alias for package-lib
 package-lib  Package library modules
 run          Run GUI Editor without demo database
 run-derby    Run GUI Editor with embedded Derby database
 run-h2       Run GUI Editor with embedded H2 database
 run-hsqldb   Run GUI Editor with embedded Hsqldb database
 ui           Alias for package-ui
 ui-jnlp      Create DConfig-UI JNLP Web Package
 webdemo      Create WEB Demo dconfig-webdemo.war file
Default target: all

Download dconfig*-src.zip
unzip the file to a local folder. Open a terminal or command window.

cd /path/to/unzipped/folder (Linux)
cd \path\to\unzipped\folder (Windows)

ant run-derby	                Build and run DConfig GUI Editor as demo mode with embedded Derby database.
                                No database setup is needed.

ant run-hsqldb	                Build and run DConfig GUI Editor as demo mode with embedded Hsqldb database.
                                No database setup is needed.

ant run-h2                      Build and run DConfig GUI Editor as demo mode with embedded H2 database.
                                No database setup is needed.

5. A Quick Start Java Example      

Copy dconfig-1.x-src/dist/dconfig-lib/*.jar or dconfig-1.x-bin/dconfig-lib/*.jar to classpath or WEB-INF/lib.

Source 1. A Quick Start Java Example

#import org.moonwave.dconfig.dao.CacheManager;
#import org.moonwave.dconfig.dao.DConfigReader;
#import org.moonwave.dconfig.dao.DConfigWriter;

//Load or reload DConfig configuration data into memory
CacheManager.load();

//Read data from 
String value = DConfigReader.getString("yourKeyName", "yourAttributeName", "defaultValue");
String pageTitle = DConfigReader.getString("config.view.page1", "title", "DConfig Web Demo");
int numRowsPerPage = DConfigReader.getInteger("config.view.page1", "#Rows Per Page", 10);

//Write an attribute to database
int rowsPerPage = 8;
DConfigWriter.writeInteger("config.view.page1", "#Rows Per Page", rowsPerPage);

//Shut down the cache manager
CacheManager.unload();