Grammar
CONFIGURE.DTD
This document type descriptor indicates a simple insinuation between the XML element and the Java API, and the first line of the Jetty.xml configuration file must refer to the DTD as follows:
<?xml version= "1.0" encoding= "Iso-8859-1"?>
<! DOCTYPE Configure Public "-//mort Bay consulting//dtd configure//en" "Http://jetty.mortbay.org/configure.dtd" >
Java objects are configured by a series of <new>, <set>, <Put> and <Call> elements. The following example gives you a rudimentary understanding of:
<set name= "Test" >value</Set> = = Obj.settest ("value");
<put name= "Test" >value</Put> = = Obj.put ("Test", "value");
<call name= "Test" ><Arg>value</Arg></Call> = = Obj.test ("value");
<new class= "Com.acme.MyStuff" ><Arg/></New> = = New Com.acme.MyStuff ();
Make the best effort to match the parameters in the method with the value, and specify the type. The Org.mortbay.util.XmlConfiguration class uses the CONFIGURE.DTD descriptor to parse the jetty XML file.
<Configure> Elements
This root element is used to specify the object class to configure:
<configure class= "Org.mortbay.jetty.server> ... </Configure>
In addition, if the object already exists and declares an ID, then he can be referenced in the configuration element as follows:
<configure id= "Server" class= "Org.mortbay.jetty.Server" >
configuration element containsNew,Set, put, CallOrRefElements.
<Set> Elements
This element alludes to the invocation of an object set method. Name and optional attributes are used to select the Set method. If the name is XXX, then setxxx is used and the latter method cannot be found. A set element can contain value text or value elements call, New, and Systemproperty. If the value type is undefined, the value is truncated from the space. If a multivalued element is included, it is added as a string before being converted to the specified type. A set comes with a class property that is called as a static set method.
View plain Copy to clipboard print? <set name= "xyz" > ... </Set>
<set name= "xyz" > ... </Set>
<Get> Elements
This element alludes to the invocation of an object get method. Property names are used to select a Get method. If the name is XXX, then getxxx will be used or cannot be found. A GET element can contain objects returned by a set, put, or call element.
View plain Copy to clipboard print? <get name= "xyz" > <set name= "xyzmethod" ><new class= "org.mortbay.jetty.xyz"/></set>
</Get>
<get name= "xyz" > <set name= "xyzmethod" ><new class= "org.mortbay.jetty.xyz"/></set> </get >
A get and a class attribute is treated as a static get method or field.
<Put> Elements
This element alludes to the invocation of the current object's put method, which must have the map interface applied. A property name is used as the key to put, and an optional type property is used to determine the type of the value. A put element can contain text values or value elements call, New, and Systemproperty. If no type is specified, the value is truncated at the space. If a multivalued element is included, it is treated as a string before being converted to the specified type.
<put name= "Admin" >admin</Put>
<Call> Elements
This element alludes to the arbitrary invocation of a method of the current object, and the attribute name and arg elements are used to determine the method. A call element can contain a series of ARG elements that follow a series of set, put, or call elements that are acting on a new object.
<call name= "Test" >
<Arg>value1</Arg>
<set name= "Test" >Value2</Set>
</Call>
Equivalent to:
Object O2 = O1.test ("value1");
O2.settest ("value2");
A call with the class attribute is treated as a static invocation:
<call class= "Com.acme.Foo" name= "setstring" >
<Arg>somestring</Arg>
</Call>
Equivalent to:
Com.acme.Foo.setString ("somestring");
<Arg> Elements
This element defines a positional parameter for the call element, and an optional type attribute is used to determine the type of the value. An ARG element can contain literal values or value elements call, New, and Systemproperty. If the value type is not specified, the value is truncated from the space. If it is a multivalued element, it is treated as a string before being converted to a specific type.
<arg><ref id= "Server"/></arg>
<Arg>./webapps</Arg>
<Arg>org/mortbay/jetty/webapp/webdefault.xml</Arg>
<arg type= "Boolean" >True</Arg>
<arg type= "Boolean" >False</Arg>
The ref tag here points to an object that has previously specified an ID parameter.
<New> Elements
This element generates a new object that uses a set, put, or ARG element as a value. The class attribute determines the properties of the new object and contains the ARG element used to make the value of the new object builder.
A new element can contain a unique ID parameter that can later be used to reference it. A new element contains a series of ARG elements that follow a series of set, put, and call elements that are acting on the new object:
View plain Copy to clipboard print? <new id= "MyObject" class= "Com.acme.MyClass" > <arg>value1</arg><set "Test" name= Set> </New> [code] is equivalent to: [code] Object o = New com.acme.MyClass ("value1"); O.settest ("value2");
<new id= "MyObject" class= "Com.acme.MyClass" > <arg>value1</arg><set "Test" name= Set> </New> [code] is equivalent to: [code] Object o = New com.acme.MyClass ("value1"); O.settest ("value2");
<Ref> Elements
This element references a previously generated object, and a REF element contains a series of set, put, and call elements acting on the Reference object:
View plain Copy to clipboard print? <ref id= "MyObject"/> <set name= "Test" >Value2</Set> </Ref>
<ref id= "MyObject"/> <set name= "Test" >Value2</Set> </Ref>
In addition, a ref element can be used to make values for ARG and Set elements:
View plain Copy to clipboard print? <set name= "SomeMethod" ><ref id= "MyObj"/></set>
<set name= "SomeMethod" ><ref id= "MyObj"/></set>
<Array> Elements
This element allows a new array to be generated as a value for set, put, or Arg elements. The type of the property determines the type of the array.
View plain Copy to clipboard print? <array type= "java.lang.String" > <Item>value0</Item> <item><new class= "Java.lang.Strin" G "><Arg>value1</Arg></New></Item> </Array>
<array type= "java.lang.String" > <Item>value0</Item> <item><new class= "Java.lang.String" ><Arg>value1</Arg></New></Item> </Array>
Equivalent to:
View plain Copy to clipboard print? String[] A = new string[]{"Value0", New String ("Value1")};
String[] A = new string[]{"Value0", New String ("Value1")};
<Map> Elements
This element allows a new hashmap to be generated, using the key, the value team:
View plain Copy to clipboard print? <Map> <Entry> <Item>keyName</Item> <item><new class= "java.lang.String" &G T;<arg>value1</arg></new></item> </Entry> </Map>
<Map> <Entry> <Item>keyName</Item> <item><new class= "java.lang.String" >< arg>value1</arg></new></item> </Entry> </Map>
Equivalent:
View plain Copy to Clipboard print? Java.util.Map Map = new Java.util.HashMap (); map.put ("KeyName", "value1"};
Java.util.Map Map = new Java.util.HashMap (); Map.put ("KeyName", "value1"}; The
<Item> element
element defines an array or an entry for a map entry element, and the optional type attribute determines the worthy type. An item element can contain text values or value elements call, new, and Systemproperty. If the value type is not specified, the value is truncated at the space. If it is a multivalued element, it is treated as a string before being converted to a specific type.
View plain Copy to clipboard print? <Item> <new class= "Org.mortbay.jetty.nio.Sele Ctchannelconnector "> <set name=" Port ">8080</Set> <set name= "MaxIdleTime" >30000</Set> < Set name= "acceptors" >10</Set> </New> </Item>
<Item> <new class= "Org.mortbay.jetty.nio.SelectChannelConnector" > <set name= "Port" >8080</ set> <set name= "MaxIdleTime" >30000</Set> <set name= "acceptors" >10</Set> </New> < /item>
<SystemProperty> element
This element allows JVM system properties to be values of set, put, or arg elements. The Name property indicates the property name, and the optional default parameter provides a default value of
This element allows JVM System properties to is retrieved as part of the value of a Set. or ARG element. The name attribute specifies the property name and the optional default argument provides a default value.
<systemproperty name= "test" default= "value"/>
is equivalent to:
System.getproperty ("Test", " Value ");