You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sc...@apache.org on 2007/07/11 18:17:43 UTC

svn commit: r555323 - in /webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description: ./ impl/

Author: scheu
Date: Wed Jul 11 09:17:40 2007
New Revision: 555323

URL: http://svn.apache.org/viewvc?view=rev&rev=555323
Log:
JIRA=AXIS2:2943
Contributor:Rich Scheuerle
This is the metadata layer scaffolding to capture an AttachmentDescription.
This code will be used in subsequent commits to marshal and unmarshal JAX-WS rpc/lit
attachments.

Added:
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/AttachmentDescription.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/AttachmentType.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/AttachmentDescriptionImpl.java
Modified:
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/OperationDescription.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ParameterDescription.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ParameterDescriptionImpl.java

Added: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/AttachmentDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/AttachmentDescription.java?view=auto&rev=555323
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/AttachmentDescription.java (added)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/AttachmentDescription.java Wed Jul 11 09:17:40 2007
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.jaxws.description;
+
+/**
+ * A parameter or return value may be represented as an attachment.
+ * In such cases, the ParameterDescription or OperationDescription has
+ * an AttachmentDescription defining the attachment information.
+ * 
+ * Note that an Attachment may be one of 3 types: SWA, SWAREF and MTOM.
+ *    SWAREF and MTOM attachments have an xml element (either in the body or header) 
+ *    that references the attachment part.
+ *    
+ *    SWA attachments are represented as an attachment part.  There are is no
+ *    xml element that references the attachment.
+ *
+ */
+public interface AttachmentDescription {
+    
+    /**
+     * @Return The attachment type 
+     */
+    AttachmentType getAttachmentType();
+    
+    /**
+     * @return one or more mime types defined for this attachment
+     */
+    String[] getMimeTypes();
+}

Added: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/AttachmentType.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/AttachmentType.java?view=auto&rev=555323
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/AttachmentType.java (added)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/AttachmentType.java Wed Jul 11 09:17:40 2007
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.jaxws.description;
+
+/**
+ * Defines the different types of attachments.
+ */
+public enum AttachmentType {
+    SWA,      // Defined by Binding MIME Types, no xml references the attachment
+    SWAREF,   // Defined by SWAREF, xml references the attachment
+    MTOM      // Defined by MTOM specification, xml references the attachment
+}

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/OperationDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/OperationDescription.java?view=diff&rev=555323&r1=555322&r2=555323
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/OperationDescription.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/OperationDescription.java Wed Jul 11 09:17:40 2007
@@ -217,4 +217,8 @@
     */
     public String getBindingOutputNamespace();
     
+    /**
+    * @return Attachment Description for the return type or null
+    */
+    public AttachmentDescription getResultAttachmentDescription();
 }

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ParameterDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ParameterDescription.java?view=diff&rev=555323&r1=555322&r2=555323
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ParameterDescription.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ParameterDescription.java Wed Jul 11 09:17:40 2007
@@ -73,6 +73,10 @@
 //  TODO: Fix this to not be the WebParam mode
 
     public WebParam.Mode getMode();
-
+    
+    /**
+     * @return AttachmentDescription for this parameter or null
+     */
+    public AttachmentDescription getAttachmentDescription();
 
 }

Added: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/AttachmentDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/AttachmentDescriptionImpl.java?view=auto&rev=555323
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/AttachmentDescriptionImpl.java (added)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/AttachmentDescriptionImpl.java Wed Jul 11 09:17:40 2007
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed 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.jaxws.description.impl;
+
+import org.apache.axis2.jaxws.description.AttachmentType;
+
+public class AttachmentDescriptionImpl implements
+        org.apache.axis2.jaxws.description.AttachmentDescription {
+
+    private AttachmentType attachmentType;
+    private String[] mimeTypes;
+    
+    /**
+     * @param attachmentType
+     * @param mimeTypes
+     */
+    public AttachmentDescriptionImpl(AttachmentType attachmentType, String[] mimeTypes) {
+        this.attachmentType = attachmentType;
+        this.mimeTypes = mimeTypes;
+    }
+
+    public AttachmentType getAttachmentType() {
+        return attachmentType;
+    }
+
+    public String[] getMimeTypes() {
+        return mimeTypes;
+    }
+    
+    public String toString() {
+        final String newline = "\n";
+        final String sameline = "; ";
+        StringBuffer string = new StringBuffer();
+        
+        string.append(super.toString());
+        string.append(newline);
+        string.append("  Attachment Type: " + getAttachmentType());
+        //
+        string.append(newline);
+        string.append("  Mime Types: " + getMimeTypes());
+        return string.toString();
+    }
+
+}

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java?view=diff&rev=555323&r1=555322&r2=555323
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java Wed Jul 11 09:17:40 2007
@@ -27,6 +27,8 @@
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.WSDL2Constants;
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.description.AttachmentDescription;
+import org.apache.axis2.jaxws.description.AttachmentType;
 import org.apache.axis2.jaxws.description.EndpointDescriptionJava;
 import org.apache.axis2.jaxws.description.EndpointInterfaceDescription;
 import org.apache.axis2.jaxws.description.FaultDescription;
@@ -164,6 +166,11 @@
     // Default value per JSR-181 MR sec 4.5, pg 24
     public static final Boolean WebResult_Header_DEFAULT = new Boolean(false);
     private Boolean webResultHeader;
+    
+    //  Web Result Attachment Description information
+    private boolean             _setAttachmentDesc = false;
+    private AttachmentDescription attachmentDesc = null;
+    
     private Method serviceImplMethod;
     private boolean serviceImplMethodFound = false;
     // For JAX-WS client async methods, this is the corresponding Sync method; for everything else,
@@ -1754,6 +1761,38 @@
         return null;
     }
     
+    public AttachmentDescription getResultAttachmentDescription() {
+        if (_setAttachmentDesc) {
+            return attachmentDesc;
+        }
+        _setAttachmentDesc = true;
+
+        // TODO
+        // The annotation description should be constructed using the
+        // wsdl information.  
+        // In order to test the marshalling processing, I am 
+        // creating a dummy attachment triggered solely by the part name and
+        // part type.
+
+        String partName = this.getResultPartName();
+        if (partName != null && 
+                partName.startsWith("dummyAttachment")) {
+            Class paramType = getResultActualType();
+            if (paramType == String.class) {
+                // TODO For the purposes of testing, assume this is text/plain
+                attachmentDesc = new AttachmentDescriptionImpl(AttachmentType.SWAREF,
+                                                               new String[] {"text/plain"});
+
+            } else if (paramType == byte[].class) {
+                // TODO For the purposes of testing, assume this is image/gif
+                attachmentDesc = new AttachmentDescriptionImpl(AttachmentType.SWAREF,
+                                                               new String[] {"text/plain"});
+            }
+        }
+
+        return attachmentDesc;
+    }
+            
     public String toString() {
         final String newline = "\n";
         final String sameline = "; ";
@@ -1793,6 +1832,10 @@
             string.append("Result type: " + getResultType());
             string.append(sameline);
             string.append("Result actual type: " + getResultActualType());
+            if (getResultAttachmentDescription() != null) {
+                string.append(newline);
+                string.append(getResultAttachmentDescription().toString());
+            }
             //
             string.append(newline);
             string.append("Request Wrapper class: " + getRequestWrapperClassName());

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ParameterDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ParameterDescriptionImpl.java?view=diff&rev=555323&r1=555322&r2=555323
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ParameterDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ParameterDescriptionImpl.java Wed Jul 11 09:17:40 2007
@@ -20,6 +20,8 @@
 
 package org.apache.axis2.jaxws.description.impl;
 
+import org.apache.axis2.jaxws.description.AttachmentDescription;
+import org.apache.axis2.jaxws.description.AttachmentType;
 import org.apache.axis2.jaxws.description.EndpointDescriptionJava;
 import org.apache.axis2.jaxws.description.OperationDescription;
 import org.apache.axis2.jaxws.description.ParameterDescription;
@@ -64,6 +66,10 @@
     public static final Boolean WebParam_Header_DEFAULT = new Boolean(false);
     private Boolean webParamHeader;
     
+    // Attachment Description information
+    private boolean             _setAttachmentDesc = false;
+    private AttachmentDescription attachmentDesc = null;
+    
     // This boolean indicates whether or not there was an @XMLList on the parameter
     private boolean isListType = false;
     
@@ -375,6 +381,10 @@
             string.append("Type: " + getParameterType());
             string.append(sameline);
             string.append("Actual type: " + getParameterActualType());
+            if (getAttachmentDescription() != null) {
+                string.append(newline);
+                string.append(getAttachmentDescription().toString());
+            }
         }
         catch (Throwable t) {
             string.append(newline);
@@ -387,5 +397,38 @@
 
     public boolean isListType() {
     	return isListType;
+    }
+    
+    public AttachmentDescription getAttachmentDescription() {
+        if (_setAttachmentDesc) {
+            return attachmentDesc;
+        }
+        _setAttachmentDesc = true;
+        
+        // TODO
+        // The annotation description should be constructed using the
+        // wsdl information.  
+        // In order to test the marshalling processing, I am 
+        // creating a dummy attachment triggered solely by the part name and
+        // part type.
+        
+        String partName = this.getPartName();
+        if (partName != null && 
+            partName.startsWith("dummyAttachment")) {
+            Class paramType = getParameterActualType();
+            if (paramType == String.class) {
+                // TODO For the purposes of testing, assume this is text/plain
+                attachmentDesc = new AttachmentDescriptionImpl(AttachmentType.SWAREF,
+                        new String[] {"text/plain"});
+                
+            } else if (paramType == byte[].class) {
+                // TODO For the purposes of testing, assume this is image/gif
+                attachmentDesc = new AttachmentDescriptionImpl(AttachmentType.SWAREF,
+                        new String[] {"text/plain"});
+            }
+            
+        }
+       
+        return attachmentDesc;
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org