6.4. InitParams configuration object

InitParams are the configuration object that is essentially a map of key-value pairs, where key is always a String, and value can be any type that can be described using the kernel configuration.xml file.

Service components that form GateIn 3.5 infrastructure use the InitParams object to configure themselves. A component can have one instance of InitParams injected at most. If the service component's constructor takes InitParams as any of the parameters, it will automatically be injected at the component instantiation time. The xml configuration for a service component that expects the InitParams object must include the <init-params> element (even if the empty one).

To learn about how the kernel xml configuration syntax looks for creating InitParams instances, see the following example.

Example: InitParams - properties-param

           <description>Default initial context properties</description>
           <property name="java.naming.factory.initial"
                    value="org.exoplatform.services.naming.SimpleContextFactory" />

The InitParams object description begins with the <init-params> element. It can have zero or more children elements, each of which is one of <value-param>, <values-param>, <properties-param>, or <object-param>. Each of these child elements takes a <name> that serves as a map entry key, and an optional <description>. It also takes a type-specific value specification.

For <properties-param>, the value specification is in the form of one or more <property> elements, each of which specifies two strings - a property name, and a property value. Each <properties-params> defines one java.util.Properties instance. Also, see Example: HibernateService using variables for an example.

Example: InitParams - value-param


For <value-param>, the value specification is in the form of <value> element, which defines one String instance.

Example: InitParams - values-param

          <description>The resources  that start with the following package name should be load from file system</description>

          <description>Store the following resources into the db for  the first launch </description>

          <description>The properties files of  the portal ,  those file will be merged
            into one ResourceBundle properties </description>

For <values-param>, the value specification is in the form of one or more <value> elements, each of which represents one String instance, where all the String values are then collected into a java.util.List instance.

Example: InitParams - object-param

           <description>The default cache configuration</description>
           <object type="org.exoplatform.services.cache.ExoCacheConfig">
              <field name="name">
              <field name="maxSize">
              <field name="liveTime">
              <field name="distributed">
              <field name="implementation">

For <object-param>, the value specification comes in a form of the <object> element, which is used for the POJO style object specification (you specify an implementation class - <type>, and property values - <field>).

Also see Example: Portal container declaration for an example of specifying a field of the Collection type.

The InitParams structure - the names and types of entries is specific for each service, as it is the code inside service components' class that decides what entry names to look up and what types it expects to find.

See also

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus