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 ch...@apache.org on 2005/10/14 08:10:34 UTC

svn commit: r321029 - in /webservices/axis2/trunk/java/modules: addressing/src/org/apache/axis2/handlers/addressing/ addressing/test-resources/ codegen/src/org/apache/axis2/databinding/utils/ core/src/org/apache/axis2/addressing/ core/src/org/apache/ax...

Author: chinthaka
Date: Thu Oct 13 23:09:50 2005
New Revision: 321029

URL: http://svn.apache.org/viewcvs?rev=321029&view=rev
Log:
- Adding toString() method to the OMElement. 
- WARNING : changing WS-A Final namespace to the latest one.

Modified:
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
    webservices/axis2/trunk/java/modules/addressing/test-resources/soapWithWSAFinalInfo.xml
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/ADBPullParser.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMElement.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ElementImpl.java
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMElementImpl.java

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java?rev=321029&r1=321028&r2=321029&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java (original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java Thu Oct 13 23:09:50 2005
@@ -129,7 +129,7 @@
             // setting anonymous URI. Defaulting to Final.
             String anonymousURI = Final.WSA_ANONYMOUS_URL;
             if (Submission.WSA_NAMESPACE.equals(addressingNamespace)) {
-                anonymousURI = Submission.WSA_ANONYMOUS_URL;
+                anonymousURI = Submission.WSA_ANONYMOUS_URL;                    
             }
             epr = new EndpointReference(anonymousURI);
         }

Modified: webservices/axis2/trunk/java/modules/addressing/test-resources/soapWithWSAFinalInfo.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/test-resources/soapWithWSAFinalInfo.xml?rev=321029&r1=321028&r2=321029&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/test-resources/soapWithWSAFinalInfo.xml (original)
+++ webservices/axis2/trunk/java/modules/addressing/test-resources/soapWithWSAFinalInfo.xml Thu Oct 13 23:09:50 2005
@@ -1,14 +1,14 @@
 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-                  xmlns:wsa="http://www.w3.org/2005/02/addressing">
+                  xmlns:wsa="http://www.w3.org/2005/08/addressing">
     <soapenv:Header xmlns:fabrikam="http://example.com/fabrikam" xmlns:axis2="http://ws.apache.org/namespaces/axis2">
         <wsa:MessageID soapenv:mustUnderstand="0">
             uuid:920C5190-0B8F-11D9-8CED-F22EDEEBF7E5</wsa:MessageID>
         <wsa:To soapenv:mustUnderstand="0">http://localhost:8081/axis/services/BankPort</wsa:To>
         <wsa:From soapenv:mustUnderstand="0">
             <wsa:Address>
-                http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</wsa:Address>
+                http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
         </wsa:From>
         <axis2:ParamOne wsa:IsReferenceParameter='true'>123456789</axis2:ParamOne>
         <axis2:ParamTwo wsa:IsReferenceParameter='true'>ABCDEFG</axis2:ParamTwo>

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/ADBPullParser.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/ADBPullParser.java?rev=321029&r1=321028&r2=321029&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/ADBPullParser.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/ADBPullParser.java Thu Oct 13 23:09:50 2005
@@ -1,6 +1,7 @@
 package org.apache.axis2.databinding.utils;
 
 import org.apache.axis2.databinding.ADBBean;
+import org.apache.axis2.om.OMElement;
 import org.apache.axis2.util.BeanSerializerUtil;
 
 import javax.xml.namespace.NamespaceContext;
@@ -63,38 +64,38 @@
     /**
      * @param properties    - this should contain all the stuff that stax events should be generated.
      *                      Lets take an example of a bean.
-*                      <pre> <Person>
-     *                          <Name>FooOne</Name>
-     *                          <DependentOne>
-     *                              <Name>FooTwo</Name>
-     *                              <Age>25</Age>
-     *                              <Sex>Male</Sex>
-     *                          </DependentOne>
-     *                      </Person>
-     *
-     *                      so the mapping bean for this is
-     *                      class Person {
-     *                          String Name;
-     *                          Dependent dependentOne;
-     *                      }
-     *
-     *                      class Dependent {
-     *                          String name;
-     *                          int age;
-     *                          String sex;
-     *                      }
-     *
-     *                      So if one needs to generate pull events out of a Person bean, the array he needs
-     *                      to pass is like this.
-     *                      ---------------------------------------------------------------
-     *                      | "Name" | "FooOne" | QName("DependentOne") | Dependent object|
-     *                      ---------------------------------------------------------------
-     *                      Remember "Name" and "FooOne" MUST be strings and DependentOne SHOULD be 
-     *                      QName.
-     *                      This DependentObject can either be an ADBBean or a POJO. If its an ADBBean
-     *                      We directly get the pull parser from that. If not we create a reflection based
-     *                      pull parser for that java bean.
-     *  </pre>
+     *                      <pre> <Person>
+     *                                               <Name>FooOne</Name>
+     *                                               <DependentOne>
+     *                                                   <Name>FooTwo</Name>
+     *                                                   <Age>25</Age>
+     *                                                   <Sex>Male</Sex>
+     *                                               </DependentOne>
+     *                                           </Person>
+     *                      <p/>
+     *                                           so the mapping bean for this is
+     *                                           class Person {
+     *                                               String Name;
+     *                                               Dependent dependentOne;
+     *                                           }
+     *                      <p/>
+     *                                           class Dependent {
+     *                                               String name;
+     *                                               int age;
+     *                                               String sex;
+     *                                           }
+     *                      <p/>
+     *                                           So if one needs to generate pull events out of a Person bean, the array he needs
+     *                                           to pass is like this.
+     *                                           ---------------------------------------------------------------
+     *                                           | "Name" | "FooOne" | QName("DependentOne") | Dependent object|
+     *                                           ---------------------------------------------------------------
+     *                                           Remember "Name" and "FooOne" MUST be strings and DependentOne SHOULD be
+     *                                           QName.
+     *                                           This DependentObject can either be an ADBBean or a POJO. If its an ADBBean
+     *                                           We directly get the pull parser from that. If not we create a reflection based
+     *                                           pull parser for that java bean.
+     *                       </pre>
      * @param adbBeansQName
      * @return XMLStreamReader
      */
@@ -160,8 +161,10 @@
                 if (object instanceof ADBBean) {
                     ADBBean adbBean = (ADBBean) object;
                     childPullParser = (ADBPullParser) adbBean.getPullParser((QName) o);
+                } else if (object instanceof OMElement) {
+//                   childPullParser = (OMElement) ;
                 } else {
-                   childPullParser = (ADBPullParser) BeanSerializerUtil.getPullParser(object, (QName) o );
+                    childPullParser = (ADBPullParser) BeanSerializerUtil.getPullParser(object, (QName) o);
                 }
                 accessingChildPullParser = true;
                 return this.next();

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java?rev=321029&r1=321028&r2=321029&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/addressing/AddressingConstants.java Thu Oct 13 23:09:50 2005
@@ -54,9 +54,9 @@
 
     public interface Final {
         // ====================== Addressing 1.0 Final Version Constants ====================
-        public static final String WSA_NAMESPACE = "http://www.w3.org/2005/02/addressing";
-        public static final String WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE = "http://www.w3.org/2005/02/addressing/reply";
-        public static final String WSA_ANONYMOUS_URL = "http://www.w3.org/2005/02/addressing/role/anonymous";
+        public static final String WSA_NAMESPACE = "http://www.w3.org/2005/08/addressing";
+        public static final String WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE = "http://www.w3.org/2005/08/addressing/reply";
+        public static final String WSA_ANONYMOUS_URL = "http://www.w3.org/2005/08/addressing/anonymous";
 
         public static final String WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE = "IsReferenceParameter";
         public static final String WSA_TYPE_ATTRIBUTE_VALUE = "true";

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java?rev=321029&r1=321028&r2=321029&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/Utils.java Thu Oct 13 23:09:50 2005
@@ -87,6 +87,7 @@
         newmsgCtx.setDoingREST(inMessageContext.isDoingREST());
         newmsgCtx.setDoingMTOM(inMessageContext.isDoingMTOM());
         newmsgCtx.setServerSide(inMessageContext.isServerSide());
+        newmsgCtx.setServiceGroupContextId(inMessageContext.getServiceGroupContextId());
 
         return newmsgCtx;
     }

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java?rev=321029&r1=321028&r2=321029&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ServiceGroupContextTest.java Thu Oct 13 23:09:50 2005
@@ -93,6 +93,7 @@
         SOAPHeaderBlock soapHeaderBlock = defaultEnvelope.getHeader().addHeaderBlock(Constants.SERVICE_GROUP_ID,
                                                                                      axis2Namespace);
 
+        System.out.println("soapHeaderBlock = " + soapHeaderBlock);
         String serviceGroupId = result.getHeader().getFirstChildWithName(new QName("ReplyTo"))
                 .getFirstChildWithName(new QName("ReferenceParameters")).
                 getFirstChildWithName(new QName("ServiceGroupId")).getText();

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMElement.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMElement.java?rev=321029&r1=321028&r2=321029&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMElement.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/OMElement.java Thu Oct 13 23:09:50 2005
@@ -17,6 +17,7 @@
 package org.apache.axis2.om;
 
 import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import java.util.Iterator;
 
@@ -265,6 +266,19 @@
      * @return The {@link QName} for the element.
      */
     public QName getQName();
+
+    /**
+     *  This is a convenience method only. This will basically serialize the given OMElement
+     *  to a String but will build the OMTree in the memory
+     */
+    public String toString();
+
+    /**
+     *  This is a convenience method only. This will basically serialize the given OMElement
+     *  to a String but will NOT build the OMTree in the memory. So you are at your own risk of
+     *  losing information.
+     */
+    public String toStringWithConsume() throws XMLStreamException;
 
 
 }

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ElementImpl.java?rev=321029&r1=321028&r2=321029&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ElementImpl.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/dom/ElementImpl.java Thu Oct 13 23:09:50 2005
@@ -27,12 +27,11 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-import java.util.Iterator;
-
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
+import java.util.Iterator;
 
 /**
  * @author Ruchith Fernando (ruchith.fernando@gmail.com)
@@ -386,13 +385,18 @@
 		throw new UnsupportedOperationException("TODO");
 	}
 
-	/* (non-Javadoc)
-	 * @see org.apache.axis2.om.OMElement#getText()
-	 */
-	public String getText() {
-		//TODO
-		throw new UnsupportedOperationException("TODO");
-	}
+    public String toStringWithConsume() throws XMLStreamException {
+        // TODO : Ruchith please implement this ;).
+        return null;  //To change body of implemented methods use File | Settings | File Templates.
+    }
+
+    /* (non-Javadoc)
+      * @see org.apache.axis2.om.OMElement#getText()
+      */
+    public String getText() {
+        //TODO
+        throw new UnsupportedOperationException("TODO");
+    }
 
 	/* (non-Javadoc)
 	 * @see org.apache.axis2.om.OMElement#getXMLStreamReader()

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMElementImpl.java?rev=321029&r1=321028&r2=321029&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMElementImpl.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/OMElementImpl.java Thu Oct 13 23:09:50 2005
@@ -25,10 +25,13 @@
 import org.apache.axis2.om.impl.llom.traverse.OMChildrenQNameIterator;
 import org.apache.axis2.om.impl.llom.util.EmptyIterator;
 import org.apache.axis2.soap.impl.llom.SOAPConstants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayOutputStream;
 import java.util.HashMap;
 import java.util.Iterator;
 
@@ -37,6 +40,8 @@
  */
 public class OMElementImpl extends OMNodeImpl
         implements OMElement, OMConstants, OMContainerEx {
+
+    private Log logger = LogFactory.getLog(getClass());
     /**
      * Field ns
      */
@@ -228,7 +233,7 @@
             child.setPreviousOMSibling(null);
         } else {
             child.setPreviousOMSibling(lastChild);
-            ((OMNodeEx)lastChild).setNextOMSibling(child);
+            ((OMNodeEx) lastChild).setNextOMSibling(child);
         }
 
         child.setNextOMSibling(null);
@@ -238,7 +243,9 @@
 
     /**
      * This will give the next sibling. This can be an OMAttribute for OMAttribute or OMText or OMELement for others.
+     *
      * @throws org.apache.axis2.om.OMException
+     *
      * @throws OMException
      */
     public OMNode getNextOMSibling() throws OMException {
@@ -260,6 +267,7 @@
 
     /**
      * Returns a filtered list of children - just the elements.
+     *
      * @return an iterator over the child elements
      */
     public Iterator getChildElements() {
@@ -322,7 +330,7 @@
 
     /**
      * This will ckeck for the namespace <B>only</B> in the current Element.
-     *
+     * <p/>
      * This can also be used to retrieve the prefix of a known namespace URI
      */
     private OMNamespace findDeclaredNamespace(String uri, String prefix) {
@@ -475,7 +483,7 @@
      */
     public void setFirstChild(OMNode firstChild) {
         if (firstChild != null) {
-            ((OMNodeEx)firstChild).setParent(this);
+            ((OMNodeEx) firstChild).setParent(this);
         }
         this.firstChild = firstChild;
     }
@@ -540,8 +548,8 @@
             throw new UnsupportedOperationException(
                     "This element was not created in a manner to be switched");
         }
-        if (builder.isCompleted() && !cache){
-               throw new UnsupportedOperationException(
+        if (builder.isCompleted() && !cache) {
+            throw new UnsupportedOperationException(
                     "The parser is already consumed!");
         }
         return new OMStAXWrapper(builder, this, cache);
@@ -627,33 +635,33 @@
 
     protected void serialize(org.apache.axis2.om.impl.OMOutputImpl omOutput, boolean cache) throws XMLStreamException {
 
-        if (cache){
+        if (cache) {
             //in this case we don't care whether the elements are built or not
             //we just call the serializeAndConsume methods
             OMSerializerUtil.serializeStartpart(this, omOutput);
             //serilize children
             Iterator children = this.getChildren();
             while (children.hasNext()) {
-                ((OMNode)children.next()).serialize(omOutput);
+                ((OMNode) children.next()).serialize(omOutput);
             }
             OMSerializerUtil.serializeEndpart(omOutput);
 
-        }else{
+        } else {
             //Now the caching is supposed to be off. However caching been switched off
             //has nothing to do if the element is already built!
-            if (this.done){
+            if (this.done) {
                 OMSerializerUtil.serializeStartpart(this, omOutput);
                 //serializeAndConsume children
                 Iterator children = this.getChildren();
                 while (children.hasNext()) {
                     //A call to the  Serialize or the serializeAndConsume wont make a difference here
-                    ((OMNode)children.next()).serializeAndConsume(omOutput);
+                    ((OMNode) children.next()).serializeAndConsume(omOutput);
                 }
                 OMSerializerUtil.serializeEndpart(omOutput);
-            } else{
+            } else {
                 //take the XMLStream reader and feed it to the stream serilizer.
                 //todo is this right ?????
-                OMSerializerUtil.serializeByPullStream(this, omOutput,cache);
+                OMSerializerUtil.serializeByPullStream(this, omOutput, cache);
             }
 
 
@@ -756,6 +764,30 @@
             qName = new QName(localName);
         }
         return qName;
+    }
+
+    public String toStringWithConsume() throws XMLStreamException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        OMOutputImpl out = new OMOutputImpl(baos, false);
+        this.serializeAndConsume(out);
+        out.flush();
+        return new String(baos.toByteArray());
+    }
+
+    public String toString() {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        OMOutputImpl out = null;
+        try {
+            out = new OMOutputImpl(baos, false);
+            this.serialize(out);
+            out.flush();
+        } catch (XMLStreamException e) {
+            // can not throw out an exception here. Can't do anything other than logging
+            // and swallowing this :(
+            logger.error("Can not serialize OM Element "+ this.getLocalName(), e);
+        }
+
+        return new String(baos.toByteArray());
     }
 
     /**