Format of XML configuration files
All services described here can be configured using XML files that follow a specific format. This will be described in more detail below.
The basis of the XML files is the file configure_1_3.dtd, which is located in the directory ./etc/dtd of the Integration Server. The special feature of this type of XML is that the XML entries are converted into method calls of the corresponding class at runtime.
Following the available commands.
Command |
Description |
Set |
Calls a set method of the current instance. |
Put |
Writes a mapping in the current map. |
Call |
Calls a method of the current instance. |
New |
Creates a new instance of a class. |
Get |
Calls a get method of the current instance. |
XML file body
<!DOCTYPE Configure PUBLIC
"-//EBD Integration//DTD Configure 1.0//EN"
"
http://www.lobster.de/dtd/configure_1_1.dtd
">
<
Configure
class
=
"[name of the class to be configured]"
>
[commands for the configuration]
</
Configure
>
The class name is the fully qualified class name, including the package.
"Set"
The Set command calls a single set method of the current instance. The argument specifies the value to be set. Since set methods are allowed to have only one argument, the Arg tag is omitted here. The value to be set is passed as the value of the XML tag. So if a class has the method
public void setName(String val); |
defined, the XML call would look like this.
<
Set
name
=
"name"
>value</
Set
>
As you can see, the value for the name attribute is the method name without the preceding set, with the first letter after the set in the method name always being lowercase.
If there are several set methods with the same name and different type, or if the type of the set method is not string, the type of the transferred value should always be specified explicitly. This is done via the attribute type, which can have the following values.
int |
The primitive type int. |
boolean |
The primitive type boolean. |
long |
The primitive type long. |
float |
The primitive type float. |
double |
The primitive type double. |
short |
The primitive type short. |
If a class has the method
public void setPort(int val); |
defined, the XML call would look like this.
<
Set
name
=
"port"
type
=
"int"
>25</
Set
>
"Put"
The Put command expects the current instance to have a method like the following.
public void put(Object key, Object val); |
The key in this call is set via the name attribute and the value to be set is the value of the XML tag. The XML call would look like the following.
<
Put
name
=
"key"
>Value</
Set
>
Since the method itself only accepts instances of objects and not primitive types, it is not possible to specify the attribute type in this context.
"Call"
The call command can call any method with any number of parameters. So for example, the method call
public void put(Object key, Object value); |
would look like this in the XML configuration file.
<
Call
name
=
"put"
>
<
Arg
>key</
Arg
>
<
Arg
>value</
Arg
>
</
Call
>
If individual parameters have a primitive type, then, as described for Set, this must be specified using the attribute type for the respective argument.
"New"
The New command can be used to create a new instance of the specified class. If you want to use a different constructor than the default constructor, pass the corresponding parameters as Arg elements. Based on the order and types of arguments, the matching constructor is automatically used for initialisation.
If further commands are inserted within the New section, they refer to the newly created instance.
If, for example, an ArrayList with an initial size of 10 elements is to be created and you want to add two texts, this can be done with the following XML fragment.
<
New
class
=
"java.util.ArrayList"
>
<
Arg
type
=
"int"
>10</
Arg
>
<
Call
name
=
"add"
>
<
Arg
>Text1</
Arg
>
</
Call
>
<
Call
name
=
"add"
>
<
Arg
>Text2</
Arg
>
</
Call
>
</
New
>
This XML fragment would typically be found within an argument of a Set command calling a method that in turn expects a list as a parameter.
"Get"
The Get command calls a get method of the current instance. If more commands are added within the Get command, they refer to the returned object. The name of the method in the XML is formed equivalent to the Set command, i.e. the get is omitted and the first letter of the rest is converted to a lowercase letter.
So for example, if you have elements within a linked list that are also lists, fetching the first element and adding text to that element would be done with the following XML fragment.
<
Get
name
=
"first"
>
<
Call
name
=
"add"
>
<
Arg
>New text</
Arg
>
</
Call
>
</
Get
>
Further commands
In addition to the commands already mentioned, further tags are possible, which are mainly used within the specification of arguments.
Array |
Used to pass an array of the specified type. The individual elements are transferred via the Item tag. The type of the array is set via the type attribute, whereby the fully qualified class name must be specified for arrays of objects. |
SystemProperty |
Calls the method System.getProperty. The property to be read is set via attribute name. A default value can be set with attribute default. |