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 2014/06/06 18:02:22 UTC
svn commit: r1600944 - in /webservices/axiom/trunk/axiom-spring-ws/src:
main/java/org/apache/axiom/spring/ws/
main/java/org/apache/axiom/spring/ws/pox/
main/java/org/apache/axiom/spring/ws/soap/
test/java/org/apache/axiom/spring/ws/test/
Author: veithen
Date: Fri Jun 6 16:02:21 2014
New Revision: 1600944
URL: http://svn.apache.org/r1600944
Log:
AXIOM-447 - Iteration 5 - Implementation: Support full streaming for JAXB2. In particular, add StreamingWebServiceMessage support.
Added:
webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/soap/StreamingPayloadOMDataSource.java (with props)
Modified:
webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/AxiomOptimizationEnabler.java
webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/AxiomWebServiceMessage.java
webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/SourceExtractionStrategy.java
webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/pox/PoxMessageImpl.java
webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/soap/SoapMessageImpl.java
webservices/axiom/trunk/axiom-spring-ws/src/test/java/org/apache/axiom/spring/ws/test/LLOMSpringWSTest.java
Modified: webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/AxiomOptimizationEnabler.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/AxiomOptimizationEnabler.java?rev=1600944&r1=1600943&r2=1600944&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/AxiomOptimizationEnabler.java (original)
+++ webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/AxiomOptimizationEnabler.java Fri Jun 6 16:02:21 2014
@@ -39,6 +39,7 @@ import org.springframework.ws.server.End
import org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResolver;
import org.springframework.ws.server.endpoint.adapter.method.dom.DomPayloadMethodProcessor;
import org.springframework.ws.server.endpoint.adapter.method.dom.JDomPayloadMethodProcessor;
+import org.springframework.ws.server.endpoint.adapter.method.jaxb.AbstractJaxb2PayloadMethodProcessor;
import org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping;
import org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping;
@@ -70,6 +71,10 @@ import org.springframework.ws.soap.addre
* <td>{@link AnnotationActionEndpointMapping}
* <td>{@link SourceExtractionStrategy#DOM_OR_SAX_PRESERVE}
* </tr>
+ * <tr>
+ * <td>{@link AbstractJaxb2PayloadMethodProcessor}
+ * <td>{@link SourceExtractionStrategy#STAX_CONSUME}
+ * </tr>
* </table>
* <p>
* TODO: note about the implications of the fact that proxies for {@link MethodArgumentResolver} use
@@ -109,6 +114,7 @@ public class AxiomOptimizationEnabler im
strategyMap.put(JDomPayloadMethodProcessor.class, SourceExtractionStrategy.SAX_CONSUME);
strategyMap.put(DomPayloadMethodProcessor.class, SourceExtractionStrategy.DOM_OR_SAX_CONSUME);
strategyMap.put(AnnotationActionEndpointMapping.class, SourceExtractionStrategy.DOM_OR_SAX_PRESERVE);
+ strategyMap.put(AbstractJaxb2PayloadMethodProcessor.class, SourceExtractionStrategy.STAX_CONSUME);
try {
strategyMap.put(Class.forName("org.springframework.ws.soap.addressing.server.AddressingEndpointInterceptor"), SourceExtractionStrategy.DOM_OR_SAX_PRESERVE);
} catch (ClassNotFoundException ex) {
Modified: webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/AxiomWebServiceMessage.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/AxiomWebServiceMessage.java?rev=1600944&r1=1600943&r2=1600944&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/AxiomWebServiceMessage.java (original)
+++ webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/AxiomWebServiceMessage.java Fri Jun 6 16:02:21 2014
@@ -27,12 +27,13 @@ import org.springframework.ws.WebService
import org.springframework.ws.server.endpoint.support.PayloadRootUtils;
import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.SoapElement;
+import org.springframework.ws.stream.StreamingWebServiceMessage;
/**
* Interface implemented by {@link WebServiceMessage} instances created by
* {@link AxiomSoapMessageFactory}.
*/
-public interface AxiomWebServiceMessage extends WebServiceMessage {
+public interface AxiomWebServiceMessage extends StreamingWebServiceMessage {
/**
* Returns the root qualified name of the payload of this message. The return value is the same
* as that of {@link PayloadRootUtils#getPayloadRootQName(Source, TransformerFactory)} when
Modified: webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/SourceExtractionStrategy.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/SourceExtractionStrategy.java?rev=1600944&r1=1600943&r2=1600944&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/SourceExtractionStrategy.java (original)
+++ webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/SourceExtractionStrategy.java Fri Jun 6 16:02:21 2014
@@ -21,6 +21,7 @@ package org.apache.axiom.spring.ws;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stax.StAXSource;
import org.apache.axiom.om.OMContainer;
import org.springframework.ws.WebServiceMessage;
@@ -71,6 +72,38 @@ import org.w3c.dom.Node;
*/
public interface SourceExtractionStrategy {
/**
+ * Extraction strategy that creates a {@link StAXSource} using
+ * {@link OMContainer#getXMLStreamReader(boolean) with <code>cache</code> set to
+ * <code>true</code>.
+ */
+ SourceExtractionStrategy STAX_PRESERVE = new SourceExtractionStrategy() {
+ public Source getSource(OMContainer container) {
+ return new StAXSource(container.getXMLStreamReader(true));
+ }
+
+ @Override
+ public String toString() {
+ return "STAX_PRESERVE";
+ }
+ };
+
+ /**
+ * Extraction strategy that creates a {@link StAXSource} using
+ * {@link OMContainer#getXMLStreamReader(boolean) with <code>cache</code> set to
+ * <code>false</code>.
+ */
+ SourceExtractionStrategy STAX_CONSUME = new SourceExtractionStrategy() {
+ public Source getSource(OMContainer container) {
+ return new StAXSource(container.getXMLStreamReader(false));
+ }
+
+ @Override
+ public String toString() {
+ return "STAX_CONSUME";
+ }
+ };
+
+ /**
* Extraction strategy that uses {@link OMContainer#getSAXSource(boolean)} with
* <code>cache</code> set to <code>true</code>.
*/
Modified: webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/pox/PoxMessageImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/pox/PoxMessageImpl.java?rev=1600944&r1=1600943&r2=1600944&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/pox/PoxMessageImpl.java (original)
+++ webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/pox/PoxMessageImpl.java Fri Jun 6 16:02:21 2014
@@ -28,6 +28,7 @@ import javax.xml.transform.Source;
import org.apache.axiom.spring.ws.AxiomWebServiceMessage;
import org.apache.axiom.spring.ws.SourceExtractionStrategy;
import org.apache.axiom.spring.ws.SourceExtractionStrategyStack;
+import org.springframework.ws.stream.StreamingPayload;
final class PoxMessageImpl implements AxiomWebServiceMessage {
private final SourceExtractionStrategyStack extractionStrategyStack = new SourceExtractionStrategyStack();
@@ -52,6 +53,11 @@ final class PoxMessageImpl implements Ax
throw new UnsupportedOperationException();
}
+ public void setStreamingPayload(StreamingPayload payload) {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+
public void pushSourceExtractionStrategy(SourceExtractionStrategy strategy, Object bean) {
extractionStrategyStack.push(strategy, bean);
}
Modified: webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/soap/SoapMessageImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/soap/SoapMessageImpl.java?rev=1600944&r1=1600943&r2=1600944&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/soap/SoapMessageImpl.java (original)
+++ webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/soap/SoapMessageImpl.java Fri Jun 6 16:02:21 2014
@@ -29,6 +29,7 @@ import javax.xml.stream.XMLStreamExcepti
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMOutputFormat;
import org.apache.axiom.soap.SOAP11Version;
+import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axiom.soap.SOAPMessage;
@@ -42,6 +43,7 @@ import org.springframework.ws.mime.Attac
import org.springframework.ws.soap.AbstractSoapMessage;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.SoapEnvelopeException;
+import org.springframework.ws.stream.StreamingPayload;
import org.springframework.ws.transport.TransportConstants;
import org.springframework.ws.transport.TransportOutputStream;
import org.w3c.dom.Document;
@@ -138,6 +140,12 @@ final class SoapMessageImpl extends Abst
return qname;
}
+ public void setStreamingPayload(StreamingPayload payload) {
+ SOAPBody body = axiomMessage.getSOAPEnvelope().getBody();
+ body.removeChildren();
+ body.addChild(axiomMessage.getOMFactory().createOMElement(new StreamingPayloadOMDataSource(payload)));
+ }
+
public void pushSourceExtractionStrategy(SourceExtractionStrategy strategy, Object bean) {
extractionStrategyStack.push(strategy, bean);
}
Added: webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/soap/StreamingPayloadOMDataSource.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/soap/StreamingPayloadOMDataSource.java?rev=1600944&view=auto
==============================================================================
--- webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/soap/StreamingPayloadOMDataSource.java (added)
+++ webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/soap/StreamingPayloadOMDataSource.java Fri Jun 6 16:02:21 2014
@@ -0,0 +1,59 @@
+/*
+ * 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.spring.ws.soap;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.om.QNameAwareOMDataSource;
+import org.apache.axiom.om.ds.AbstractPushOMDataSource;
+import org.springframework.ws.stream.StreamingPayload;
+
+final class StreamingPayloadOMDataSource extends AbstractPushOMDataSource implements QNameAwareOMDataSource {
+ private final StreamingPayload payload;
+
+ public StreamingPayloadOMDataSource(StreamingPayload payload) {
+ this.payload = payload;
+ }
+
+ public boolean isDestructiveWrite() {
+ // Note that the StreamingPayload contract doesn't specify if the payload can be
+ // written multiple times. We assume that it can. In particular this is true
+ // for JaxbStreamingPayload.
+ return false;
+ }
+
+ public void serialize(XMLStreamWriter streamWriter) throws XMLStreamException {
+ payload.writeTo(streamWriter);
+ }
+
+ public String getLocalName() {
+ return payload.getName().getLocalPart();
+ }
+
+ public String getNamespaceURI() {
+ return payload.getName().getNamespaceURI();
+ }
+
+ public String getPrefix() {
+ // It is unlikely that the StreamingPayload correctly predicts the prefix
+ // that will be used.
+ return null;
+ }
+}
Propchange: webservices/axiom/trunk/axiom-spring-ws/src/main/java/org/apache/axiom/spring/ws/soap/StreamingPayloadOMDataSource.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axiom/trunk/axiom-spring-ws/src/test/java/org/apache/axiom/spring/ws/test/LLOMSpringWSTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/axiom-spring-ws/src/test/java/org/apache/axiom/spring/ws/test/LLOMSpringWSTest.java?rev=1600944&r1=1600943&r2=1600944&view=diff
==============================================================================
--- webservices/axiom/trunk/axiom-spring-ws/src/test/java/org/apache/axiom/spring/ws/test/LLOMSpringWSTest.java (original)
+++ webservices/axiom/trunk/axiom-spring-ws/src/test/java/org/apache/axiom/spring/ws/test/LLOMSpringWSTest.java Fri Jun 6 16:02:21 2014
@@ -21,7 +21,6 @@ package org.apache.axiom.spring.ws.test;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.ts.springws.MessageFactoryConfigurator;
import org.apache.axiom.ts.springws.SpringWSTestSuiteBuilder;
-import org.apache.axiom.ts.springws.jaxb2.JAXB2Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -30,9 +29,6 @@ public class LLOMSpringWSTest extends Te
public static TestSuite suite() {
SpringWSTestSuiteBuilder builder = new SpringWSTestSuiteBuilder(new AxiomMessageFactoryConfigurator(OMAbstractFactory.FEATURE_DEFAULT), MessageFactoryConfigurator.SAAJ);
- // TODO: Iteration 5
- builder.exclude(JAXB2Test.class);
-
return builder.build();
}
}