com.neeve.config
Class VMConfigurer

java.lang.Object
  extended by com.neeve.config.VMConfigurer

public final class VMConfigurer
extends Object

The Talon VM configurer.

A talon VM is configured using Domain Descriptor Language (ddl). The DDL is defined in x-ddl.xsd schema which can be alternately expressed as a set of hierarchical DDL properties as described below. The VMConfigurer uses the DDL to seed The X Platform's internal configuration repository which is consulted at startup to configure the system.

Ddl Property Format

The DDL property format can be derived from x-ddl schema by converting the xml format to a set of hierarchical properties derived by concatenation the xml model child elements into a '.' separated properties path prefixed by 'x.'. In cases where the a DDL element has a list of child elements the property path is formed by using either the 'name' or 'id' attribute of the child element to form a unique path in cases where the child element has no name or id value then child elements are converted to a list using a numeric identifier for each child element.
The following are examples of converting DDL XML to a properties:
For example:
 <model>
   <env>
     <nv>
       <checked>false</checked>
       <optimizefor>latency</optimizefor>
     </nv>
   </env>
   <apps>
     <app name="OrderProcessing" mainClass="com.acme.OrderProcessingApp">
       <disposeOnSend>true</disposeOnSend>
       <performDuplicateChecking>false</performDuplicateChecking>
     </app>
     <app name="Shipping" mainClass="com.acme.ShippingApp">
       <disposeOnSend>true</disposeOnSend>
       <performDuplicateChecking>true</performDuplicateChecking>
       <messaging>
         <factories>
           <factory>com.example.MessageFactory</factory>
           <factory>com.example.AdminMessageFactory</factory>
         </factories>
       </messaging>
     </app>
   </env>
 </model>
 
would translate to:
 x.env.nv.checked = false
 x.env.nv.optimizefor = latency
 x.apps.OrderProcessing.mainClass=com.acme.OrderProcessingApp
 x.apps.OrderProcessing.disposeOnSend=true
 x.apps.OrderProcessing.performDuplicateChecking=false
 x.apps.Shipping.mainClass=com.acme.ShippingApp
 x.apps.Shipping.disposeOnSend=true
 x.apps.Shipping.performDuplicateChecking=false
 x.apps.Shipping.messaging.factories.1=com.example.MessageFactory
 x.apps.Shipping.messaging.factories.2=com.example.AdminMessageFactory
 

The above allows allows applications to use the DDL xml directly to configure applications, while the property based format allows applications to bind to other configuration mechanisms by converting external config to a set of DDL properties that can be used to configure the platform.


Constructor Summary
VMConfigurer()
           
 
Method Summary
static void configure(File ddlDescriptorXml, UtlStr.ISubstResolver valueResolver)
          Deprecated. use configure(File, PropertySource)
static void configure(File ddlDescriptorXml, UtlTailoring.PropertySource valueResolver)
          Configure the VM using a descriptor file localized using a user supplied value resolver.
static void configure(InputStream ddlDescriptorXml, UtlStr.ISubstResolver valueResolver)
          Deprecated. use configure(File, PropertySource)
static void configure(InputStream ddlDescriptorXml, UtlTailoring.PropertySource valueResolver)
          Configure the VM using a descriptor file from the given stream and the given valueResolver.
static void configure(InputStream ddlDescriptorXml, UtlTailoring.PropertySource valueResolver, Properties ddlOverlayProperties)
          Configure the VM using a descriptor file.
static void configure(Properties ddlProperties)
          Configure the VM using the given DDL properties.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VMConfigurer

public VMConfigurer()
Method Detail

configure

@Deprecated
public static final void configure(InputStream ddlDescriptorXml,
                                              UtlStr.ISubstResolver valueResolver)
                            throws Exception
Deprecated. use configure(File, PropertySource)

Configure the VM using a descriptor file from the given stream and the given valueResolver.

This method is equivalent to call #configure(InputStream, PropertySource)

Parameters:
ddlDescriptorXml - an InputStream containing the contents of the x-ddl to localize.
valueResolver - The substitution values against which to localize the x-ddl.
Throws:
Exception

configure

public static final void configure(InputStream ddlDescriptorXml,
                                   UtlTailoring.PropertySource valueResolver)
                            throws Exception
Configure the VM using a descriptor file from the given stream and the given valueResolver.

This method is equivalent to calling VMConfigurer#configure(ddlDescriptorXml, valueResolver, null)

Note: this call closes the provided stream.

Parameters:
ddlDescriptorXml - an InputStream containing the contents of the x-ddl to localize.
valueResolver - The substitution values against which to localize the x-ddl.
Throws:
Exception

configure

@Deprecated
public static final void configure(File ddlDescriptorXml,
                                              UtlStr.ISubstResolver valueResolver)
                            throws Exception
Deprecated. use configure(File, PropertySource)

Configure the VM using a descriptor file localized using a user supplied value resolver.

This method is equivalent to calling #configure(File, PropertySource)

Parameters:
ddlDescriptorXml - The ddl xml file.
valueResolver - The resolver used as the property source for performing String substitution of ${propName::default} values in the file for overridding element values.
Throws:
Exception

configure

public static final void configure(File ddlDescriptorXml,
                                   UtlTailoring.PropertySource valueResolver)
                            throws Exception
Configure the VM using a descriptor file localized using a user supplied value resolver.

This method is equivalent to calling VMConfigurer#configure(ddlDescriptorXml, valueResolver, null) with file opened as an InputStream.

Parameters:
ddlDescriptorXml - The ddl xml file.
valueResolver - The resolver used as the property source for performing String substitution of ${propName::default} values in the file for overridding element values.
Throws:
Exception

configure

public static final void configure(InputStream ddlDescriptorXml,
                                   UtlTailoring.PropertySource valueResolver,
                                   Properties ddlOverlayProperties)
                            throws Exception
Configure the VM using a descriptor file.

This call localizes the provided ddl xml file using the provided value resolver to perform substitutions on the provided DDL. The ddl then parsed, converted to DDL properties that are augemented by overlaying the ddl Properties provided. The resulting set of properties is then used to configure the system.

Parameters:
ddlDescriptorXml - The ddl xml file.
valueResolver - The resolver used as the property source for performing String substitution of ${propName::default}
ddlOverlayProperties - Additional ddl overlay properties (for example ddl configuration from system properties or the environment). values in the file for overridding element values. s
Throws:
Exception

configure

public static final void configure(Properties ddlProperties)
                            throws Exception
Configure the VM using the given DDL properties.

The provided DDL configuration properties (in DDL property format) are used to configure the system. This configuration method is provided as a means for supporting external configuration mechanisms by allowing an arbitrary configuration format to conform platform config to a set of hierarchical properties that can be translated to platform configuration.

The set of properties can contain values that use substitution variables in the form of ${propName::defaultValue}. For example:

 troubleshooting.enabled=true
 x.apps.OrderProcessing.enableMessageTrace=${troubleshooting.enabled::false}
 
would resolve to:
 troubleshooting.enabled=true
 x.apps.OrderProcessing.enableMessageTrace=true
 

Environment Overrides

The current environment loaded in UtlEnv is used to override values for properties provided and to check for child element or attributes on properties that are already specified in the set of properties passed in. But the environment is not consulted for values that would be supplied as a child element list with a name or id attribute such as a new app or a new bus. This prevents inadvertent addition of additional configuration elements from the environment.

To use the environment properties as a source for new ddl elements such as app or buses it is up to the caller to add those properties to the ddlProperties passed in here by calling UtlEnv.getEnvPropsNoWarn() and adding them to properties supplied here.

Parameters:
ddlProperties - The DDL properties.
Throws:
Exception


Copyright © 2016 Neeve Research, LLC. All Rights Reserved.