You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2010/12/30 14:00:06 UTC

svn commit: r1053881 - in /axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message: attachments/AttachmentUtils.java util/MessageUtils.java

Author: veithen
Date: Thu Dec 30 13:00:06 2010
New Revision: 1053881

URL: http://svn.apache.org/viewvc?rev=1053881&view=rev
Log:
Removed some dead and/or deprecated code in order to get rid of references to classes in org.apache.axiom.om.impl.

Modified:
    axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/AttachmentUtils.java
    axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/util/MessageUtils.java

Modified: axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/AttachmentUtils.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/AttachmentUtils.java?rev=1053881&r1=1053880&r2=1053881&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/AttachmentUtils.java (original)
+++ axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/AttachmentUtils.java Thu Dec 30 13:00:06 2010
@@ -23,10 +23,7 @@ import org.apache.axiom.attachments.Atta
 import org.apache.axiom.attachments.CachedFileDataSource;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMText;
-import org.apache.axiom.om.impl.OMNavigator;
-import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -34,7 +31,6 @@ import javax.activation.DataHandler;
 import javax.activation.DataSource;
 import javax.xml.namespace.QName;
 import java.io.File;
-import java.util.ArrayList;
 
 /** A suite of utilities used for handling MTOM attachment data. */
 public class AttachmentUtils {
@@ -44,122 +40,6 @@ public class AttachmentUtils {
             new QName("http://www.w3.org/2004/08/xop/include", "Include");
 
     /**
-     * Can be used to find all instances of the <pre><xop:include></pre> element
-     * within a given OM SOAPEnvelope.
-     *
-     * @param env
-     * @return
-     */
-    public static ArrayList<OMElement> findXopElements(OMElement env) {
-        ArrayList<OMElement> xops = new ArrayList<OMElement>();
-        findXopElements(env, xops);
-        return xops;
-    }
-
-    /*
-    * A recursive search for all of the <xop:include> elements in the tree.
-    */
-    private static void findXopElements(OMElement root, ArrayList<OMElement> xops) {
-
-        //      Forces a parse.  This seems to be necessary due to bugs in OMNavigator
-        root.getNextOMSibling();
-
-        // Navigator does a traversal that mimics the structure of an xml document. 
-        // Each non-element object is processed once.
-        // Each element object is visited prior to its children and after its children.
-        // 
-        // Suppose you have the following tree (caps are elements, lowers are text)
-        // 
-        //     A
-        //    / \
-        //   B   C
-        //  /\   /\
-        //  D e F  g
-        //
-        // The traversal is
-        // is A B D D' e B' C F F' g C' A'
-        // The ' indicates that this is the second time the node is visited (i.e. nav.visited() 
-        // returns true)
-
-        OMNavigator nav = new OMNavigator(root);
-
-        while (nav.isNavigable()) {
-            OMNode curr = nav.next();
-
-            // Inspect elements that have been visited. 
-            // It is probably safer to inspect the node when it is visited, because 
-            // this guarantees that its children have been processed/expanded.
-            if (nav.visited() && curr instanceof OMElement) {
-                OMElement element = (OMElement)curr;
-                if (element.getQName().equals(XOP_INCLUDE)) {
-                    if (log.isDebugEnabled()) {
-                        log.debug("[XOP_INCLUDE] " + element.getLocalName());
-                    }
-                    xops.add(element);
-                }
-            }
-        }
-    }
-
-    /**
-     * Can be used to find all of the nodes in a tree that contain binary content that is targetted
-     * for optimization via MTOM.
-     *
-     * @param env
-     * @return
-     */
-    public static ArrayList<OMText> findBinaryNodes(SOAPEnvelope env) {
-        ArrayList<OMText> nodes = new ArrayList<OMText>();
-        findBinaryElements(env, nodes);
-        return nodes;
-    }
-
-    /*
-    * A recursive search for all of the binary, optimized nodes in a tree.
-    */
-    private static void findBinaryElements(OMNode node, ArrayList<OMText> attachments) {
-
-        // Forces a parse.  This seems to be necessary due to bugs in OMNavigator
-        node.getNextOMSibling();
-
-        // Navigator does a traversal that mimics the structure of an xml document. 
-        // Each non-element object is processed once.
-        // Each element object is visited prior to its children and after its children.
-        // 
-        // Suppose you have the following tree (caps are elements, lowers are text)
-        // 
-        //     A
-        //    / \
-        //   B   C
-        //  /\   /\
-        //  D e F  g
-        // 
-        // The traversal is
-        // The traversal is
-        // is A B D D' e B' C F F' g C' A'
-        // The ' indicates that this is the second time the node is visited 
-        // (i.e. nav.isVisited() returns true)
-        OMNavigator nav = new OMNavigator(node);
-
-        while (nav.isNavigable()) {
-            OMNode curr = nav.next();
-            if (curr instanceof OMText) {
-                // If it's an OMText, see if its optimized and add it to the list
-                if (log.isDebugEnabled())
-                    log.debug("text node found");
-
-                OMText textNode = (OMText)curr;
-                if (textNode.isOptimized()) {
-                    if (log.isDebugEnabled())
-                        log.debug("optimized text node found");
-
-                    attachments.add(textNode);
-                }
-            }
-        }
-    }
-
-    /**
      * Given an <pre><xop:include></pre> element, create an OMText element
      * with the appropriate attachment data.
      *

Modified: axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/util/MessageUtils.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/util/MessageUtils.java?rev=1053881&r1=1053880&r2=1053881&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/util/MessageUtils.java (original)
+++ axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/message/util/MessageUtils.java Thu Dec 30 13:00:06 2010
@@ -19,14 +19,11 @@
 
 package org.apache.axis2.jaxws.message.util;
 
-import org.apache.axiom.attachments.Attachments;
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMDocument;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.OMXMLParserWrapper;
-import org.apache.axiom.om.impl.MTOMConstants;
 import org.apache.axiom.om.impl.builder.StAXBuilder;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAPEnvelope;
@@ -44,7 +41,6 @@ import org.apache.axis2.jaxws.handler.Tr
 import org.apache.axis2.jaxws.i18n.Messages;
 import org.apache.axis2.jaxws.message.Message;
 import org.apache.axis2.jaxws.message.Protocol;
-import org.apache.axis2.jaxws.message.attachments.AttachmentUtils;
 import org.apache.axis2.jaxws.message.factory.MessageFactory;
 import org.apache.axis2.jaxws.registry.FactoryRegistry;
 import org.apache.axis2.jaxws.utility.JavaUtils;
@@ -53,7 +49,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import javax.activation.DataHandler;
-import javax.xml.namespace.QName;
 import javax.xml.soap.AttachmentPart;
 import javax.xml.soap.SOAPMessage;
 import javax.xml.ws.WebServiceException;
@@ -64,8 +59,6 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.Map;
 
 /** Miscellaneous Utilities that may be useful inside and outside the Message subcomponent. */
@@ -177,10 +170,6 @@ public class MessageUtils {
             if (soapEnv.hasFault()) {
                 soapEnv.toString();
             }
-
-            if (false) {
-                makeXOPIncludeNodes(msgContext, message);
-            }
         }
         return message;
     }
@@ -236,101 +225,7 @@ public class MessageUtils {
         if (message.isMTOMEnabled()) {
             // Enable MTOM on the Axis2 MessageContext
             msgContext.setProperty(Configuration.ENABLE_MTOM, "true");
-            if (false) {
-                makeBinaryNodes(message);
-            }
-        }
-    }
-    
-    /**
-     * Used to expand the tree and create binary nodes
-     * @param msg
-     * @deprecated
-     */
-    private static void makeBinaryNodes(Message msg) {
-        if (log.isDebugEnabled()) {
-            log.debug("MTOM is enabled on the JAX-WS Message...look for XOP Includes");
         }
-        // If we have MTOM attachments, we need to replace the <xop:include>
-        // elements with OMText binary nodes.
-        
-        // First find all of the <xop:include> elements
-        SOAPEnvelope envelope = (SOAPEnvelope) msg.getAsOMElement();
-        ArrayList<OMElement> xops = AttachmentUtils.findXopElements(envelope);
-        
-        if (xops != null && xops.size() > 0) {
-            if (log.isDebugEnabled()) {
-                log.debug("Found XOP:Include Elements");
-            }
-            
-            QName href = new QName("","href");
-            Iterator<OMElement> itr = xops.iterator();
-            
-            
-            while (itr.hasNext()) {
-                OMElement xop = itr.next();
-                String cid = xop.getAttributeValue(href);
-                
-                // Find and remove the Attachment from the JAX-WS Message
-                // (It is removed so that it is not considered a SWA Attachment ...see below)
-                DataHandler dh = msg.removeDataHandler(cid);
-                if (log.isDebugEnabled()) {
-                    log.debug("Create Binary OMNode for attachment:" + cid);
-                }
-                
-                // Convert the <xop:include> OMElement into an OMText
-                // binary node and replace it in the tree.                    
-                OMText binaryNode = AttachmentUtils.makeBinaryOMNode(xop, dh);
-                xop.insertSiblingAfter(binaryNode);
-                xop.detach();
-            }
-        }
-    }
-    
-    /**
-     * Expand the tree and create XOP nodes
-     * @param msg
-     * @deprecated
-     */
-    private static void makeXOPIncludeNodes(MessageContext msgContext, Message message) {
-        // This destroys performance by forcing a double pass through the message.
-        //If attachments are found on the MessageContext, then that means
-        //the inbound message has more than just the normal XML payload
-        Attachments as = (Attachments) msgContext.getProperty(MTOMConstants.ATTACHMENTS); 
-        if (as != null) { 
-            if (log.isDebugEnabled()) {
-                log.debug("Found Axis MTOM Attachments");
-            }
-            
-            //Walk the tree and find all of the optimized binary nodes.
-            ArrayList<OMText> binaryNodes = AttachmentUtils.findBinaryNodes((SOAPEnvelope) message.getAsOMElement());
-            if (binaryNodes != null  && binaryNodes.size() > 0) {
-                
-                if (log.isDebugEnabled()) {
-                    log.debug("Found " + binaryNodes.size() +"MTOM Binary Nodes");
-                }
-                
-                
-                //Replace each of the nodes with it's corresponding <xop:include>
-                //element, so JAXB can process it correctly.
-                Iterator<OMText> itr = binaryNodes.iterator();
-                while (itr.hasNext()) {
-                    OMText node = itr.next();
-                    OMElement xop = AttachmentUtils.makeXopElement(node);
-                    node.getParent().addChild(xop);
-                    node.detach();
-                    
-                    //We have to add the individual attachments in their raw
-                    //binary form, so we can access them later.
-                    if (log.isDebugEnabled()) {
-                        log.debug("Create MTOM Message Attachment for " + node.getContentID());
-                    }
-                    message.addDataHandler(
-                            (DataHandler) node.getDataHandler(), 
-                            node.getContentID());
-                }
-            }
-        } 
     }
     
     /**