ExtConfigurator < Jxta < TWiki

TWiki . Jxta . ExtConfigurator

The Confguration Extension, found in the net.jxta.ext.config, aims to unify JXTA Platform configuration related tasks. As such, the initial implementation is comprised largely of existing configuration utilities, namely:

For this initial release no changes where made to the JXTA Platform in how it manages the resulting PlatformConfig. In addition to aggregating various configuration utilitilies, the Configuration Extension aims to be forward looking in anticipation of forthcoming JXTA Platform configuration improvements, including:

In addition to the above, the Configuration Extension provides:

The Configuration Extension does not, as of yet, have a UI element. It is anticipated that any number of UIs can be readily tiered above the current work.

The Configurator's default constructor in addition to the constructors which accept String arguments will look for an existing PlatformConfig residing in the specified JXTA_HOME to use to seed the newly created Configurator instances. If the PlatformConfig can not be found, the profile.xml file will be used. If neither of the files can be found, the Profile.EDGE profile will be used as a seed.

Following are a number of Configuration Extension code samples.

Trivial configuration that will effectively result in a prototypical JXTA Edge configuration:

  try {
    new Configurator("myPrincipal", "myPassword").save();
  } catch (ConfiguratorException ce) {
    ...
  }

One can invoke a number of Configurator setters to generate specific configurations:

  Configurator c = new Configurator();

  c.set(...);

  try{
    c.save(new File(System.getProperty("home.dir")));
  } catch (ConfiguratorException ce) {
    ...
  }

A Profile can be used to seed the defaults:

  Configurator c = new Configurator(Profile.EDGE);

  c.set(...);

  try {
    c.save();
  } catch (ConfiguratorException ce) {
    ...
  }

An existing PlatformConfig can be used to seed the defaults:

  PlatformConfig pc = ...
  Configurator c = new Configurator(pc);

  c.set(...);

  try {
    c.save();
  } catch (ConfiguratorException ce) {
    ...
  }

Lastly, one can register their own "configurator process" within the Platform as follows:

import net.jxta.peergroup.Configurator;
import net.jxta.impl.protocol.PlatformConfig;
import java.io.File;

public class MyConfigurator
implements Configurator {

  public PlatformConfig getPlatformConfig() {
    ...
  }

  public boolean save() {
    return save(null);
  }

  public boolean save(File f) {
    ...
  }

  public void setPlatformConfig(PlatformConfig pc) {
    ...
  }

  public void setReconfigure(boolean r) {
    ...
  }
}

and register the newly minted Configurator:

...
PeerGroupFactory.setConfiguratorClass(MyConfigurator.class);
...

A trivial Configurator implementation can be found in the "JXTA Extention" package as net.jxta.ext.config.TrivialConfigurator.

-- JamesTodd - 21 Nov 2003

----- Revision r3 - 06 Dec 2003 - 03:57:00 - Main.gonzo