Develop > Business logic layer > Developing the business logic layer using the BOD command framework > Work with WebSphere Commerce service modules > Configure a BOD service module


Extend the configuration of a service module to add name-value parameters

The simplest way to quickly add configuration data to a BOD service module is to extend the default WebSphere Commerce configuration file. No parser code needs to be written, you just need to provide the parameters in an XML file, and then retrieve them in the Java code.

Because the configuration data is structured as name-value pairs, the following restrictions apply:

To add configuration data as name-value pairs to a service module:


Procedure

  1. Create a file called wc-component.xml in the WC_EAR\xml\config\servicemodulename-ext\ directory, where servicemodulename is the name of the WebSphere Commerce or custom service module.

  2. Paste the following XML into the file:

    <_config:DevelopmentComponentConfiguration 
        xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-component.xsd">         <_config:extendedconfiguration>             <_config:configgrouping name="MyConfigurationGroup">                 <_config:property name="myName" value="myValue"/>             </_config:configgrouping>         </_config:extendedconfiguration>
    </_config:DevelopmentComponentConfiguration >
    

    where MyConfigurationGroup is a name for a logical grouping of configuration data, and myName and myValue is the name-value pair to add.

  3. In the service module Java code, you can access the configuration data using Java code similar to the following example:

    String compId = "com.myco.myservicemodule"; ComponentConfiguration config = ComponentConfigurationRegistry.instance().getComponentConfiguration(compId); 
    List configNodes = (List) config.getComponentConfiguration(ExtendedConfigurationConfigNode.class.getName(), null); 
    for (int i=0; i<configNodes.size(); i++)
    {
        ExtendedConfigurationConfigNode extendedConfig = (ExtendedConfigurationConfigNode) configNodes.get(i);     HashMap configMap = (HashMap) extendedConfig.getConfigSection("MyConfigurationGroup");     String customNewConfigMyValue = (String) configMap.get("myName");             
    }
    

    Note how the MyConfigurationGroup and MyName strings are used to retrieve the configuration values.


+

Search Tips   |   Advanced Search