WSO2Con 2013 CFP Banner

How do I create a ConfigurationContext from a source other than a file system?

By Eran Chinthaka
Date: Tue, 25th Jul, 2006
Reads: 7059 Discuss this article on Stack Overflow
chinthaka's picture
Eran Chinthaka
Software Engineer
WSO2 Inc.

ConfigurationContext is the heart of Apache Axis2 engine's runtime configuration. The behaviour of Axis2 engine can be controlled using properties and parameters in its ConfigurationContext. A ConfigurationContext is usually initialized with the static information loaded through AxisConfiguration.

The easiest way to create an AxisConfiguration is by using a file system based resource like axis2.xml. Since this is the widely used method of creating a ConfigurationContext, Axis2's ConfigurationContextFactory has an in-built convenience method to create an instance of ConfigurationContext from a file. How is this done? Just see below.

ConfigurationContext configContext = ConfigurationContextFactory.
(pathToRepository, pathToAxis2xml);

Axis2 has other choices for loading AxisConfiguration as well. It is possible to write a custom AxisConfigurator for example, to load it from a database by writing a class that implements the AxisConfigurator interface.

public interface AxisConfigurator {

* Configurationcontextfactory will invoke this method to get
the AxisConfiguration
* @return AxisConfigurator
AxisConfiguration getAxisConfiguration() throws AxisFault;

* Method to deploy services from the repository
void loadServices();

* Engages the global modules specified in the configuration
* @throws AxisFault
void engageGlobalModules() throws AxisFault;

Axis2 also has three built-in AxisConfigurators, namely:

  1. FileSystemConfigurator - Loads information from file system based resources
  2. WarBasedConfigurator - Loads information when its deployed in a web container.
  3. URLBasedAxisConfigurator - Loads information when the repository is accessed through a remote URL.

Once you have implemented your own AxisConfigurator, say MyAxisConfigurator, you can simply use it by calling the createConfigurationContext(AxisConfigurator) method.

ConfigurationContext configContext = ConfigurationContextFactory.
createConfigurationContext(new MyAxisConfigurator());

Applies To:

Apache Axis2/Java 1.0
WSO2Con 2014