eXoKernelForGatein3.0

Version 2

    The eXo Kernel has been added several features in order to make the configuration of GateIn 3.0 easier.

    System property configuration

    A new property configurator service has been developed for taking care of configuring system properties from the inline kernel configuration or from specified property files.

     

    The services is scoped at the root container level because it is used by all the services in the different portal containers in the GateIn runtime.

    Init params

    Properties init param

    The properties init param takes a property declared to configure various properties.

    <component>
      <key>PropertyManagerConfigurator</key>
      <type>org.exoplatform.container.PropertyConfigurator</type>
      <init-params>
        <properties-param>
          <name>properties</name>
          <property name="foo" value="bar"/>
        </properties-param>
      </init-params>
    </component>
    

    Properties URL init param

    The properties URL init param allow to load an external file by specifying its URL. Both property and XML format are supported, see the javadoc of the java.util.Properties class for more information. When a property file is loaded the various property declarations are loaded in the order in which the properties are declared sequentially in the file.

     

    <component>
      <key>PropertyManagerConfigurator</key>
      <type>org.exoplatform.container.PropertyConfigurator</type>
      <init-params>
        <value-param>
          <name>properties.url</name>
          <value>classpath:configuration.properties</value>
        </value-param>
      </init-params>
    </component>
    

    System Property configuration of the properties URL

    It is possible to replace the properties URL init param by a system property that overwrites it. The name of that property is exo.properties.url.

    Runtime configuration profiles

    The kernel configuration is able to handle configuration profiles at runtime (as opposed to packaging time).

    Profiles activation

    An active profile list is obtained during the boot of the root container and is composed of the system property exo.profiles sliced according the "," delimiter and also a server specific profile value (tomcat for tomcat, jboss for jboss, etc...).

     

    # runs GateIn on Tomcat with the profiles tomcat and foo
    sh gatein.sh -Dexo.profiles=foo
    
    # runs GateIn on JBoss with the profiles jboss, foo and bar
    sh run.sh -Dexo.profiles=foo,bar
    
    

    Profiles configuration

    Profiles are configured in the configuration files of the eXo kernel.

    Kernel configuration namespace

    To be effective the namespace URI http://www.exoplaform.org/xml/ns/kernel_1_1.xsd or above must be target namespace of the XML configuration file.

    <xsd:schema
         targetNamespace="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
         xmlns="http://www.exoplaform.org/xml/ns/kernel_1_1.xsd"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"
         elementFormDefault="qualified"
         attributeFormDefault="unqualified"
         version="1.0">
    
       ...
    </xsd:schema>
    

    Profiles definition

    Profile activation occurs at XML to configuration object unmarshalling time. It is based on an "profile" attribute that is present on some of the XML element of the configuration files. To enable this the kernel configuration schema has been upgraded to kernel_1_1.xsd. The configuration is based on the following rules:

    1. any kernel element with the no profiles attribute will create a configuration object
    2. any kernel element having a profiles attribute containing at least one of the active profiles will create a configuration object
    3. any kernel element having a profiles attribute matching none of the active profile will not create a configuration object
    4. resolution of duplicates (such as two components with same type) is left up to the kernel

    Profiles capable configuration elements

    A configuration element is profiles capable when it carries a profiles element.

    Component element

    The component element declares a component when activated. It will shadow any element with the same key declared before in the same configuration file:

    <component>
      <key>Component</key>
      <type>Component</type>
    </component>
    
    <component profiles="foo">
      <key>Component</key>
      <type>FooComponent</type>
    </component>
    

    Import element

    The import element imports a referenced configuration file when activated:

    <import>empty</import>
    <import profile="foo">foo</import>
    <import profile="bar">bar</import>
    

    Init param element

    The init param element configures the parameter argument of the construction of a component service:

    <component>
      <key>Component</key>
      <type>ComponentImpl</type>
      <init-params>
        <value-param>
          <name>param</name>
          <value>empty</value>
        </value-param>
        <value-param profiles="foo">
          <name>param</name>
          <value>foo</value>
        </value-param>
        <value-param profiles="bar">
          <name>param</name>
          <value>bar</value>
        </value-param>
      </init-params>
    </component>
    

    Value collection element

    The value collection element configures one of the value of collection data:

    <object type="org.exoplatform.container.configuration.ConfigParam">
      <field name="role">
        <collection type="java.util.ArrayList">
          <value><string>manager</string></value>
          <value profiles="foo"><string>foo_manager</string></value>
          <value profiles="foo,bar"><string>foo_bar_manager</string></value>
        </collection>
      </field>
    </object>
    

    Field configuration element

    The field configuration element configures the field of an object:

    <object-param>
      <name>test.configuration</name>
      <object type="org.exoplatform.container.configuration.ConfigParam">
        <field name="role">
          <collection type="java.util.ArrayList">
            <value><string>manager</string></value>
          </collection>
        </field>
        <field name="role" profiles="foo,bar">
          <collection type="java.util.ArrayList">
            <value><string>foo_bar_manager</string></value>
          </collection>
        </field>
        <field name="role" profiles="foo">
          <collection type="java.util.ArrayList">
            <value><string>foo_manager</string></value>
          </collection>
        </field>
      </object>
    </object-param>