axis-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1368613 - in /axis/axis2/java/core/trunk/modules: jaxbri/ jaxbri/src/main/resources/org/apache/axis2/jaxbri/template/ jaxbri/src/test/java/org/apache/axis2/jaxbri/mtom/ jaxbri/src/test/wsdl/ parent/
Date Thu, 02 Aug 2012 17:29:37 GMT
Author: veithen
Date: Thu Aug  2 17:29:37 2012
New Revision: 1368613

URL: http://svn.apache.org/viewvc?rev=1368613&view=rev
Log:
Implemented full support for MTOM in the JAXBRI databinding.

Added:
    axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/mtom/
    axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/mtom/MtomImpl.java
  (with props)
    axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/mtom/MtomTest.java
  (with props)
    axis/axis2/java/core/trunk/modules/jaxbri/src/test/wsdl/mtom.wsdl
Modified:
    axis/axis2/java/core/trunk/modules/jaxbri/pom.xml
    axis/axis2/java/core/trunk/modules/jaxbri/src/main/resources/org/apache/axis2/jaxbri/template/JaxbRIDatabindingTemplate.xsl
    axis/axis2/java/core/trunk/modules/parent/pom.xml

Modified: axis/axis2/java/core/trunk/modules/jaxbri/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxbri/pom.xml?rev=1368613&r1=1368612&r2=1368613&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxbri/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/jaxbri/pom.xml Thu Aug  2 17:29:37 2012
@@ -73,6 +73,11 @@
             <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>axiom-testutils</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <url>http://axis.apache.org/axis2/java/core/</url>
     <scm>
@@ -164,6 +169,10 @@
                                     <classpath refid="maven.test.classpath" />
                                     <arg line="-d jaxbri -ss -ssi -sd -g -o ${project.build.directory}/gen/identityservice
-u -uri src/test/wsdl/identityService.wsdl -p org.apache.axis2.jaxbri.identityservice -ns2p
http://www.example.org/identity=org.apache.axis2.jaxbri.identityservice" />
                                 </java>
+                                <java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true">
+                                    <classpath refid="maven.test.classpath" />
+                                    <arg line="-d jaxbri -ss -ssi -sd -g -o ${project.build.directory}/gen/mtom
-u -uri src/test/wsdl/mtom.wsdl -p org.apache.axis2.jaxbri.mtom -ns2p http://www.example.org/mtom/=org.apache.axis2.jaxbri.mtom
-EbindingFileName " />
+                                </java>
                             </tasks>
                         </configuration>
                     </execution>
@@ -199,6 +208,7 @@
                                 <source>${project.build.directory}/gen/Test01/src</source>
                                 <source>${project.build.directory}/gen/processor/src</source>
                                 <source>${project.build.directory}/gen/identityservice/src</source>
+                                <source>${project.build.directory}/gen/mtom/src</source>
                             </sources>
                         </configuration>
                     </execution>
@@ -264,6 +274,25 @@
                             </resources>
                         </configuration>
                     </execution>
+                    <execution>
+                        <id>mtom-repo</id>
+                        <phase>generate-test-resources</phase>
+                        <goals>
+                            <goal>copy-resources</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}/repo/mtom</outputDirectory>
+                            <resources>
+                                <resource>
+                                    <directory>src/test/repo</directory>
+                                </resource>
+                                <resource>
+                                    <directory>${project.build.directory}/gen/mtom/resources</directory>
+                                    <targetPath>services/mtom.aar/META-INF</targetPath>
+                                </resource>
+                            </resources>
+                        </configuration>
+                    </execution>
                 </executions>
             </plugin>
             <plugin>

Modified: axis/axis2/java/core/trunk/modules/jaxbri/src/main/resources/org/apache/axis2/jaxbri/template/JaxbRIDatabindingTemplate.xsl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxbri/src/main/resources/org/apache/axis2/jaxbri/template/JaxbRIDatabindingTemplate.xsl?rev=1368613&r1=1368612&r2=1368613&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxbri/src/main/resources/org/apache/axis2/jaxbri/template/JaxbRIDatabindingTemplate.xsl
(original)
+++ axis/axis2/java/core/trunk/modules/jaxbri/src/main/resources/org/apache/axis2/jaxbri/template/JaxbRIDatabindingTemplate.xsl
Thu Aug  2 17:29:37 2012
@@ -210,8 +210,9 @@
             try {
                 javax.xml.bind.JAXBContext context = wsContext;
                 javax.xml.bind.Unmarshaller unmarshaller = context.createUnmarshaller();
-
-                return unmarshaller.unmarshal(param.getXMLStreamReaderWithoutCaching(), type).getValue();
+                org.apache.axiom.util.jaxb.UnmarshallerAdapter adapter = org.apache.axiom.util.jaxb.JAXBUtils.getUnmarshallerAdapter(param.getXMLStreamReaderWithoutCaching());
+                unmarshaller.setAttachmentUnmarshaller(adapter.getAttachmentUnmarshaller());
+                return unmarshaller.unmarshal(adapter.getReader(), type).getValue();
             } catch (javax.xml.bind.JAXBException bex){
                 throw org.apache.axis2.AxisFault.makeFault(bex);
             }

Added: axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/mtom/MtomImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/mtom/MtomImpl.java?rev=1368613&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/mtom/MtomImpl.java
(added)
+++ axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/mtom/MtomImpl.java
Thu Aug  2 17:29:37 2012
@@ -0,0 +1,52 @@
+/*
+ * 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.axis2.jaxbri.mtom;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.activation.DataHandler;
+
+import org.apache.axiom.attachments.lifecycle.DataHandlerExt;
+import org.apache.commons.io.IOUtils;
+
+public class MtomImpl implements MtomSkeletonInterface {
+    private final Map<String,byte[]> documents = new HashMap<String,byte[]>();
+    
+    public UploadDocumentResponse uploadDocument(UploadDocument uploadDocument) {
+        String id = UUID.randomUUID().toString();
+        try {
+            // If we don't get a DataHandlerExt here, then we know that we are not using
MTOM
+            documents.put(id, IOUtils.toByteArray(((DataHandlerExt)uploadDocument.getContent()).readOnce()));
+        } catch (IOException ex) {
+            throw new RuntimeException(ex);
+        }
+        UploadDocumentResponse response = new UploadDocumentResponse();
+        response.setId(id);
+        return response;
+    }
+
+    public RetrieveDocumentResponse retrieveDocument(RetrieveDocument retrieveDocument) {
+        RetrieveDocumentResponse response = new RetrieveDocumentResponse();
+        response.setContent(new DataHandler(documents.get(retrieveDocument.getId()), "application/octet-stream"));
+        return response;
+    }
+}

Propchange: axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/mtom/MtomImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/mtom/MtomTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/mtom/MtomTest.java?rev=1368613&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/mtom/MtomTest.java
(added)
+++ axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/mtom/MtomTest.java
Thu Aug  2 17:29:37 2012
@@ -0,0 +1,64 @@
+/*
+ * 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.axis2.jaxbri.mtom;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+
+import org.apache.axiom.testutils.activation.RandomDataSource;
+import org.apache.axiom.testutils.io.IOTestUtils;
+import org.apache.axis2.Constants;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.testutils.UtilServer;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class MtomTest {
+    private static final String ENDPOINT = "http://127.0.0.1:" + UtilServer.TESTING_PORT
+ "/axis2/services/mtom";
+    
+    @BeforeClass
+    public static void startServer() throws Exception {
+        UtilServer.start(System.getProperty("basedir", ".") + "/target/repo/mtom");
+        AxisConfiguration axisConfiguration = UtilServer.getConfigurationContext().getAxisConfiguration();
+        axisConfiguration.getParameter(Constants.Configuration.ENABLE_MTOM).setValue(true);
+        AxisService service = axisConfiguration.getService("mtom");
+        service.getParameter(Constants.SERVICE_CLASS).setValue(MtomImpl.class.getName());
+        service.setScope(Constants.SCOPE_APPLICATION);
+    }
+    
+    @AfterClass
+    public static void stopServer() throws Exception {
+        UtilServer.stop();
+    }
+    
+    @Test
+    public void test() throws Exception {
+        MtomStub stub = new MtomStub(UtilServer.getConfigurationContext(), ENDPOINT);
+        UploadDocument uploadRequest = new UploadDocument();
+        DataSource contentDS = new RandomDataSource(1234567L, 1024);
+        uploadRequest.setContent(new DataHandler(contentDS));
+        UploadDocumentResponse uploadResponse = stub.uploadDocument(uploadRequest);
+        RetrieveDocument retrieveRequest = new RetrieveDocument();
+        retrieveRequest.setId(uploadResponse.getId());
+        RetrieveDocumentResponse retrieveResponse = stub.retrieveDocument(retrieveRequest);
+        IOTestUtils.compareStreams(contentDS.getInputStream(), retrieveResponse.getContent().getInputStream());
+    }
+}

Propchange: axis/axis2/java/core/trunk/modules/jaxbri/src/test/java/org/apache/axis2/jaxbri/mtom/MtomTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: axis/axis2/java/core/trunk/modules/jaxbri/src/test/wsdl/mtom.wsdl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxbri/src/test/wsdl/mtom.wsdl?rev=1368613&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxbri/src/test/wsdl/mtom.wsdl (added)
+++ axis/axis2/java/core/trunk/modules/jaxbri/src/test/wsdl/mtom.wsdl Thu Aug  2 17:29:37
2012
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+  ~ 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.
+  -->
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+                  xmlns:tns="http://www.example.org/mtom/"
+                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+                  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+                  xmlns:xmime="http://www.w3.org/2005/05/xmlmime"
+                  name="mtom"
+                  targetNamespace="http://www.example.org/mtom/">
+    <wsdl:types>
+        <xsd:schema targetNamespace="http://www.example.org/mtom/">
+            <xsd:element name="uploadDocument">
+                <xsd:complexType>
+                    <xsd:sequence>
+                        <xsd:element name="content" type="xsd:base64Binary" xmime:expectedContentTypes="application/octet-stream"
/>
+                    </xsd:sequence>
+                </xsd:complexType>
+            </xsd:element>
+            <xsd:element name="uploadDocumentResponse">
+                <xsd:complexType>
+                    <xsd:sequence>
+                        <xsd:element name="id" type="xsd:string" />
+                    </xsd:sequence>
+                </xsd:complexType>
+            </xsd:element>
+            <xsd:element name="retrieveDocument">
+                <xsd:complexType>
+                    <xsd:sequence>
+                        <xsd:element name="id" type="xsd:string" />
+                    </xsd:sequence>
+                </xsd:complexType>
+            </xsd:element>
+            <xsd:element name="retrieveDocumentResponse">
+                <xsd:complexType>
+                    <xsd:sequence>
+                        <xsd:element name="content" type="xsd:base64Binary" xmime:expectedContentTypes="application/octet-stream"
/>
+                    </xsd:sequence>
+                </xsd:complexType>
+            </xsd:element>
+        </xsd:schema>
+    </wsdl:types>
+    <wsdl:message name="uploadDocumentRequest">
+        <wsdl:part name="parameters" element="tns:uploadDocument" />
+    </wsdl:message>
+    <wsdl:message name="uploadDocumentResponse">
+        <wsdl:part name="parameters" element="tns:uploadDocumentResponse" />
+    </wsdl:message>
+    <wsdl:message name="retrieveDocumentRequest">
+        <wsdl:part name="parameters" element="tns:retrieveDocument" />
+    </wsdl:message>
+    <wsdl:message name="retrieveDocumentResponse">
+        <wsdl:part name="parameters" element="tns:retrieveDocumentResponse" />
+    </wsdl:message>
+    <wsdl:portType name="mtom">
+        <wsdl:operation name="uploadDocument">
+            <wsdl:input message="tns:uploadDocumentRequest" />
+            <wsdl:output message="tns:uploadDocumentResponse" />
+        </wsdl:operation>
+        <wsdl:operation name="retrieveDocument">
+            <wsdl:input message="tns:retrieveDocumentRequest" />
+            <wsdl:output message="tns:retrieveDocumentResponse" />
+        </wsdl:operation>
+    </wsdl:portType>
+    <wsdl:binding name="mtomSOAP" type="tns:mtom">
+        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"
/>
+        <wsdl:operation name="uploadDocument">
+            <soap:operation soapAction="http://www.example.org/mtom/uploadDocument" />
+            <wsdl:input>
+                <soap:body use="literal" />
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal" />
+            </wsdl:output>
+        </wsdl:operation>
+        <wsdl:operation name="retrieveDocument">
+            <soap:operation soapAction="http://www.example.org/mtom/retrieveDocument"
/>
+            <wsdl:input>
+                <soap:body use="literal" />
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal" />
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:service name="mtom">
+        <wsdl:port binding="tns:mtomSOAP" name="mtomSOAP">
+            <soap:address location="http://www.example.org/" />
+        </wsdl:port>
+    </wsdl:service>
+</wsdl:definitions>

Modified: axis/axis2/java/core/trunk/modules/parent/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/parent/pom.xml?rev=1368613&r1=1368612&r2=1368613&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/parent/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/parent/pom.xml Thu Aug  2 17:29:37 2012
@@ -638,6 +638,11 @@
                 <version>${axiom.version}</version>
             </dependency>
             <dependency>
+                <groupId>org.apache.ws.commons.axiom</groupId>
+                <artifactId>axiom-testutils</artifactId>
+                <version>${axiom.version}</version>
+            </dependency>
+            <dependency>
                 <groupId>org.apache.ws.commons.schema</groupId>
                 <artifactId>XmlSchema</artifactId>
                 <version>${xmlschema.version}</version>



Mime
View raw message