Configuring through the ConfigTree

JBoss ESB handles the majority of its configuration through a hierarchical structure similar to the W3C DOM, namely, org.jboss.soa.esb.helpers.ConfigTree. Each node within the structure contains a name, a reference to the parent node, a set of named attributes, and references to all child nodes.

Configuring through the ConfigTree

This structure is used, directly and indirectly, within the implementation of the service pipeline and action processors, and will be required if you are intending to create your own action processors. The only exception to this is when using an annotated action class when the configuring of the action will be handled by the framework instead of programmatically; see the section on Annotated actions in Chapter 4 for more details.

Configuring properties in the jboss-esb.xml file

The ConfigTree instance passed to an action processor is a hierarchical representation of the properties as defined within the action definition of the jboss-esb.xml file. Each property defined within an action may be interpreted as a name/value pair or as hierarchical content to be parsed by the action. For example the following:

<action ....>
  <!-- name/value property -->
  <property name="propertyName" value="propertyValue"/>
  <!-- Hierarchical property -->
  <property name="propertyName">
    <hierarchicalProperty attr="value">
      <inner name="myName" random="randomValue"/>
    </hierarchicalProperty>
  </property>
</action>

This will result in the following ConfigTree structure being passed to the action:

Configuring properties in the jboss-esb.xml file

Traversing the ConfigTree hierarchy

Traversing the hierarchy is simply a matter of using the following methods to obtain access to the parent or child nodes:

public ConfigTree getParent() ;
public ConfigTree[] getAllChildren() ;
public ConfigTree[] getChildren(String name) ;
public ConfigTree getFirstChild(String name) ;

Accessing attributes

Attributes are usually accessed by querying the current ConfigTree instance for the value associated with the required name, using the following methods:

public String getAttribute(String name) ;
public String getAttribute(String name, String defaultValue) ;
public long getLongAttribute(String name, long defaultValue) ;
public float getFloatAttribute(String name, float defaultValue) ;
public boolean getBooleanAttribute(String name, boolean defaultValue) ;
public String getRequiredAttribute(String name)  throws ConfigurationException ;

It is also possible to obtain the number of attributes, names of all the attributes, or the set of key/value pairs using the following methods:

public int attributeCount() ;
public Set<String> getAttributeNames() ;
public List<KeyValuePair> attributesAsList() ;
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset