User: olegnitz
Date: 02/02/10 09:57:47
Modified: jetty/src/main/org/mortbay/xml XmlConfiguration.java
XmlParser.java configure_1_0.dtd configure_1_1.dtd
Added: jetty/src/main/org/mortbay/xml configure_1_2.dtd
Log:
Fresh version of Jetty and patches to Jetty plugin by Jan Bartel
Revision Changes Path
1.2 +83 -8 contrib/jetty/src/main/org/mortbay/xml/XmlConfiguration.java
Index: XmlConfiguration.java
===================================================================
RCS file:
/cvsroot/jboss/contrib/jetty/src/main/org/mortbay/xml/XmlConfiguration.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XmlConfiguration.java 17 Jan 2002 01:23:23 -0000 1.1
+++ XmlConfiguration.java 10 Feb 2002 17:57:46 -0000 1.2
@@ -1,11 +1,12 @@
// ========================================================================
// Copyright (c) 1999 Mort Bay Consulting (Australia) Pty. Ltd.
-// $Id: XmlConfiguration.java,v 1.1 2002/01/17 01:23:23 olegnitz Exp $
+// $Id: XmlConfiguration.java,v 1.2 2002/02/10 17:57:46 olegnitz Exp $
// ========================================================================
package org.mortbay.xml;
import java.io.IOException;
+import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
@@ -30,7 +31,7 @@
* methods on the object.
*
* @see configure.dtd
- * @version $Id: XmlConfiguration.java,v 1.1 2002/01/17 01:23:23 olegnitz Exp $
+ * @version $Id: XmlConfiguration.java,v 1.2 2002/02/10 17:57:46 olegnitz Exp $
* @author Greg Wilkins (gregw)
*/
public class XmlConfiguration
@@ -65,12 +66,26 @@
if (__parser==null)
{
__parser = new XmlParser();
- Resource config11Resource=Resource.newSystemResource
- ("org/mortbay/xml/configure_1_1.dtd");
-
+ Resource config12Resource=Resource.newSystemResource
+ ("org/mortbay/xml/configure_1_2.dtd");
+ Code.assertTrue(config12Resource.exists(),
+ "org/mortbay/xml/configure_1_2.dtd");
__parser.redirectEntity
- ("configure.dtd",config11Resource);
-
+ ("configure.dtd",config12Resource);
+ __parser.redirectEntity
+ ("configure_1_2.dtd",
+ config12Resource);
+ __parser.redirectEntity
+ ("http://jetty.mortbay.org/configure_1_2.dtd",
+ config12Resource);
+ __parser.redirectEntity
+ ("-//Mort Bay Consulting//DTD Configure 1.2//EN",
+ config12Resource);
+
+ Resource config11Resource=Resource.newSystemResource
+ ("org/mortbay/xml/configure_1_1.dtd");
+ Code.assertTrue(config11Resource.exists(),
+ "org/mortbay/xml/configure_1_1.dtd");
__parser.redirectEntity
("configure_1_1.dtd",
config11Resource);
@@ -82,7 +97,9 @@
config11Resource);
Resource config10Resource=Resource.newSystemResource
- ("org/mortbay/xml/configure_1_1.dtd");
+ ("org/mortbay/xml/configure_1_0.dtd");
+ Code.assertTrue(config10Resource.exists(),
+ "org/mortbay/xml/configure_1_0.dtd");
__parser.redirectEntity
("configure_1_0.dtd",
config10Resource);
@@ -526,6 +543,62 @@
/* ------------------------------------------------------------ */
+ /* Create a new value object.
+ *
+ * @param obj
+ * @param node
+ * @return
+ * @exception NoSuchMethodException
+ * @exception ClassNotFoundException
+ * @exception InvocationTargetException
+ */
+ private Object newArray(Object obj,XmlParser.Node node)
+ throws NoSuchMethodException,
+ ClassNotFoundException,
+ InvocationTargetException,
+ IllegalAccessException
+ {
+ // Get the type
+ Class aClass = java.lang.Object.class;
+ String type = node.getAttribute("type");
+ if (type!=null)
+ {
+ aClass=Primitive.fromName(type);
+ if (aClass==null)
+ {
+ if ("String".equals(type))
+ aClass=java.lang.String.class;
+ else if ("URL".equals(type))
+ aClass=java.net.URL.class;
+ else if ("InetAddress".equals(type))
+ aClass=java.net.InetAddress.class;
+ else if ("InetAddrPort".equals(type))
+ aClass=org.mortbay.util.InetAddrPort.class;
+ else
+ aClass=Class.forName(type);
+ }
+ }
+
+ Object array = Array.newInstance(aClass,node.size());
+
+ for (int i=0;i<node.size();i++)
+ {
+ Object o = node.get(i);
+ if (o instanceof String)
+ continue;
+ XmlParser.Node item = (XmlParser.Node)o;
+ if (!item.getTag().equals("Item"))
+ throw new IllegalStateException("Not an Item");
+ Object v=value(obj,item);
+ if (v!=null)
+ Array.set(array,i,v);
+ }
+
+ return array;
+ }
+
+
+ /* ------------------------------------------------------------ */
/* Get the value of an element.
* If no value type is specified, then white space is trimmed out of the
* value. If it contains multiple value elements they are added as
@@ -685,6 +758,8 @@
return get(obj,node);
if ("New".equals(tag))
return newObj(obj,node);
+ if ("Array".equals(tag))
+ return newArray(obj,node);
if ("SystemProperty".equals(tag))
{
1.2 +0 -0 contrib/jetty/src/main/org/mortbay/xml/XmlParser.java
Index: XmlParser.java
===================================================================
RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/mortbay/xml/XmlParser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XmlParser.java 17 Jan 2002 01:23:23 -0000 1.1
+++ XmlParser.java 10 Feb 2002 17:57:46 -0000 1.2
@@ -1,6 +1,6 @@
// ========================================================================
// Copyright (c) 1999 Mort Bay Consulting (Australia) Pty. Ltd.
-// $Id: XmlParser.java,v 1.1 2002/01/17 01:23:23 olegnitz Exp $
+// $Id: XmlParser.java,v 1.2 2002/02/10 17:57:46 olegnitz Exp $
// ========================================================================
package org.mortbay.xml;
@@ -35,7 +35,7 @@
* This class wraps any standard JAXP1.1 parser with convieniant error and
* entity handlers and a mini dom-like document tree.
*
- * @version $Id: XmlParser.java,v 1.1 2002/01/17 01:23:23 olegnitz Exp $
+ * @version $Id: XmlParser.java,v 1.2 2002/02/10 17:57:46 olegnitz Exp $
* @author Greg Wilkins (gregw)
*/
public class XmlParser
1.2 +0 -0 contrib/jetty/src/main/org/mortbay/xml/configure_1_0.dtd
Index: configure_1_0.dtd
===================================================================
RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/mortbay/xml/configure_1_0.dtd,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- configure_1_0.dtd 17 Jan 2002 01:23:24 -0000 1.1
+++ configure_1_0.dtd 10 Feb 2002 17:57:46 -0000 1.2
@@ -16,7 +16,7 @@
Values are matched to arguments on a best effort approach, but types
my be specified if a match is not achieved.
-$Id: configure_1_0.dtd,v 1.1 2002/01/17 01:23:24 olegnitz Exp $
+$Id: configure_1_0.dtd,v 1.2 2002/02/10 17:57:46 olegnitz Exp $
-->
1.2 +0 -0 contrib/jetty/src/main/org/mortbay/xml/configure_1_1.dtd
Index: configure_1_1.dtd
===================================================================
RCS file: /cvsroot/jboss/contrib/jetty/src/main/org/mortbay/xml/configure_1_1.dtd,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- configure_1_1.dtd 17 Jan 2002 01:23:24 -0000 1.1
+++ configure_1_1.dtd 10 Feb 2002 17:57:46 -0000 1.2
@@ -16,7 +16,7 @@
Values are matched to arguments on a best effort approach, but types
my be specified if a match is not achieved.
-$Id: configure_1_1.dtd,v 1.1 2002/01/17 01:23:24 olegnitz Exp $
+$Id: configure_1_1.dtd,v 1.2 2002/02/10 17:57:46 olegnitz Exp $
-->
<!ENTITY % CONFIG "Set|Put|Call|New">
1.1 contrib/jetty/src/main/org/mortbay/xml/configure_1_2.dtd
Index: configure_1_2.dtd
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
This is the document type descriptor for the
org.mortbay.util.XmlConfiguration class. It allows a java object to be
configured by with a sequence of Set, Put and Call elements. These tags are
mapped to methods on the object to be configured as follows:
<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");
Values themselves may be configured objects that are created with the
<New> tag or returned from a <Call> tag.
Values are matched to arguments on a best effort approach, but types
my be specified if a match is not achieved.
$Id: configure_1_2.dtd,v 1.1 2002/02/10 17:57:46 olegnitz Exp $
-->
<!ENTITY % CONFIG "Set|Put|Call|New">
<!ENTITY % TYPE
"String|Character|Short|Byte|Integer|Long|Boolean|Float|Double|char|short|byte|int|long|boolean|float|double|URL|InetAddress|InetAddrPort">
<!ENTITY % VALUE "#PCDATA|Call|New|SystemProperty|Array">
<!ENTITY % TYPEATTR "type (%TYPE;) #IMPLIED " >
<!ENTITY % CLASSATTR "class NMTOKEN #REQUIRED" >
<!ENTITY % NAMEATTR "name NMTOKEN #REQUIRED" >
<!--
Configure Element.
This is the root element that specifies the class of object that
can be configured:
<Configure class="com.acme.MyClass"> ... </Configure>
A Configure element can contain Set, Put or Call elements.
-->
<!ELEMENT Configure (%CONFIG;)* >
<!ATTLIST Configure %CLASSATTR; >
<!--
Set Element.
This element maps to a call to a set method on the current object.
The name and optional type attributes are used to select the set
method.
A Set element can contain value text and/or the value elements Call,
New and SystemProperty. If no value type is specified, then white
space is trimmed out of the value. If it contains multiple value
elements they are added as strings before being converted to any
specified type.
-->
<!ELEMENT Set ( %VALUE; )* >
<!ATTLIST Set %NAMEATTR; %TYPEATTR; >
<!--
Put Element.
This element maps to a call to a put method on the current object,
which must implement the Map interface. The name attribute is used
as the put key and the optional type attribute can force the type
of the value.
A Put element can contain value text and/or the value elements Call,
New and SystemProperty. If no value type is specified, then white
space is trimmed out of the value. If it contains multiple value
elements they are added as strings before being converted to any
specified type.
-->
<!ELEMENT Put ( %VALUE; )* >
<!ATTLIST Put %NAMEATTR; %TYPEATTR;>
<!--
Call Element.
This element maps to an arbitrary call to a method on the current object,
The name attribute and Arg elements are used to select the method.
A Call element can contain a sequence of Arg elements followed by
a sequence of Set, Put and/or Call elements which act on any object
returned by the original call:
<Call name="test"><Arg>value1</Arg><Set name="Test">Value2</Set></Call>
This is equivalent to:
Object o2 = o1.test("value1");
o2.setTest("value2");
-->
<!ELEMENT Call (Arg*,(%CONFIG;)*)>
<!ATTLIST Call %NAMEATTR;>
<!--
Arg Element.
This element defines a positional argument for the Call element.
The optional type attribute can force the type of the value.
An Arg element can contain value text and/or the value elements Call,
New and SystemProperty. If no value type is specified, then white
space is trimmed out of the value. If it contains multiple value
elements they are added as strings before being converted to any
specified type.
-->
<!ELEMENT Arg ( %VALUE; )* >
<!ATTLIST Arg %TYPEATTR; >
<!--
New Element.
This element allows the creation of a new object as part of a
value of a Set, Put or Arg element. The class attribute determines
the type of the new object and the contained Arg elements
are used to select the constructor for the new object.
A New element can contain a sequence of Arg elements followed by
a sequence of Set, Put and/or Call elements which act on the new object:
<New class="com.acme.MyClass">
<Arg>value1</Arg><Set name="Test">Value2</Set>
</New>
This is equivalent to:
Object o = new com.acme.MyClass("value1");
o.setTest("value2");
-->
<!ELEMENT New (Arg*,(%CONFIG;)*)>
<!ATTLIST New %CLASSATTR; >
<!--
Array Element.
This element allows the creation of a new array as part of a
value of a Set, Put or Arg element. The type attribute determines
the type of the new array and the contained Item elements
are used for each element of the array
<Array type="java.lang.String">
<Item>value0</Arg>
<Item><New class="java.lang.String"><Arg>value1</Arg></New></Item>
</Array>
This is equivalent to:
String[] a = new String[] { "value0", new String("value1") };
-->
<!ELEMENT Array (Item*)>
<!ATTLIST Array %TYPEATTR; >
<!--
Item Element.
This element defines a positional argument for the Array element.
The optional type attribute can force the type of the value.
An Item element can contain value text and/or the value elements Call,
New and SystemProperty. If no value type is specified, then white
space is trimmed out of the value. If it contains multiple value
elements they are added as strings before being converted to any
specified type.
-->
<!ELEMENT Item ( %VALUE; )* >
<!ATTLIST Item %TYPEATTR; >
<!--
System Property Element.
This element allows JVM System properties to be retrieved as
part of the value of a Set, Put or Arg element.
The name attribute specifies the property name and the optional
default argument provides a default value.
<SystemProperty name="Test" default="value"/>
This is equivalent to:
System.getProperty("Test","value");
-->
<!ELEMENT SystemProperty EMPTY>
<!ATTLIST SystemProperty %NAMEATTR; default NMTOKEN #IMPLIED>
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development