Notifications
Clear all

[Solved] How to add a module specific InstanceConfig?

1 Posts
2 Users
3 Reactions
1,148 Views
1
Topic starter

In InstanceConfig file, default xml schema contains 'PlatformInstanceConfig'. How can I add a ModuleInstanceConfig that is specific to the module?

Example:

<FINInstanceConfig xmlns="http://www.financials.onenetwork.com/Financials" xmlns:vc="http://www.onenetwork.com/Platform"></FINInstanceConfig>
1 Answer
3

When you create a new Module, it will have a file in the xsd directory called ModuleInstanceConfig.xsd. For example, it looks like this in Showcase:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" jxb:extensionBindingPrefixes="parentnav" jxb:version="2.1" targetNamespace="http://www.onenetwork.com/Showcase" xmlns="http://www.onenetwork.com/Showcase" xmlns:fnc="xalan://com.transcendsys.tools.ant.AntXsltFunctions" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:parentnav="http://www.onenetwork.com/jaxb/ParentNav" xmlns:vc="http://www.onenetwork.com/Platform" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://www.onenetwork.com/Platform" schemaLocation="../build/OneNetworkFull.xsd"/>
  <xs:element name="SHOInstanceConfig" type="SHOInstanceConfig" substitutionGroup="vc:ModuleInstanceConfig"/>
  <xs:complexType name="SHOInstanceConfig">
    <xs:complexContent>
      <xs:extension base="vc:ModuleInstanceConfig">
        <xs:sequence>
        <!-- Please configure your app specific configuration elements here. This will allow you to configure things that are 
        global to the instance. You will have to specify these elements in ModuleInstanceConfig.xml.template in the app and build/installer
        would take care of merging all ModuleInstanceConfigs. If you want property replacements than define those properties in build.properties
        and specify defaults there. During Installer you can than override them in node.properties.
        In Code you can use InstanceConfigManager.getInstance().getModuleInstanceConfig method to get the config.-->
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType> 
</xs:schema>

You can customize this with your own schema, and modify also ModuleInstanceConfig.xml.template in your module root directory with default values.
Or may also use <%some.variable%> substitution in ModuleInstanceConfig.xml.template and define the default values in build.properties.

To retrieve the property in java see the folowing example for the LMCM module:

ModuleService modServ = Services.get(ModuleService.class);
LMCMInstanceConfig instCfg = modServ.getModuleInstanceConfig(LMCMInstanceConfig.class)

You will have to replace LMCM with your module prefix.