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 2008/08/02 18:20:01 UTC
svn commit: r682006 -
/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/dispatchers/MustUnderstandUtils.java
Author: scheu
Date: Sat Aug 2 09:20:01 2008
New Revision: 682006
URL: http://svn.apache.org/viewvc?rev=682006&view=rev
Log:
AXIS2-3959
Contributor:Rich Scheuerle and David Strite
Performance fix to cache the list of headers from sei method parameters.
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/dispatchers/MustUnderstandUtils.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/dispatchers/MustUnderstandUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/dispatchers/MustUnderstandUtils.java?rev=682006&r1=682005&r2=682006&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/dispatchers/MustUnderstandUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/dispatchers/MustUnderstandUtils.java Sat Aug 2 09:20:01 2008
@@ -21,6 +21,7 @@
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.description.AxisDescription;
import org.apache.axis2.description.AxisOperation;
@@ -61,7 +62,7 @@
}
ArrayList understoodHeaderQNames = MustUnderstandUtils.getHeaderParamaterList(msgContext);
- if (understoodHeaderQNames == null) {
+ if (understoodHeaderQNames == null || understoodHeaderQNames.isEmpty()) {
return;
}
@@ -88,42 +89,71 @@
* @return ArrayList of QNames for all header parameters for an SEI and SOAP handlers.
* The list may be empty but will not be null.
*/
+ static ArrayList EMPTY_LIST = new ArrayList();
public static ArrayList getHeaderParamaterList(MessageContext msgContext) {
- ArrayList returnList = new ArrayList();
+ ArrayList headers = null;
// Build a list of understood headers for all the operations under the service
AxisService axisService = msgContext.getAxisService();
if (log.isDebugEnabled()) {
log.debug("Building list of understood headers for all operations under " + axisService);
}
- if (axisService != null) {
- ArrayList understoodHeaders;
+ if (axisService == null) {
+ headers = EMPTY_LIST;
+ } else {
- // examine SEI methods
- Iterator operationIterator = axisService.getOperations();
- if (operationIterator != null) {
- while (operationIterator.hasNext()) {
- AxisOperation operation = (AxisOperation) operationIterator.next();
- understoodHeaders = getSEIMethodHeaderParameterList(operation);
- if (log.isDebugEnabled()) {
- log.debug("Adding headers from operation " + operation + "; headers = "
- + understoodHeaders);
+ // Get the understood headers from the sei methods
+ ArrayList seiMethodHeaders = (ArrayList)
+ axisService.getParameterValue("seiMethodHeaderParameter");
+
+ if (seiMethodHeaders == null) {
+ // examine SEI methods
+ seiMethodHeaders = new ArrayList();
+ Iterator operationIterator = axisService.getOperations();
+ if (operationIterator != null) {
+ while (operationIterator.hasNext()) {
+ AxisOperation operation = (AxisOperation) operationIterator.next();
+ ArrayList list = getSEIMethodHeaderParameterList(operation);
+ if (log.isDebugEnabled()) {
+ log.debug("Adding headers from operation " + operation + "; headers = "
+ + list);
+ }
+ if (list != null && !list.isEmpty()) {
+ seiMethodHeaders.addAll(list);
+ }
}
- if (understoodHeaders != null && !understoodHeaders.isEmpty()) {
- returnList.addAll(understoodHeaders);
+ }
+
+ try {
+ // Save calculated value since this won't change
+ axisService.addParameter("seiMethodHeaderParameter", seiMethodHeaders);
+ } catch (AxisFault e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Problem caching seiMethodHeaderParameter. " +
+ "Processing continues without cached value");
}
}
+
}
- // examine handlers
- understoodHeaders = getHandlersHeaderParameterList(axisService);
+ // Get the understood headers from the handlers
+ ArrayList handlerHeaders = getHandlersHeaderParameterList(axisService);
if (log.isDebugEnabled()) {
- log.debug("Adding headers from SOAP handlers; headers = " + understoodHeaders);
+ log.debug("Adding headers from SOAP handlers; headers = " + handlerHeaders);
}
- if (understoodHeaders != null && !understoodHeaders.isEmpty()) {
- returnList.addAll(understoodHeaders);
+
+ // Make the combined headers list.
+ // The following code avoids making temporary array lists for performance/gc reasons
+ if (seiMethodHeaders == null || seiMethodHeaders.isEmpty()) {
+ headers = (handlerHeaders == null) ? EMPTY_LIST : handlerHeaders; // Return handler headers
+ } else if (handlerHeaders == null || handlerHeaders.isEmpty()) {
+ headers = (seiMethodHeaders == null) ? EMPTY_LIST : seiMethodHeaders; // Return sei method headers
+ } else {
+ headers = new ArrayList();
+ headers.addAll(seiMethodHeaders);
+ headers.addAll(handlerHeaders);
}
}
- return returnList;
+ return headers;
}
/**