Adding a custom configuration to a BOD service module
For more complex configuration data structures, that cannot easily be represented as name-value pairs (for example, heavily structured, nested data), you can provide your 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 your service module Java code.
Procedure
-
Create your configuration file in
workspace_dir\WC\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).
- If the file format for your configuration file is XML, create an XSD for your configuration file. Place it in the workspace_dir\WC\xml\config\servicemodulename-ext\xsd directory.
- 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 methodsgetMapGroups()
andgetGroupRelationships()
, which are arbitrary methods chosen as samples.- Your Java class should implement your interface. Put the methods on the interface that you will need to call to retrieve data in your Java code.
- You need to implement the
getInterfaceName()
,loadConfig(InputStream aConfigFile, Map aConfigMapping)
, andisOverridable()
methods.
- Call your new interface in your code.
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(); }