My favorites | Sign in
Project Home Wiki Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
Configuration  
Updated Sep 15, 2010 by denis.ha...@gmail.com

XML configuration file

XML configuration file consists of of a single root element jibe-config and a number of children called configuration elements

<jibe-config xmlns="http://www.icodix.com/jibe/config">
        <properties-config>
             ....
        </properties-config>
        <form-def id="repo.nodeProperties">
		.....
	</form-def>
	<form-def id="repo.nodePropertiesEdit">
		....
	</form-def>
	<form-def id="repo.nodePropertiesEdit" condition="type:'cm:content'">
		....
	</form-def>
        <form-def id="repo.nodePropertiesEdit" condition="group:'GROUP_Some group'" replace="true">
		....
	</form-def>
</jibe-config>

Configuration element

Configuration element is a child of jibe-core element in xml configuration file. Each configuration element can have following attributes

There is XML schema existing and can be found within jibe-core project.
Attribute Description
id Identification of configuration element. This attribute is not mandatory and, if left out, configuration element will be considered as anonymous configuration element
condition Condition expression which has to be satisfied in order to consider this configuration element during configuration evaluation. Configuration evaluation algorithm will be explained subsequently
replace Boolean attribute which defines whether this configuration element will replace configuration element with the same id and condition satisfied or combination will be attempted

Configuration evaluation

In order to fully exploit the potential of the framework, it is important to understand how the configuration is evaluated. All registered xml configuration files are parsed in the order of registration. The result of parsing is a list of all configuration elements defined in registered configuration files. This list is indexed with two keys, configuration element name and id attribute. In order to explain how configuration elements are fetched, we will use a small example.

Configuration service is usually queried with this type of query.

Give me form-def configuration element which has id="repo.nodePropertiesEdit
Looking at the configuration snippet above the result of such query will be three configuration elements.

<form-def id="repo.nodePropertiesEdit">
		....
</form-def>
<form-def id="repo.nodePropertiesEdit" condition="type:'cm:content'">
		....
</form-def>
<form-def id="repo.nodePropertiesEdit" condition="group:'GROUP_Some group'" replace="true">
		....
</form-def>

The next step will be iteration over results and merging using the algorithm explained in the pseudo code bellow.

Set result to null
FOR each element in configuration elements list
    IF element has condition attribute THAN
         IF element condition is satisfied THAN
                IF result is not null THAN
                      IF element has replace attrribute THAN
                            set result to combine(result,element)
                      ELSE
                          set result to element
                      END IF
                ELSE
                      set result to element
                END IF
         END IF
    ELSE
         IF result is not null
               IF element has replace attrribute THAN
                     set result to combine(result, element)
               ELSE
                     set result to element
               END IF
         ELSE
               set result to element
         END IF
    END IF     
END FOR

As we can see from the pseudo code, if condition is satisfied and replace attribute is not true, two configuration elements will be combined into single configuration element.

Combination of configuration elements

Component definition configuration element

This configuration element is responsible to describe ExtJs component definition in JSON format. This component definition will be sent to client and used to instantiate and render ExtJs component. More details about different component configuration options can be found in ExtJs documentation. In order to explain how exactly is definition JSON created from xml configuration a simple example will be used. This is a definition of initial viewport taken from the quick start guide.

<component-def id="core.viewPort" replace="true">
    <xtype>viewport</xtype>
    <layout>absolute</layout>
    <items>
	<component id="todoTasks">
              <xtype>panel</xtype>
	      <pageX>20</pageX>
	      <pageY>20</pageY>
	      <width>300</width>
	      <height>300</height>
	      <html>Hello from Jibe component</html>
	</component>
     </items>
</component-def>

After rendering process the resulting json will look like this

{
    "xtype" : "viewport",
    "layout" : "absolute",
    "items" : [{
	"xtype" : "panel",
	"pageX" : 20,
	"pageY" : 20,
	"width" : 300,
	"height" : 300,
	"html" : "Hello from Jibe component",
	"id" : "todoTasks"
    }]
}

As we can see, the structure of resulting JSON and xml configuration is pretty similar with few exceptions. Children of items property are rendered as JSON array, and component element is completely missing and id attribute is added as id property. These differences are result of rendering algorithm which will be explained bellow.

Recursively, each child of component-def element is processed. Each processed element appends the result to the JSON stream. What will be the nature of processing depends on the param-templates which can be found in /org.jibeframework.core/src/main/resources/config/configuration-config.xml, just search for the param-templates element.

Each param template can define the following for the corresponding element

class Definition of which class will be instantiated as param representation. If null, org.jibeframework.core.ui.param.SimpleParam will be used
quoted if true, value of element will be enclosed in quotes
handler Defines the @ParamHandler annotated method which will be invoked in order to provide content

Returning to the example above, we can see that items element has a handler defined with value core.items. Therefore, to provide content of the item property method org.jibeframework.core.app.controller.ParamHandlers.handleItems(BaseParam) will be invoked.

It is also possible to override values defined in param-templates in the component definition

<items handler="my.itemsHandler">
	<component id="todoTasks">
              <xtype>panel</xtype>
	      <pageX>20</pageX>
	      <pageY>20</pageY>
	      <width>300</width>
	      <height>300</height>
	      <html>Hello from Jibe component</html>
	</component>
     </items>

Component element which is represented by org.jibeframework.core.ui.param.ComponentParam deserves a bit more explanation. It represent child components and can accept following attributes

idThe value specified will become client component id. If omitted generated id value will assigned to the component
methodIdentification of @Component annotated java or groovy method which will be invoked before component is rendered and can alter component definition
definition Referenced component definition will be used as a prototype to construct component and children of component element will override prototype elements
templateFreemarker or groovy template which will be used to render JSON. Children elements will be used as a model for the template evaluation

Powered by Google Project Hosting