You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "STEARNS,JIM (HP-FtCollins,ex1)" <ji...@hp.com> on 2001/03/06 02:24:31 UTC
RE: cvs commit: xml-axis/java/src/org/apache/axis/utils Admin.jav
a
Doug,
One documentation nit: you might want to add JDOM to the list of
prerequisites in the introductory comment in build.xml.
Jim
> -----Original Message-----
> From: dug@apache.org [mailto:dug@apache.org]
> Sent: Friday, March 02, 2001 12:05 PM
> To: xml-axis-cvs@apache.org
> Subject: cvs commit: xml-axis/java/src/org/apache/axis/utils
> Admin.java
>
>
> dug 01/03/02 12:04:59
>
> Modified: java/samples/stock ComInfoService.java
> StockQuoteService.java StockQuoteService.jws
> java/src/org/apache/axis AxisFault.java Message.java
> java/src/org/apache/axis/client HTTPCall.java
> HTTPMessage.java
> java/src/org/apache/axis/handlers DebugHandler.java
> MsgDispatchHandler.java
> RPCDispatchHandler.java
> java/src/org/apache/axis/message RPCArg.java
> RPCBody.java
> SOAPBody.java SOAPEnvelope.java
> SOAPHeader.java
> java/src/org/apache/axis/transport/http
> HTTPDispatchHandler.java
> java/src/org/apache/axis/utils Admin.java
> Log:
> Use JDOM instead of DOM/Xerces
> Everything still seems to work - samples still run so hopefully I
> got everything 8-)
>
> Revision Changes Path
> 1.4 +1 -4 xml-axis/java/samples/stock/ComInfoService.java
>
> Index: ComInfoService.java
> ===================================================================
> RCS file:
> /home/cvs/xml-axis/java/samples/stock/ComInfoService.java,v
> retrieving revision 1.3
> retrieving revision 1.4
> diff -u -r1.3 -r1.4
> --- ComInfoService.java 2001/02/10 04:39:52 1.3
> +++ ComInfoService.java 2001/03/02 20:02:18 1.4
> @@ -58,10 +58,7 @@
> import java.io.*;
> import java.net.URL;
>
> -import org.w3c.dom.*;
> -import org.xml.sax.InputSource ;
> -import org.apache.xerces.parsers.* ;
> -import org.apache.xerces.framework.* ;
> +import org.jdom.* ;
>
> /**
> *
>
>
>
> 1.6 +9 -12
> xml-axis/java/samples/stock/StockQuoteService.java
>
> Index: StockQuoteService.java
> ===================================================================
> RCS file:
> /home/cvs/xml-axis/java/samples/stock/StockQuoteService.java,v
> retrieving revision 1.5
> retrieving revision 1.6
> diff -u -r1.5 -r1.6
> --- StockQuoteService.java 2001/02/10 04:39:52 1.5
> +++ StockQuoteService.java 2001/03/02 20:02:22 1.6
> @@ -56,12 +56,11 @@
> package samples.stock ;
>
> import java.io.*;
> +import java.util.* ;
> import java.net.URL;
>
> -import org.w3c.dom.*;
> -import org.xml.sax.InputSource ;
> -import org.apache.xerces.parsers.* ;
> -import org.apache.xerces.framework.* ;
> +import org.jdom.* ;
> +import org.jdom.input.SAXBuilder ;
>
> /**
> * See \samples\stock\readme for info.
> @@ -80,17 +79,15 @@
> URL url = new URL(
> "http://www.xmltoday.com/examples/" +
>
> "stockquote/getxmlquote.vep?s="+symbol );
>
> - DOMParser parser = new DOMParser();
> - InputSource inp = new InputSource( url.openStream() );
> + SAXBuilder parser = new SAXBuilder();
>
> - parser.parse( inp );
> + Document doc = parser.build( url );
>
> - Document doc = parser.getDocument();
> - Element elem = doc.getDocumentElement ();
> - NodeList list = elem.getElementsByTagName( "price" );
> + Element elem = doc.getRootElement ();
> + List list = elem.getChildren( "price" );
>
> - elem = (Element) list.item( 0 );
> - String quoteStr = elem.getAttribute ("value");
> + elem = (Element) list.get( 0 );
> + String quoteStr = elem.getAttributeValue("value");
> try {
> return Float.valueOf(quoteStr).floatValue();
> } catch (NumberFormatException e1) {
>
>
>
> 1.2 +9 -12
> xml-axis/java/samples/stock/StockQuoteService.jws
>
> Index: StockQuoteService.jws
> ===================================================================
> RCS file:
> /home/cvs/xml-axis/java/samples/stock/StockQuoteService.jws,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -u -r1.1 -r1.2
> --- StockQuoteService.jws 2001/02/20 14:24:42 1.1
> +++ StockQuoteService.jws 2001/03/02 20:02:25 1.2
> @@ -54,12 +54,11 @@
> */
>
> import java.io.*;
> +import java.util.* ;
> import java.net.URL;
>
> -import org.w3c.dom.*;
> -import org.xml.sax.InputSource ;
> -import org.apache.xerces.parsers.* ;
> -import org.apache.xerces.framework.* ;
> +import org.jdom.* ;
> +import org.jdom.input.SAXBuilder ;
>
> /**
> * See \samples\stock\readme for info.
> @@ -78,17 +77,15 @@
> URL url = new URL(
> "http://www.xmltoday.com/examples/" +
>
> "stockquote/getxmlquote.vep?s="+symbol );
>
> - DOMParser parser = new DOMParser();
> - InputSource inp = new InputSource( url.openStream() );
> + SAXBuilder parser = new SAXBuilder();
>
> - parser.parse( inp );
> + Document doc = parser.build( url );
>
> - Document doc = parser.getDocument();
> - Element elem = doc.getDocumentElement ();
> - NodeList list = elem.getElementsByTagName( "price" );
> + Element elem = doc.getRootElement ();
> + List list = elem.getChildren( "price" );
>
> - elem = (Element) list.item( 0 );
> - String quoteStr = elem.getAttribute ("value");
> + elem = (Element) list.get( 0 );
> + String quoteStr = elem.getAttributeValue("value");
> try {
> return Float.valueOf(quoteStr).floatValue();
> } catch (NumberFormatException e1) {
>
>
>
> 1.10 +14 -22
> xml-axis/java/src/org/apache/axis/AxisFault.java
>
> Index: AxisFault.java
> ===================================================================
> RCS file:
> /home/cvs/xml-axis/java/src/org/apache/axis/AxisFault.java,v
> retrieving revision 1.9
> retrieving revision 1.10
> diff -u -r1.9 -r1.10
> --- AxisFault.java 2001/02/17 16:44:01 1.9
> +++ AxisFault.java 2001/03/02 20:02:48 1.10
> @@ -57,9 +57,9 @@
>
> import java.io.* ;
> import java.util.* ;
> -import org.w3c.dom.* ;
> -import org.xml.sax.InputSource ;
> -import org.apache.xerces.dom.DocumentImpl ;
> +
> +import org.jdom.* ;
> +
> import org.apache.axis.utils.* ;
>
> /**
> @@ -132,36 +132,28 @@
> return( (Element[]) faultDetails.toArray() );
> }
>
> - public Element getAsDOM() {
> - Document doc = null ;
> + public Element getAsXML() {
> Element elem, root ;
> int i ;
> -
> - doc = new DocumentImpl();
>
> - root = doc.createElementNS(Constants.URI_SOAP_ENV,
> - Constants.NSPREFIX_SOAP_ENV + ":" +
> - Constants.ELEM_FAULT);
> - doc.appendChild( root );
> + root = new Element( Constants.ELEM_FAULT,
> Constants.NSPREFIX_SOAP_ENV,
> + Constants.URI_SOAP_ENV );
> + root.addContent( elem = new Element(
> Constants.ELEM_FAULT_CODE ) );
> + elem.addContent( faultCode );
>
> - root.appendChild( elem =
> doc.createElement(Constants.ELEM_FAULT_CODE) );
> - elem.appendChild( doc.createTextNode( faultCode ) );
> + root.addContent( elem = new
> Element(Constants.ELEM_FAULT_STRING) );
> + elem.addContent( faultString );
>
> - root.appendChild( elem =
> doc.createElement(Constants.ELEM_FAULT_STRING) );
> - elem.appendChild( doc.createTextNode( faultString ) );
> -
> if ( faultActor != null && !faultActor.equals("") ) {
> - root.appendChild( elem =
> doc.createElement(Constants.ELEM_FAULT_ACTOR) );
> - elem.appendChild( doc.createTextNode( faultActor ) );
> + root.addContent( elem = new
> Element(Constants.ELEM_FAULT_ACTOR) );
> + elem.addContent( faultActor );
> }
>
> if ( faultDetails != null && faultDetails.size() > 0 ) {
> - root.appendChild( elem =
> doc.createElement(Constants.ELEM_FAULT_DETAIL) );
> + root.addContent( elem = new
> Element(Constants.ELEM_FAULT_DETAIL) );
> for ( i = 0 ;i < faultDetails.size() ; i++ )
> - elem.appendChild( (Element) faultDetails.get(i) );
> + elem.addContent( (Element) faultDetails.get(i) );
> }
> -
> - root.appendChild( elem );
>
> return( root );
> }
>
>
>
> 1.11 +42 -18 xml-axis/java/src/org/apache/axis/Message.java
>
> Index: Message.java
> ===================================================================
> RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Message.java,v
> retrieving revision 1.10
> retrieving revision 1.11
> diff -u -r1.10 -r1.11
> --- Message.java 2001/02/21 19:18:28 1.10
> +++ Message.java 2001/03/02 20:02:52 1.11
> @@ -58,12 +58,13 @@
> import java.io.* ;
> import javax.servlet.* ;
> import javax.servlet.http.* ;
> -import org.w3c.dom.* ;
> -import org.xml.sax.InputSource ;
> -import org.apache.xerces.parsers.DOMParser ;
> -import org.apache.xml.serialize.OutputFormat ;
> -import org.apache.xml.serialize.XMLSerializer ;
> +
> +import org.jdom.* ;
> +import org.jdom.input.SAXBuilder ;
> +import org.jdom.output.XMLOutputter ;
> +
> import org.apache.axis.message.* ;
> +import org.apache.axis.utils.Debug ;
>
> /**
> *
> @@ -83,6 +84,7 @@
> * Just something to us working...
> */
> public Message(Object origMsg, String form) {
> + Debug.Print( 1, "Enter Message ctor, form: " + form );
> originalMessage = origMsg ;
> currentMessage = origMsg ;
> currentForm = form ;
> @@ -101,6 +103,7 @@
> }
>
> public void setCurrentMessage(Object currMsg, String form) {
> + Debug.Print( 1, "Setting current message form to: " + form );
> currentMessage = currMsg ;
> currentForm = form ;
> }
> @@ -109,6 +112,8 @@
> // now I need something quick...
>
> public Object getAs( String desiredType ) {
> + Debug.Print( 1, "Enter: Message::getAs(" +desiredType+ ")" );
> + Debug.Print( 1, " current form: " + currentForm );
> if ( currentForm.equals( desiredType ) ) return(
> currentMessage );
>
> if ( desiredType.equals( "Bytes" )) return( getAsBytes() );
> @@ -121,7 +126,11 @@
> }
>
> private byte[] getAsBytes() {
> - if ( currentForm.equals("Bytes") ) return( (byte[])
> currentMessage );
> + Debug.Print( 1, "Enter: Message::getAsByes" );
> + if ( currentForm.equals("Bytes") ) {
> + Debug.Print( 1, "Exit: Message::getAsByes" );
> + return( (byte[]) currentMessage );
> + }
>
> if ( currentForm.equals("InputStream") ) {
> // Assumes we don't need a content length
> @@ -130,11 +139,13 @@
> byte[] buf = new byte[ inp.available() ];
> inp.read( buf );
> setCurrentMessage( buf, "Bytes" );
> + Debug.Print( 1, "Exit: Message::getAsByes" );
> return( (byte[]) currentMessage );
> }
> catch( Exception e ) {
> e.printStackTrace( System.err );
> }
> + Debug.Print( 1, "Exit: Message::getAsByes" );
> return( null );
> }
>
> @@ -144,6 +155,7 @@
> byte[] buf = new byte[req.getContentLength()];
> req.getInputStream().read( buf );
> setCurrentMessage( buf, "Bytes" );
> + Debug.Print( 1, "Exit: Message::getAsBytes" );
> return( (byte[]) currentMessage );
> }
> catch( Exception e ) {
> @@ -158,16 +170,21 @@
>
> if ( currentForm.equals("String") ) {
> setCurrentMessage(
> ((String)currentMessage).getBytes(), "Bytes" );
> + Debug.Print( 1, "Exit: Message::getAsBytes" );
> return( (byte[]) currentMessage );
> }
>
> -
> System.err.println("Can't convert " + currentForm + "
> to Bytes" );
> + Debug.Print( 1, "Exit: Message::getAsBytes" );
> return( null );
> }
>
> private String getAsString() {
> - if ( currentForm.equals("String") ) return( (String)
> currentMessage );
> + Debug.Print( 1, "Enter: Message::getAsString" );
> + if ( currentForm.equals("String") ) {
> + Debug.Print( 1, "Exit: Message::getAsString" );
> + return( (String) currentMessage );
> + }
>
> if ( currentForm.equals("InputStream") ||
> currentForm.equals("ServletRequest")) {
> @@ -177,6 +194,7 @@
>
> if ( currentForm.equals("Bytes") ) {
> setCurrentMessage( new String((byte[])
> currentMessage), "String" );
> + Debug.Print( 1, "Exit: Message::getAsString" );
> return( (String) currentMessage );
> }
>
> @@ -187,11 +205,9 @@
> if ( currentForm.equals("Document") ) {
> try {
> ByteArrayOutputStream baos = new ByteArrayOutputStream();
> - XMLSerializer xs = new XMLSerializer( baos, new
> OutputFormat() );
> - xs.serialize( (Document) currentMessage );
> - baos.close();
> + XMLOutputter xo = new XMLOutputter();
> currentForm = "String" ;
> - currentMessage = baos.toString();
> + currentMessage = xo.outputString( (Document)
> currentMessage );
> return( (String) currentMessage );
> }
> catch( Exception e ) {
> @@ -200,13 +216,15 @@
> }
>
> System.err.println("Can't convert " + currentForm + "
> to String" );
> + Debug.Print( 1, "Exit: Message::getAsString" );
> return( null );
> }
>
> private Document getAsDocument() {
> + Debug.Print( 1, "Enter: Message::getAsDocument" );
> if ( currentForm.equals("Document") ) return(
> (Document) currentMessage );
>
> - DOMParser parser = new DOMParser();
> + SAXBuilder parser = new SAXBuilder();
> Reader reader = null ;
>
> try {
> @@ -236,39 +254,45 @@
> else if ( currentForm.equals("AxisFault") ) {
> AxisFault fault = (AxisFault) currentMessage ;
> SOAPEnvelope env = new SOAPEnvelope();
> - SOAPBody body = new SOAPBody( fault.getAsDOM() );
> + SOAPBody body = new SOAPBody( fault.getAsXML() );
>
> env.addBody( body );
>
> - setCurrentMessage( env.getAsDOM(), "Document" );
> + setCurrentMessage( env.getAsXML(), "Document" );
> + Debug.Print( 1, "Exit: Message::getAsDocument" );
> return( (Document) currentMessage );
> }
> else if ( currentForm.equals("SOAPEnvelope") ) {
> SOAPEnvelope env = (SOAPEnvelope) currentMessage ;
> - setCurrentMessage( env.getAsDOM(), "Document" );
> + setCurrentMessage( env.getAsXML(), "Document" );
> + Debug.Print( 1, "Exit: Message::getAsDocument" );
> return( (Document) currentMessage );
> }
> else {
> System.err.println("Can't convert " + currentForm
> + " to Document" );
> + Debug.Print( 1, "Exit: Message::getAsDocument" );
> return( null );
> }
>
> - parser.parse( new InputSource( reader ) );
> - setCurrentMessage( parser.getDocument(), "Document" );
> + setCurrentMessage( parser.build( reader ), "Document" );
> + Debug.Print( 1, "Exit: Message::getAsDocument" );
> return( (Document) currentMessage );
> }
> catch( Exception e ) {
> e.printStackTrace( System.err );
> }
> + Debug.Print( 1, "Exit: Message::getAsDocument" );
> return( null );
> }
>
> private SOAPEnvelope getAsSOAPEnvelope() {
> + Debug.Print( 1, "Enter: Message::getAsSOAPEnvelope" );
> if ( currentForm.equals("SOAPEnvelope") )
> return( (SOAPEnvelope) currentMessage );
> getAsDocument();
> setCurrentMessage( new SOAPEnvelope( (Document)
> currentMessage ),
> "SOAPEnvelope" );
> + Debug.Print( 1, "Exit: Message::getAsSOAPEnvelope" );
> return( (SOAPEnvelope) currentMessage );
> }
>
>
>
>
> 1.13 +2 -2
> xml-axis/java/src/org/apache/axis/client/HTTPCall.java
>
> Index: HTTPCall.java
> ===================================================================
> RCS file:
> /home/cvs/xml-axis/java/src/org/apache/axis/client/HTTPCall.java,v
> retrieving revision 1.12
> retrieving revision 1.13
> diff -u -r1.12 -r1.13
> --- HTTPCall.java 2001/02/21 01:07:21 1.12
> +++ HTTPCall.java 2001/03/02 20:03:07 1.13
> @@ -56,7 +56,7 @@
> package org.apache.axis.client ;
>
> import java.util.* ;
> -import org.w3c.dom.* ;
> +import org.jdom.* ;
> import org.apache.axis.* ;
> import org.apache.axis.message.* ;
> import org.apache.axis.handlers.* ;
> @@ -166,7 +166,7 @@
>
> resMsg = msgContext.getResponseMessage();
> Document doc = (Document) resMsg.getAs("Document");
> - body = new RPCBody( doc.getDocumentElement() );
> + body = new RPCBody( doc.getRootElement() );
> resArgs = body.getArgs();
> arg = (RPCArg) resArgs.get(0);
> Debug.Print( 1, "Exit: HTTPCall.invoke" );
>
>
>
> 1.11 +2 -5
> xml-axis/java/src/org/apache/axis/client/HTTPMessage.java
>
> Index: HTTPMessage.java
> ===================================================================
> RCS file:
> /home/cvs/xml-axis/java/src/org/apache/axis/client/HTTPMessage.java,v
> retrieving revision 1.10
> retrieving revision 1.11
> diff -u -r1.10 -r1.11
> --- HTTPMessage.java 2001/02/21 01:07:21 1.10
> +++ HTTPMessage.java 2001/03/02 20:03:12 1.11
> @@ -56,8 +56,7 @@
> package org.apache.axis.client ;
>
> import java.util.* ;
> -import org.w3c.dom.* ;
> -import org.apache.xerces.dom.DocumentImpl ;
> +import org.jdom.* ;
>
> import org.apache.axis.* ;
> import org.apache.axis.message.* ;
> @@ -163,9 +162,7 @@
> header.setName("Debug");
> header.setNamespaceURI( Constants.URI_DEBUG );
> header.setActor( Constants.URI_NEXT_ACTOR );
> - Document doc = new DocumentImpl();
> - Node node = doc.createTextNode( "" + Debug.getDebugLevel() );
> - header.addDataNode( node );
> + header.addDataNode( "" + Debug.getDebugLevel() );
>
> reqEnv.addHeader( header );
> }
>
>
>
> 1.6 +3 -5
> xml-axis/java/src/org/apache/axis/handlers/DebugHandler.java
>
> Index: DebugHandler.java
> ===================================================================
> RCS file:
> /home/cvs/xml-axis/java/src/org/apache/axis/handlers/DebugHand
> ler.java,v
> retrieving revision 1.5
> retrieving revision 1.6
> diff -u -r1.5 -r1.6
> --- DebugHandler.java 2001/02/21 01:07:21 1.5
> +++ DebugHandler.java 2001/03/02 20:03:25 1.6
> @@ -56,8 +56,7 @@
> package org.apache.axis.handlers ;
>
> import java.util.* ;
> -import org.w3c.dom.* ;
> -import org.xml.sax.InputSource ;
> +import org.jdom.* ;
>
> import org.apache.axis.* ;
> import org.apache.axis.utils.* ;
> @@ -80,9 +79,8 @@
>
> for ( int i = 0 ; headers != null && i <
> headers.size() ; i ++ ) {
> SOAPHeader header = (SOAPHeader) headers.get(i);
> - Node node = header.getDataAtIndex( 0 );
> - if ( node != null ) {
> - String value = node.getNodeValue();
> + String value = (String)
> header.getDataAtIndex( 0 );
> + if ( value != null ) {
> int debugVal = Integer.parseInt( value );
> Debug.Print( 1, "Setting debug level
> to: " + debugVal );
> Debug.setDebugLevel( debugVal );
>
>
>
> 1.7 +2 -3
> xml-axis/java/src/org/apache/axis/handlers/MsgDispatchHandler.java
>
> Index: MsgDispatchHandler.java
> ===================================================================
> RCS file:
> /home/cvs/xml-axis/java/src/org/apache/axis/handlers/MsgDispat
> chHandler.java,v
> retrieving revision 1.6
> retrieving revision 1.7
> diff -u -r1.6 -r1.7
> --- MsgDispatchHandler.java 2001/02/21 01:07:21 1.6
> +++ MsgDispatchHandler.java 2001/03/02 20:03:31 1.7
> @@ -58,8 +58,7 @@
> import java.io.* ;
> import java.util.* ;
> import java.lang.reflect.* ;
> -import org.w3c.dom.* ;
> -import org.apache.xerces.dom.DocumentImpl ;
> +import org.jdom.* ;
> import org.apache.axis.* ;
> import org.apache.axis.utils.* ;
> import org.apache.axis.message.* ;
> @@ -102,7 +101,7 @@
> SOAPBody reqBody = reqEnv.getFirstBody();
>
> argClasses[0] =
> cl.loadClass("org.apache.axis.MessageContext");
> - argClasses[1] = cl.loadClass("org.w3c.dom.Document");
> + argClasses[1] = cl.loadClass("org.jdom.Document");
> argObjects[0] = (Object) msgContext ;
> argObjects[1] = (Object) reqBody.getAsDocument();
>
>
>
>
> 1.15 +1 -1
> xml-axis/java/src/org/apache/axis/handlers/RPCDispatchHandler.java
>
> Index: RPCDispatchHandler.java
> ===================================================================
> RCS file:
> /home/cvs/xml-axis/java/src/org/apache/axis/handlers/RPCDispat
> chHandler.java,v
> retrieving revision 1.14
> retrieving revision 1.15
> diff -u -r1.14 -r1.15
> --- RPCDispatchHandler.java 2001/02/21 01:07:22 1.14
> +++ RPCDispatchHandler.java 2001/03/02 20:03:37 1.15
> @@ -57,7 +57,7 @@
>
> import java.util.* ;
> import java.lang.reflect.* ;
> -import org.w3c.dom.* ;
> +import org.jdom.* ;
> import org.apache.axis.* ;
> import org.apache.axis.utils.* ;
> import org.apache.axis.message.* ;
>
>
>
> 1.8 +10 -15
> xml-axis/java/src/org/apache/axis/message/RPCArg.java
>
> Index: RPCArg.java
> ===================================================================
> RCS file:
> /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCArg.java,v
> retrieving revision 1.7
> retrieving revision 1.8
> diff -u -r1.7 -r1.8
> --- RPCArg.java 2001/02/10 04:39:56 1.7
> +++ RPCArg.java 2001/03/02 20:03:54 1.8
> @@ -58,9 +58,7 @@
> // !!!!***** Just a placeholder until we get the real
> stuff ***!!!!!
>
> import java.util.* ;
> -import org.w3c.dom.* ;
> -import org.xml.sax.InputSource ;
> -import org.apache.axis.message.* ;
> +import org.jdom.* ;
>
> /**
> *
> @@ -75,10 +73,10 @@
> public RPCArg() {}
>
> public RPCArg(Element elem) {
> - prefix = elem.getPrefix();
> + prefix = elem.getNamespacePrefix();
> namespaceURI = elem.getNamespaceURI();
> - name = elem.getLocalName();
> - value = elem.getFirstChild().getNodeValue();
> + name = elem.getName();
> + value = elem.getText();
> }
>
> public RPCArg(String name) {
> @@ -103,17 +101,14 @@
> public String getValue() { return( value ); }
> public void setValue(String val) { value = val ; }
>
> - public Element getAsXML(Document doc) {
> + public Element getAsXML() {
> Element root ;
>
> - if ( prefix != null ) {
> - root = doc.createElementNS(prefix, prefix + ":" + name );
> - root.setAttribute( "xmlns:" + prefix, namespaceURI );
> - }
> - else {
> - root = doc.createElement( name );
> - }
> - root.appendChild( doc.createTextNode( value ) );
> + if ( prefix != null )
> + root = new Element( name, prefix, namespaceURI );
> + else
> + root = new Element( name );
> + root.addContent( value );
> return( root );
> }
> };
>
>
>
> 1.10 +13 -19
> xml-axis/java/src/org/apache/axis/message/RPCBody.java
>
> Index: RPCBody.java
> ===================================================================
> RCS file:
> /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCBody.java,v
> retrieving revision 1.9
> retrieving revision 1.10
> diff -u -r1.9 -r1.10
> --- RPCBody.java 2001/02/17 16:44:02 1.9
> +++ RPCBody.java 2001/03/02 20:03:58 1.10
> @@ -58,9 +58,7 @@
> // !!!!***** Just a placeholder until we get the real
> stuff ***!!!!!
>
> import java.util.* ;
> -import org.w3c.dom.* ;
> -import org.apache.xerces.dom.DocumentImpl ;
> -import org.xml.sax.InputSource ;
> +import org.jdom.* ;
> import org.apache.axis.message.* ;
>
> /**
> @@ -84,10 +82,10 @@
> }
>
> public void setBody( Element root ) {
> - setMethodName( root.getLocalName() );
> - setPrefix( root.getPrefix() );
> + setMethodName( root.getName() );
> + setPrefix( root.getNamespacePrefix() );
> setNamespaceURI( root.getNamespaceURI() );
> - parseArgs( root.getChildNodes() );
> + parseArgs( root.getChildren() );
> }
>
> public RPCBody(String methodName, Object[] args) {
> @@ -122,34 +120,30 @@
> args.add( arg );
> }
>
> - public void parseArgs(NodeList list) {
> - for ( int i = 0 ; list != null && i < list.getLength()
> ; i++ ) {
> - Node n = list.item(i);
> - if ( n.getNodeType() != Node.ELEMENT_NODE ) continue ;
> + public void parseArgs(List list) {
> + for ( int i = 0 ; list != null && i < list.size() ; i++ ) {
> + Object n = list.get(i);
> if ( args == null ) args = new ArrayList();
> args.add( new RPCArg( (Element) n ) );
> }
> }
>
> - public Element getAsXML(Document doc) {
> + public Element getAsXML() {
> Element root ;
>
> - if ( prefix != null ) {
> - root = doc.createElementNS(prefix, prefix + ":" +
> methodName );
> - root.setAttribute( "xmlns:" + prefix, namespaceURI );
> - }
> + if ( prefix != null )
> + root = new Element( methodName, prefix, namespaceURI );
> else
> - root = doc.createElement( methodName );
> + root = new Element( methodName );
> for ( int i = 0 ; args != null && i < args.size() ; i++ ) {
> RPCArg arg = (RPCArg) args.get(i) ;
> - root.appendChild( arg.getAsXML(doc) );
> + root.addContent( arg.getAsXML() );
> }
> return( root );
> }
>
> public SOAPBody getAsSOAPBody() {
> - Document doc = new DocumentImpl();
> - return( new SOAPBody( getAsXML(doc) ) );
> + return( new SOAPBody( getAsXML() ) );
> }
>
> };
>
>
>
> 1.9 +5 -10
> xml-axis/java/src/org/apache/axis/message/SOAPBody.java
>
> Index: SOAPBody.java
> ===================================================================
> RCS file:
> /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPBody.java,v
> retrieving revision 1.8
> retrieving revision 1.9
> diff -u -r1.8 -r1.9
> --- SOAPBody.java 2001/02/10 04:39:56 1.8
> +++ SOAPBody.java 2001/03/02 20:04:01 1.9
> @@ -58,9 +58,7 @@
> // !!!!***** Just a placeholder until we get the real
> stuff ***!!!!!
>
> import java.util.* ;
> -import org.w3c.dom.* ;
> -import org.apache.xerces.dom.DocumentImpl ;
> -import org.xml.sax.InputSource ;
> +import org.jdom.* ;
> import org.apache.axis.message.* ;
>
> /**
> @@ -75,7 +73,7 @@
> }
>
> public SOAPBody(Document doc) {
> - root = doc.getDocumentElement() ;
> + root = doc.getRootElement() ;
> }
>
> public SOAPBody(Element elem) {
> @@ -90,15 +88,12 @@
> this.root = r ;
> }
>
> - public Element getAsXML(Document doc) {
> - if ( doc == null ) return( root );
> - return( (Element) doc.importNode( (Node) root, true ) );
> + public Element getAsXML() {
> + return( root );
> }
>
> public Document getAsDocument() {
> - Document doc = new DocumentImpl();
> - doc.appendChild( doc.importNode( (Node) root, true ) );
> - return( doc );
> + return( new Document(root) );
> }
>
> };
>
>
>
> 1.11 +34 -43
> xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java
>
> Index: SOAPEnvelope.java
> ===================================================================
> RCS file:
> /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPEnvelo
> pe.java,v
> retrieving revision 1.10
> retrieving revision 1.11
> diff -u -r1.10 -r1.11
> --- SOAPEnvelope.java 2001/02/10 04:39:57 1.10
> +++ SOAPEnvelope.java 2001/03/02 20:04:04 1.11
> @@ -58,9 +58,7 @@
> package org.apache.axis.message ;
>
> import java.util.* ;
> -import org.w3c.dom.* ;
> -import org.xml.sax.InputSource ;
> -import org.apache.xerces.dom.DocumentImpl ;
> +import org.jdom.* ;
> import org.apache.axis.message.* ;
> import org.apache.axis.* ;
>
> @@ -78,7 +76,7 @@
> }
>
> public SOAPEnvelope(Document doc) {
> - setEnvelope( doc.getDocumentElement() );
> + setEnvelope( doc.getRootElement() );
> }
>
> public SOAPEnvelope(SOAPBody bod) {
> @@ -86,7 +84,7 @@
> }
>
> public void setEnvelope(Element elem) {
> - NodeList list ;
> + List list ;
> int i ;
>
> if ( elem == null ) {
> @@ -95,30 +93,25 @@
> body = null ;
> return ;
> }
> - list = elem.getElementsByTagNameNS( Constants.URI_SOAP_ENV,
> - Constants.ELEM_HEADER );
> - if ( list != null && list.getLength() > 0 ) {
> - Element h = (Element) list.item(0);
> - // list = h.getElementsByTagName("*");
> - list = h.getChildNodes();
> - for ( i = 0 ; i < list.getLength() ; i++ ) {
> - Node n = list.item(i);
> - if ( n.getNodeType() != Node.ELEMENT_NODE ) continue ;
> - h = (Element) list.item(i);
> + list = elem.getChildren( Constants.ELEM_HEADER,
> elem.getNamespace());
> + if ( list != null && list.size() > 0 ) {
> + Element h = (Element) list.get(0);
> + // list = h.getChildren();
> + list = h.getChildren();
> + for ( i = 0 ; i < list.size() ; i++ ) {
> + h = (Element) list.get(i);
> if ( headers == null ) headers = new Vector();
> headers.add( new SOAPHeader( h ) );
> }
> }
>
> - list = elem.getElementsByTagNameNS( Constants.URI_SOAP_ENV,
> - Constants.ELEM_BODY );
> - if ( list != null && list.getLength() > 0 ) {
> - Element h = (Element) list.item(0);
> - list = h.getChildNodes();
> + list = elem.getChildren( Constants.ELEM_BODY,
> elem.getNamespace() );
> + if ( list != null && list.size() > 0 ) {
> + Element h = (Element) list.get(0);
> + list = h.getChildren();
> if ( list != null ) {
> - for ( i = 0 ; i < list.getLength() ; i++ ) {
> - Node n = list.item(i);
> - if ( n.getNodeType() != Node.ELEMENT_NODE ) continue ;
> + for ( i = 0 ; i < list.size() ; i++ ) {
> + Object n = list.get(i);
> if ( body == null ) body = new Vector();
> body.add( new SOAPBody( (Element) n ) );
> }
> @@ -182,37 +175,35 @@
> return( body );
> }
>
> - public Document getAsDOM() {
> + public Document getAsXML() {
> Document doc = null ;
> Element elem ;
> int i ;
>
> - doc = new DocumentImpl();
> - elem = doc.createElementNS(Constants.NSPREFIX_SOAP_ENV,
> - Constants.NSPREFIX_SOAP_ENV + ":" +
> - Constants.ELEM_ENVELOPE);
> - elem.setAttribute( "xmlns:" + Constants.NSPREFIX_SOAP_ENV,
> - Constants.URI_SOAP_ENV );
> + elem = new Element( Constants.ELEM_ENVELOPE,
> Constants.NSPREFIX_SOAP_ENV,
> + Constants.URI_SOAP_ENV );
> + doc = new Document( elem );
>
> - doc.appendChild( elem );
> if ( headers != null && headers.size() > 0 ) {
> - Element root = doc.createElementNS(Constants.URI_SOAP_ENV,
> -
> Constants.NSPREFIX_SOAP_ENV + ":" +
> - Constants.ELEM_HEADER);
> - elem.appendChild( root );
> + Element root = new Element( Constants.ELEM_HEADER,
> + Constants.NSPREFIX_SOAP_ENV,
> + Constants.URI_SOAP_ENV );
> + elem.addContent( root );
> for ( i = 0 ; i < headers.size() ; i++ ) {
> SOAPHeader h = (SOAPHeader) headers.get(i);
> - root.appendChild( h.getAsXML(doc) );
> + root.addContent( h.getAsXML() );
> }
> }
> if ( body != null ) {
> - Element root = doc.createElementNS(Constants.URI_SOAP_ENV,
> -
> Constants.NSPREFIX_SOAP_ENV + ":" +
> - Constants.ELEM_BODY);
> - elem.appendChild( root );
> - for ( i = 0 ; i < body.size() ; i++ )
> - root.appendChild( ((SOAPBody)body.get(i)).getAsXML(doc) );
> - // root.appendChild(doc.importNode( (Node)
> body.get(i), true ));
> + Element root = new Element( Constants.ELEM_BODY,
> + Constants.NSPREFIX_SOAP_ENV,
> + Constants.URI_SOAP_ENV );
> + elem.addContent( root );
> + for ( i = 0 ; i < body.size() ; i++ ) {
> + Element bod = ((SOAPBody)body.get(i)).getAsXML();
> + bod = (Element) bod.clone();
> + root.addContent( bod );
> + }
> }
> return( doc );
> }
>
>
>
> 1.10 +29 -27
> xml-axis/java/src/org/apache/axis/message/SOAPHeader.java
>
> Index: SOAPHeader.java
> ===================================================================
> RCS file:
> /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPHeader.java,v
> retrieving revision 1.9
> retrieving revision 1.10
> diff -u -r1.9 -r1.10
> --- SOAPHeader.java 2001/02/10 04:39:57 1.9
> +++ SOAPHeader.java 2001/03/02 20:04:08 1.10
> @@ -58,8 +58,7 @@
> // !!!!***** Just a placeholder until we get the real
> stuff ***!!!!!
>
> import java.util.* ;
> -import org.w3c.dom.* ;
> -import org.xml.sax.InputSource ;
> +import org.jdom.* ;
> import org.apache.axis.message.* ;
> import org.apache.axis.* ;
>
> @@ -82,15 +81,14 @@
>
> public SOAPHeader(Element elem) {
> String value ;
> - prefix = elem.getPrefix();
> + prefix = elem.getNamespacePrefix();
> namespaceURI = elem.getNamespaceURI();
> - name = elem.getLocalName();
> - value = elem.getAttributeNS( Constants.URI_SOAP_ENV,
> -
> Constants.ATTR_MUST_UNDERSTAND );
> + name = elem.getName();
> + value = elem.getAttributeValue( Constants.ATTR_MUST_UNDERSTAND,
> + elem.getNamespace() );
> if ( "1".equals(value) ) mustUnderstand = true ;
> - actor = elem.getAttributeNS( Constants.URI_SOAP_ENV,
> - Constants.ATTR_ACTOR );
> - setData( elem.getChildNodes() );
> + actor = elem.getAttributeValue( Constants.ATTR_ACTOR,
> elem.getNamespace() );
> + setData( elem.getMixedContent() );
> processed = false ;
> }
>
> @@ -111,36 +109,40 @@
>
> public Vector getData() { return( data ); }
>
> - public Node getDataAtIndex(int i) {
> + public Object getDataAtIndex(int i) {
> if ( data == null || i >= data.size() ) return( null );
> - return( (Node) data.get(i) );
> + return( (Object) data.get(i) );
> }
>
> - public void addDataNode(Node n) {
> + public void addDataNode(Object n) {
> if ( data == null ) data = new Vector();
> data.add(n);
> };
>
> - public void setData(NodeList nl) {
> + public void setData(List nl) {
> data = null ;
> - if ( nl != null && nl.getLength() != 0 ) data = new Vector();
> - for ( int i = 0 ; i < nl.getLength() ; i++ )
> - data.add( nl.item(i) );
> + if ( nl != null && nl.size() != 0 ) data = new Vector();
> + for ( int i = 0 ; i < nl.size() ; i++ )
> + data.add( nl.get(i) );
> }
>
> - public Element getAsXML(Document doc) {
> - Element root = doc.createElementNS(prefix, prefix +
> ":" + name );
> - root.setAttribute( "xmlns:" + prefix, namespaceURI );
> + public Element getAsXML() {
> + Element root = new Element( name, prefix, namespaceURI );
> if ( mustUnderstand )
> - root.setAttributeNS( Constants.URI_SOAP_ENV,
> - Constants.ATTR_MUST_UNDERSTAND,
> - "1" );
> + root.addAttribute( Constants.ATTR_MUST_UNDERSTAND, "1" );
> if ( actor != null )
> - root.setAttributeNS( Constants.URI_SOAP_ENV,
> - Constants.ATTR_ACTOR,
> - actor );
> - for ( int i = 0 ; data != null && i < data.size() ; i++ )
> - root.appendChild(doc.importNode( (Node) data.get(i), true ));
> + root.addAttribute( Constants.ATTR_ACTOR, actor );
> + for ( int i = 0 ; data != null && i < data.size() ; i++ ) {
> + Object o = data.get(i);
> + if ( o instanceof String )
> + root.addContent( (String) o );
> + else if ( o instanceof CDATA )
> + root.addContent( (CDATA) o );
> + else if ( o instanceof Element )
> + root.addContent( (Element) o );
> + else
> + System.err.println( "Unknown type: " + o.getClass() );
> + }
> return( root );
> }
>
>
>
>
> 1.4 +7 -9
> xml-axis/java/src/org/apache/axis/transport/http/HTTPDispatchH
> andler.java
>
> Index: HTTPDispatchHandler.java
> ===================================================================
> RCS file:
> /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/HTT
> PDispatchHandler.java,v
> retrieving revision 1.3
> retrieving revision 1.4
> diff -u -r1.3 -r1.4
> --- HTTPDispatchHandler.java 2001/02/21 01:07:22 1.3
> +++ HTTPDispatchHandler.java 2001/03/02 20:04:33 1.4
> @@ -58,9 +58,9 @@
> import java.io.* ;
> import java.net.* ;
> import java.util.* ;
> -import org.w3c.dom.* ;
> -import org.xml.sax.InputSource ;
> -import org.apache.xerces.parsers.DOMParser ;
> +import org.jdom.* ;
> +import org.jdom.input.SAXBuilder ;
> +import org.jdom.output.XMLOutputter ;
> import org.apache.axis.* ;
> import org.apache.axis.utils.* ;
> import org.apache.axis.message.* ;
> @@ -172,15 +172,13 @@
> }
> }
> if ( b != -1 ) {
> - DOMParser parser = new DOMParser();
> - parser.parse( new InputSource( inp ) );
> -
> - outMsg = new Message( parser.getDocument(), "Document" );
> + SAXBuilder parser = new SAXBuilder();
> + Document doc = parser.build(inp);
> + outMsg = new Message( doc, "Document" );
> msgContext.setResponseMessage( outMsg );
> if ( Debug.DebugOn(2) ) {
> Debug.Print( 2, "XML received:" );
> - Message m = new Message( parser.getDocument(),
> "Document" );
> - Debug.Print( 2, (String) m.getAs( "String" ) );
> + Debug.Print( 2, (new XMLOutputter()).outputString(doc) );
> }
> }
>
>
>
>
> 1.14 +27 -34
> xml-axis/java/src/org/apache/axis/utils/Admin.java
>
> Index: Admin.java
> ===================================================================
> RCS file:
> /home/cvs/xml-axis/java/src/org/apache/axis/utils/Admin.java,v
> retrieving revision 1.13
> retrieving revision 1.14
> diff -u -r1.13 -r1.14
> --- Admin.java 2001/02/20 22:51:30 1.13
> +++ Admin.java 2001/03/02 20:04:49 1.14
> @@ -57,10 +57,8 @@
>
> import java.io.* ;
> import java.util.* ;
> -import org.w3c.dom.* ;
> -import org.apache.xerces.dom.DocumentImpl ;
> -import org.apache.xerces.parsers.DOMParser ;
> -import org.xml.sax.InputSource ;
> +import org.jdom.* ;
> +import org.jdom.input.SAXBuilder ;
> import org.apache.axis.registries.* ;
> import org.apache.axis.handlers.* ;
> import org.apache.axis.utils.* ;
> @@ -90,12 +88,12 @@
> }
>
> private void getOptions(Element root, Handler handler) {
> - NodeList list = root.getElementsByTagName( "option" );
> + List list = root.getChildren( "option" );
>
> - for ( int i = 0 ; list != null && i < list.getLength()
> ; i++ ) {
> - Element elem = (Element) list.item(i);
> - String name = elem.getAttribute( "name" );
> - String value = elem.getAttribute( "value" );
> + for ( int i = 0 ; list != null && i < list.size() ; i++ ) {
> + Element elem = (Element) list.get(i);
> + String name = elem.getAttributeValue( "name" );
> + String value = elem.getAttributeValue( "value" );
>
> if ( name != null && value != null )
> handler.addOption( name, value );
> @@ -107,35 +105,33 @@
> hr =
> (HandlerRegistry)msgContext.getProperty(Constants.HANDLER_REGISTRY);
> sr =
> (HandlerRegistry)msgContext.getProperty(Constants.SERVICE_REGISTRY);
> process( xml );
> - Document doc = new DocumentImpl();
> - Element root = doc.createElement( "Admin" );
> - doc.appendChild( root );
> - root.appendChild( doc.createTextNode( "Done processing" ) );
> + Element root = new Element( "Admin" );
> + Document doc = new Document(root);
> + root.addContent( "Done processing" );
> Debug.Print( 1, "Exit: Admin:AdminService" );
> return( doc );
> }
>
> public void process(Document doc) {
> - process( doc.getDocumentElement() );
> + process( doc.getRootElement() );
> }
>
> public void process(Element root) {
> try {
> init();
> ClassLoader cl = new AxisClassLoader();
> - String action = root.getTagName();
> + String action = root.getName();
>
> if ( !action.equals("deploy") &&
> !action.equals("undeploy") )
> Error( "Root element must be 'deploy' or 'undeploy'" );
>
> - NodeList list = root.getChildNodes();
> - for ( int loop = 0 ; loop < list.getLength() ; loop++ ) {
> - Node node = list.item(loop);
> - if ( node.getNodeType() != Node.ELEMENT_NODE ) continue ;
> + List list = root.getChildren();
> + for ( int loop = 0 ; loop < list.size() ; loop++ ) {
> + Object node = list.get(loop);
> Element elem = (Element) node ;
> // if ( elem.getNodeType != ELEMENT_NODE ) continue ;
> - String type = elem.getTagName();
> - String name = elem.getAttribute( "name" );
> + String type = elem.getName();
> + String name = elem.getAttributeValue( "name" );
>
> if ( action.equals( "undeploy" ) ) {
> if ( type.equals("service") ) {
> @@ -154,11 +150,11 @@
> Handler h = null ;
>
> if ( type.equals( "handler" ) ) {
> - String cls = elem.getAttribute( "class" );
> + String cls = elem.getAttributeValue( "class" );
> System.out.println( "Deploying handler: " + name );
>
> if (hr instanceof SupplierRegistry) {
> - String lifeCycle = elem.getAttribute("lifecycle");
> + String lifeCycle = elem.getAttributeValue("lifecycle");
> Supplier supplier;
>
> if ("factory".equals(lifeCycle)) {
> @@ -179,10 +175,10 @@
> }
> }
> else if ( type.equals( "chain" ) ) {
> - String flow = elem.getAttribute( "flow" );
> - String input = elem.getAttribute( "input" );
> - String pivot = elem.getAttribute( "pivot" );
> - String output = elem.getAttribute( "output" );
> + String flow = elem.getAttributeValue( "flow" );
> + String input = elem.getAttributeValue( "input" );
> + String pivot = elem.getAttributeValue( "pivot" );
> + String output = elem.getAttributeValue( "output" );
>
> String hName ;
> Handler tmpH ;
> @@ -244,7 +240,7 @@
> }
> }
> else if ( type.equals( "service" ) ) {
> - String handler = elem.getAttribute( "handler" );
> + String handler = elem.getAttributeValue( "handler" );
> System.out.println( "Deploying service: " + name );
> Handler hand = hr.find(handler);
> if( hand == null )
> @@ -296,15 +292,12 @@
>
> try {
> for ( i = 0 ; i < args.length ; i++ ) {
> - DOMParser parser = new DOMParser();
> - InputSource inp = null ;
> - Document doc = null ;
> + SAXBuilder parser = new SAXBuilder();
> + Document doc = null ;
>
> System.out.println( "Processing '" + args[i] + "'" );
>
> - inp = new InputSource( new FileInputStream(args[i]));
> - parser.parse( inp );
> - doc = parser.getDocument();
> + doc = parser.build( new FileInputStream(args[i]) );
>
> admin.process( doc );
> }
>
>
>
>