axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davidills...@apache.org
Subject svn commit: r580330 - in /webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing: AddressingInHandler.java AddressingOutHandler.java
Date Fri, 28 Sep 2007 12:42:57 GMT
Author: davidillsley
Date: Fri Sep 28 05:42:56 2007
New Revision: 580330

URL: http://svn.apache.org/viewvc?rev=580330&view=rev
Log:
Small perf improvements. Allow EPR refparam extraction to be
disabled if not required.

Modified:
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
    webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java?rev=580330&r1=580329&r2=580330&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
(original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingInHandler.java
Fri Sep 28 05:42:56 2007
@@ -19,6 +19,11 @@
 
 package org.apache.axis2.handlers.addressing;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPHeader;
@@ -31,22 +36,33 @@
 import org.apache.axis2.addressing.RelatesTo;
 import org.apache.axis2.client.Options;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.HandlerDescription;
 import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.util.LoggingControl;
+import org.apache.axis2.util.Utils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.Iterator;
-
 public abstract class AddressingInHandler extends AbstractHandler implements AddressingConstants
{
 
     protected String addressingNamespace = Final.WSA_NAMESPACE;  // defaulting to final version
     protected String addressingVersion = null;
+    
+	public static final String DISABLE_REF_PARAMETER_EXTRACT = "disableRefParamExtract";
+    
     private static final Log log = LogFactory.getLog(AddressingInHandler.class);
 
-
+    private boolean disableRefparamExtract = false;
+    	  	 
+    public void init(HandlerDescription handlerdesc) {
+    	super.init(handlerdesc);
+    	disableRefparamExtract = JavaUtils.isTrueExplicitly(Utils.getParameterValue(handlerdesc.getParameter(DISABLE_REF_PARAMETER_EXTRACT)));
+    	if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
+    		log.debug("AddressingInHandler.init disableRefparamExtract="+disableRefparamExtract);
+    	}
+    }
+    
     public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
         // if another handler has already processed the addressing headers, do not do anything
here.
         if (msgContext.isPropertyTrue(IS_ADDR_INFO_ALREADY_PROCESSED)) {
@@ -128,22 +144,23 @@
             SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock)addressingHeadersIt.next();
             // TODO - Don't do role processing here!
             if (!SOAP12Constants.SOAP_ROLE_NONE.equals(soapHeaderBlock.getRole())) {
-                if (WSA_ACTION.equals(soapHeaderBlock.getLocalName())) {
+            	String localName = soapHeaderBlock.getLocalName();
+            	if (WSA_ACTION.equals(localName)) {
                     ignoreAction = checkDuplicateHeaders(WSA_ACTION, checkedHeaderNames,
                                                          duplicateHeaderNames);
-                } else if (WSA_TO.equals(soapHeaderBlock.getLocalName())) {
+                } else if (WSA_TO.equals(localName)) {
                     ignoreTo =
                             checkDuplicateHeaders(WSA_TO, checkedHeaderNames, duplicateHeaderNames);
-                } else if (WSA_MESSAGE_ID.equals(soapHeaderBlock.getLocalName())) {
+                } else if (WSA_MESSAGE_ID.equals(localName)) {
                     ignoreMessageID = checkDuplicateHeaders(WSA_MESSAGE_ID, checkedHeaderNames,
                                                             duplicateHeaderNames);
-                } else if (WSA_REPLY_TO.equals(soapHeaderBlock.getLocalName())) {
+                } else if (WSA_REPLY_TO.equals(localName)) {
                     ignoreReplyTo = checkDuplicateHeaders(WSA_REPLY_TO, checkedHeaderNames,
                                                           duplicateHeaderNames);
-                } else if (WSA_FAULT_TO.equals(soapHeaderBlock.getLocalName())) {
+                } else if (WSA_FAULT_TO.equals(localName)) {
                     ignoreFaultTo = checkDuplicateHeaders(WSA_FAULT_TO, checkedHeaderNames,
                                                           duplicateHeaderNames);
-                } else if (WSA_FROM.equals(soapHeaderBlock.getLocalName())) {
+                } else if (WSA_FROM.equals(localName)) {
                     ignoreFrom = checkDuplicateHeaders(WSA_FROM, checkedHeaderNames,
                                                        duplicateHeaderNames);
                 }
@@ -155,21 +172,22 @@
         while (addressingHeadersIt2.hasNext()) {
             SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock)addressingHeadersIt2.next();
             if (!SOAP12Constants.SOAP_ROLE_NONE.equals(soapHeaderBlock.getRole())) {
-                if (WSA_ACTION.equals(soapHeaderBlock.getLocalName()) && !ignoreAction)
{
+            	String localName = soapHeaderBlock.getLocalName();
+                if (WSA_ACTION.equals(localName) && !ignoreAction) {
                     extractActionInformation(soapHeaderBlock, messageContext);
-                } else if (WSA_TO.equals(soapHeaderBlock.getLocalName()) && !ignoreTo)
{
+                } else if (WSA_TO.equals(localName) && !ignoreTo) {
                     extractToEPRInformation(soapHeaderBlock, messageContextOptions, header,
                                             namespace);
                 } else
-                if (WSA_MESSAGE_ID.equals(soapHeaderBlock.getLocalName()) && !ignoreMessageID)
{
+                if (WSA_MESSAGE_ID.equals(localName) && !ignoreMessageID) {
                     extractMessageIDInformation(soapHeaderBlock, messageContext);
-                } else if (WSA_REPLY_TO.equals(soapHeaderBlock.getLocalName()) &&
!ignoreReplyTo) {
+                } else if (WSA_REPLY_TO.equals(localName) && !ignoreReplyTo) {
                     extractReplyToEPRInformation(soapHeaderBlock, namespace, messageContext);
-                } else if (WSA_FAULT_TO.equals(soapHeaderBlock.getLocalName()) &&
!ignoreFaultTo) {
+                } else if (WSA_FAULT_TO.equals(localName) && !ignoreFaultTo) {
                     extractFaultToEPRInformation(soapHeaderBlock, namespace, messageContext);
-                } else if (WSA_RELATES_TO.equals(soapHeaderBlock.getLocalName())) {
+                } else if (WSA_RELATES_TO.equals(localName)) {
                     extractRelatesToInformation(soapHeaderBlock, messageContextOptions);
-                } else if (WSA_FROM.equals(soapHeaderBlock.getLocalName()) && !ignoreFrom)
{
+                } else if (WSA_FROM.equals(localName) && !ignoreFrom) {
                     extractFromEPRInformation(soapHeaderBlock, namespace, messageContext);
                 }
             }
@@ -323,7 +341,9 @@
         }
 
         // check for reference parameters
-        extractToEprReferenceParameters(epr, header, namespace);
+        if(!disableRefparamExtract){
+        	extractToEprReferenceParameters(epr, header, namespace);
+        }
         soapHeaderBlock.setProcessed();
 
         if (log.isTraceEnabled()) {

Modified: webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java?rev=580330&r1=580329&r2=580330&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
(original)
+++ webservices/axis2/trunk/java/modules/addressing/src/org/apache/axis2/handlers/addressing/AddressingOutHandler.java
Fri Sep 28 05:42:56 2007
@@ -126,6 +126,8 @@
         private boolean replaceHeaders;  // determines whether we replace the existing headers
or not, if they present
         private boolean includeOptionalHeaders;
 
+        private ArrayList existingWSAHeaders = null;
+        
         public WSAHeaderWriter(MessageContext mc, boolean isSubmissionNamespace, boolean
addMU,
                                boolean replace, boolean includeOptional) {
             if (log.isDebugEnabled()) {
@@ -151,6 +153,20 @@
             addressingNamespaceObject =
                     factory.createOMNamespace(addressingNamespace, WSA_DEFAULT_PREFIX);
 
+            // if there is no soap header in the envelope being processed, add one.
+            if (header == null) {
+            	header = factory.createSOAPHeader(envelope);
+            }else{
+            	ArrayList addressingHeaders = header.getHeaderBlocksWithNSURI(addressingNamespace);
+            	if(addressingHeaders!=null && !addressingHeaders.isEmpty()){
+            		existingWSAHeaders = new ArrayList();
+            		for(Iterator iter=addressingHeaders.iterator();iter.hasNext();){
+            			OMElement oe = (OMElement)iter.next();
+            			existingWSAHeaders.add(oe.getLocalName());
+            		}
+            	}
+            }
+            
             isFinalAddressingNamespace = !isSubmissionNamespace;
             addMustUnderstandAttribute = addMU;
             replaceHeaders = replace;
@@ -488,8 +504,7 @@
          *         true - if new headers can't be added.
          */
         private boolean isAddressingHeaderAlreadyAvailable(String name, boolean multipleHeaders)
{
-            QName qname = new QName(addressingNamespaceObject.getNamespaceURI(), name,
-                                    addressingNamespaceObject.getPrefix());
+        	QName qname = new QName(addressingNamespace, name, WSA_DEFAULT_PREFIX);
             boolean status = false;
 
             if (multipleHeaders) {
@@ -501,16 +516,17 @@
                     }
                 }
             } else {
-                OMElement addressingHeader = header.getFirstChildWithName(qname);
-
-                if (addressingHeader != null && replaceHeaders) {
+            	 boolean exists = didAddressingHeaderExist(name);
+            	  	  	 
+            	 if (exists && replaceHeaders) {
+            	 	  	                         OMElement addressingHeader = header.getFirstChildWithName(qname);
                     if (log.isTraceEnabled()) {
                         log.trace("isAddressingHeaderAlreadyAvailable: Removing existing
header:" +
                                 addressingHeader.getLocalName());
                     }
                     addressingHeader.detach();
                 } else {
-                    status = addressingHeader != null;
+                    status = exists;
                 }
             }
 
@@ -518,6 +534,20 @@
                 log.trace("isAddressingHeaderAlreadyAvailable: name=" + name + " status="
+ status);
             }
             return status;
+        }
+        
+        private boolean didAddressingHeaderExist(String headerName){
+        	if (log.isTraceEnabled()) {
+        		log.trace("didAddressingHeaderExist: headerName=" + headerName);
+        	}
+        	boolean result = false;
+        	if(existingWSAHeaders != null){
+        		result = existingWSAHeaders.contains(headerName);
+        		if (log.isTraceEnabled()) {
+        			log.trace("didAddressingHeaderExist: existingWSAHeaders=" + existingWSAHeaders+"
result="+result);
+        		}
+        	}
+        	return result;
         }
 
         /**



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


Mime
View raw message