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


Add a custom configuration to a BOD service module

For more complex configuration data structures, that cannot be represented as name-value pairs (for example, heavily structured, nested data), you can provide the own configuration file and configuration parser. This requires more work from the developer, but is completely flexible - any kind of configuration file can be read, parsed, and retrieved in the service module Java code.


Procedure

  1. Create the configuration file in WC_EAR\xml\config\servicemodulename-ext\. The file name (not including the file type .suffix) must match the name of the parser class interface you define to read the file. Although the suggested format for the configuration file is XML, any format can be used (remember that you have to write a parser for this file).

    1. If the file format for the configuration file is XML, create an XSD for the configuration file. Place it in the WC_EAR\xml\config\servicemodulename-ext\xsd directory.

  2. Create the interface and implementation classes for parsing the configuration information. The implementation class has to extend from AbstractConfigurationImpl as shown in the example class diagram below. The diagram illustrates a parser class that retrieves custom data from a custom configuration file, using the methods getMapGroups() and getGroupRelationships(), which are arbitrary methods chosen as samples.

    1. Your Java class should implement the interface. Put the methods on the interface that we will need to call to retrieve data in the Java code.

    2. You need to implement the getInterfaceName(), loadConfig(InputStream aConfigFile, Map aConfigMapping), and isOverridable() methods.

  3. Call the new interface in the code. For example:

    String compId = "com.myco.myservicemodule"; ComponentConfiguration config = ComponentConfigurationRegistry.instance().getComponentConfiguration(compId); 
    List configNodes = (List) config.getComponentConfiguration(SampleCustomExtendedConfig.class.getName()); for (int i=0; i<configNodes.size(); i++)
    {
        SampleCustomExtendedConfig sampleConfig = (SampleCustomExtendedConfig) configNodes.get(i);     HashMap mapGroups = sampleConfig.getMapGroups();        
    }
    


+

Search Tips   |   Advanced Search