You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2013/01/10 22:14:42 UTC

svn commit: r1431647 - in /webservices/commons/trunk/modules/axiom: modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/ modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/ modules/axiom-impl/src/main/java/org/ap...

Author: veithen
Date: Thu Jan 10 21:14:42 2013
New Revision: 1431647

URL: http://svn.apache.org/viewvc?rev=1431647&view=rev
Log:
AXIOM-444: Fixed another issue revealed by r1431544. Since Spring-WS doesn't use OMAbstractFactory, the OMMetaFactory is not a singleton.

Added:
    webservices/commons/trunk/modules/axiom/systests/spring-ws-tests/src/test/java/org/apache/axiom/systest/springws/AxiomSoapMessageTest.java   (with props)
    webservices/commons/trunk/modules/axiom/systests/spring-ws-tests/src/test/resources/
    webservices/commons/trunk/modules/axiom/systests/spring-ws-tests/src/test/resources/org/
    webservices/commons/trunk/modules/axiom/systests/spring-ws-tests/src/test/resources/org/apache/
    webservices/commons/trunk/modules/axiom/systests/spring-ws-tests/src/test/resources/org/apache/axiom/
    webservices/commons/trunk/modules/axiom/systests/spring-ws-tests/src/test/resources/org/apache/axiom/systest/
    webservices/commons/trunk/modules/axiom/systests/spring-ws-tests/src/test/resources/org/apache/axiom/systest/springws/
    webservices/commons/trunk/modules/axiom/systests/spring-ws-tests/src/test/resources/org/apache/axiom/systest/springws/soap-message.xml   (with props)
Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListMetaFactory.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11Factory.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12Factory.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java?rev=1431647&r1=1431646&r2=1431647&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/OMContainerHelper.java Thu Jan 10 21:14:42 2013
@@ -99,7 +99,7 @@ public final class OMContainerHelper {
         } else {
             // Careful here: if the child was created by another Axiom implementation, it doesn't
             // necessarily implement OMNodeEx
-            if (omNode.getOMFactory().getMetaFactory() == container.getOMFactory().getMetaFactory()) {
+            if (omNode.getOMFactory().getMetaFactory().equals(container.getOMFactory().getMetaFactory())) {
                 child = (OMNodeEx)omNode;
             } else {
                 child = (OMNodeEx)((OMFactoryEx)container.getOMFactory()).importNode(omNode);

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java?rev=1431647&r1=1431646&r2=1431647&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java Thu Jan 10 21:14:42 2013
@@ -20,6 +20,7 @@
 package org.apache.axiom.om.impl.llom.factory;
 
 import org.apache.axiom.ext.stax.datahandler.DataHandlerProvider;
+import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMComment;
 import org.apache.axiom.om.OMContainer;
@@ -57,10 +58,18 @@ import javax.xml.namespace.QName;
 public class OMLinkedListImplFactory implements OMFactoryEx {
     private final OMLinkedListMetaFactory metaFactory;
     
-    public OMLinkedListImplFactory(OMLinkedListMetaFactory metaFactory) {
+    /**
+     * For internal use only.
+     * 
+     * @param metaFactory
+     */
+    protected OMLinkedListImplFactory(OMLinkedListMetaFactory metaFactory) {
         this.metaFactory = metaFactory;
     }
     
+    /**
+     * @deprecated Use {@link OMAbstractFactory#getOMFactory()} to get an instance of this class.
+     */
     public OMLinkedListImplFactory() {
         this(new OMLinkedListMetaFactory());
     }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListMetaFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListMetaFactory.java?rev=1431647&r1=1431646&r2=1431647&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListMetaFactory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListMetaFactory.java Thu Jan 10 21:14:42 2013
@@ -51,4 +51,16 @@ public class OMLinkedListMetaFactory ext
     public SOAPMessage createSOAPMessage(OMXMLParserWrapper builder) {
         return new SOAPMessageImpl(builder, null);
     }
+
+    public int hashCode() {
+        return getClass().hashCode();
+    }
+    
+    public boolean equals(Object obj) {
+        // All instances of this class are considered equal. This is only required
+        // to support legacy code that instantiates OMFactory implementations directly
+        // (in which case the OMMetaFactory implementation is not guaranteed to be
+        // a singleton). May be removed in Axiom 1.3.
+        return obj != null && obj.getClass() == getClass();
+    }
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11Factory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11Factory.java?rev=1431647&r1=1431646&r2=1431647&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11Factory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap11/SOAP11Factory.java Thu Jan 10 21:14:42 2013
@@ -19,6 +19,7 @@
 
 package org.apache.axiom.soap.impl.llom.soap11;
 
+import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
@@ -50,10 +51,19 @@ import org.apache.axiom.soap.impl.llom.S
 /**
  */
 public class SOAP11Factory extends OMLinkedListImplFactory implements SOAPFactoryEx {
+    /**
+     * For internal use only.
+     * 
+     * @param metaFactory
+     */
     public SOAP11Factory(OMLinkedListMetaFactory metaFactory) {
         super(metaFactory);
     }
 
+    /**
+     * @deprecated Use {@link OMAbstractFactory#getSOAP11Factory()} to get an instance of this
+     *             class.
+     */
     public SOAP11Factory() {
     }
 

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12Factory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12Factory.java?rev=1431647&r1=1431646&r2=1431647&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12Factory.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/soap12/SOAP12Factory.java Thu Jan 10 21:14:42 2013
@@ -19,6 +19,7 @@
 
 package org.apache.axiom.soap.impl.llom.soap12;
 
+import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
@@ -50,10 +51,19 @@ import org.apache.axiom.soap.impl.llom.S
 /**
  */
 public class SOAP12Factory extends OMLinkedListImplFactory implements SOAPFactoryEx {
+    /**
+     * For internal use only.
+     * 
+     * @param metaFactory
+     */
     public SOAP12Factory(OMLinkedListMetaFactory metaFactory) {
         super(metaFactory);
     }
 
+    /**
+     * @deprecated Use {@link OMAbstractFactory#getSOAP12Factory()} to get an instance of this
+     *             class.
+     */
     public SOAP12Factory() {
     }
 

Added: webservices/commons/trunk/modules/axiom/systests/spring-ws-tests/src/test/java/org/apache/axiom/systest/springws/AxiomSoapMessageTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/systests/spring-ws-tests/src/test/java/org/apache/axiom/systest/springws/AxiomSoapMessageTest.java?rev=1431647&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/systests/spring-ws-tests/src/test/java/org/apache/axiom/systest/springws/AxiomSoapMessageTest.java (added)
+++ webservices/commons/trunk/modules/axiom/systests/spring-ws-tests/src/test/java/org/apache/axiom/systest/springws/AxiomSoapMessageTest.java Thu Jan 10 21:14:42 2013
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.systest.springws;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.soap.SOAPFactory;
+import org.springframework.ws.soap.SoapHeaderElement;
+import org.springframework.ws.soap.axiom.AxiomSoapMessage;
+import org.springframework.ws.soap.axiom.AxiomSoapMessageFactory;
+import org.w3c.dom.Document;
+
+public class AxiomSoapMessageTest extends TestCase {
+    /**
+     * Tests that {@link AxiomSoapMessage#setDocument(Document)} works correctly. There have been
+     * issues with that method because Spring-WS instantiates {@link SOAPFactory} implementations
+     * directly instead of using {@link OMAbstractFactory}.
+     * 
+     * @throws Exception
+     */
+    public void testSetDocument() throws Exception {
+        AxiomSoapMessageFactory mf = new AxiomSoapMessageFactory();
+        mf.afterPropertiesSet();
+        AxiomSoapMessage message = mf.createWebServiceMessage();
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+        dbf.setNamespaceAware(true);
+        Document document = dbf.newDocumentBuilder().parse(AxiomSoapMessageTest.class.getResource("soap-message.xml").toString());
+        message.setDocument(document);
+        Iterator it = message.getEnvelope().getHeader().examineAllHeaderElements();
+        assertTrue(it.hasNext());
+        SoapHeaderElement headerElement = (SoapHeaderElement)it.next();
+        assertEquals(new QName("urn:test", "myHeader"), headerElement.getName());
+    }
+}

Propchange: webservices/commons/trunk/modules/axiom/systests/spring-ws-tests/src/test/java/org/apache/axiom/systest/springws/AxiomSoapMessageTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: webservices/commons/trunk/modules/axiom/systests/spring-ws-tests/src/test/resources/org/apache/axiom/systest/springws/soap-message.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/systests/spring-ws-tests/src/test/resources/org/apache/axiom/systest/springws/soap-message.xml?rev=1431647&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/systests/spring-ws-tests/src/test/resources/org/apache/axiom/systest/springws/soap-message.xml (added)
+++ webservices/commons/trunk/modules/axiom/systests/spring-ws-tests/src/test/resources/org/apache/axiom/systest/springws/soap-message.xml Thu Jan 10 21:14:42 2013
@@ -0,0 +1,9 @@
+<?xml version='1.0'?>
+<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
+    <env:Header>
+        <p:myHeader xmlns:p="urn:test">value</p:myHeader>
+    </env:Header>
+    <env:Body>
+        <p:echo xmlns:p="urn:test">hi!</p:echo>
+    </env:Body>
+</env:Envelope>
\ No newline at end of file

Propchange: webservices/commons/trunk/modules/axiom/systests/spring-ws-tests/src/test/resources/org/apache/axiom/systest/springws/soap-message.xml
------------------------------------------------------------------------------
    svn:eol-style = native