You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2010/06/10 08:58:32 UTC

svn commit: r953227 - in /servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc: SchemaUtil.java WSAUtils.java

Author: ffang
Date: Thu Jun 10 06:58:32 2010
New Revision: 953227

URL: http://svn.apache.org/viewvc?rev=953227&view=rev
Log:
[SMXCOMP-756]refactor WSAUtils and ShemaUtils to iterate entrySet instead of keySet to get better performance

Modified:
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/SchemaUtil.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/WSAUtils.java

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/SchemaUtil.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/SchemaUtil.java?rev=953227&r1=953226&r2=953227&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/SchemaUtil.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/SchemaUtil.java Thu Jun 10 06:58:32 2010
@@ -23,6 +23,8 @@ import java.util.IdentityHashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
+
 import javax.wsdl.Definition;
 import javax.wsdl.Import;
 import javax.wsdl.Types;
@@ -85,6 +87,7 @@ public final class SchemaUtil {
         }
     }
 
+    @SuppressWarnings("unchecked")
     private void extractSchema(Definition def, SchemaCollection schemaCol, List<SchemaInfo> schemaInfos) {
         Types typesElement = def.getTypes();
         if (typesElement != null) {
@@ -102,8 +105,11 @@ public final class SchemaUtil {
                 }
                 if (schemaElem != null) {
                     synchronized (schemaElem.getOwnerDocument()) {
-                        for (Object prefix : def.getNamespaces().keySet()) {
-                            String ns = (String)def.getNamespaces().get(prefix);
+                        //for (Object prefix : def.getNamespaces().keySet()) {
+                        Map<String, String> nameSpaces = CastUtils.cast(def.getNamespaces());
+                        for (Entry<String, String> ent : nameSpaces.entrySet()) {
+                            String prefix = ent.getKey();
+                            String ns = nameSpaces.get(prefix);
                             if ("".equals(prefix)) {
                                 if (!schemaElem.hasAttribute("xmlns")) {
                                     Attr attr = 
@@ -191,9 +197,8 @@ public final class SchemaUtil {
         //handle imports
         Map<String, List> imports = CastUtils.cast(schema.getImports());
         if (imports != null && imports.size() > 0) {
-            Collection<String> importKeys = imports.keySet();
-            for (String importNamespace : importKeys) {
-
+            for (Entry<String, List> ent : imports.entrySet()) {
+                String importNamespace = ent.getKey();
                 List<SchemaImport> schemaImports = CastUtils.cast(imports.get(importNamespace));
                 
                 for (SchemaImport schemaImport : schemaImports) {

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/WSAUtils.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/WSAUtils.java?rev=953227&r1=953226&r2=953227&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/WSAUtils.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/WSAUtils.java Thu Jun 10 06:58:32 2010
@@ -18,6 +18,7 @@ package org.apache.servicemix.cxfbc;
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.apache.cxf.ws.addressing.AddressingProperties;
 import org.apache.cxf.ws.addressing.AddressingPropertiesImpl;
@@ -46,35 +47,32 @@ public final class WSAUtils {
         if (wsAddressingAsMap == null) {
             return maps;
         }
-        for (String wsaHeaderKey : wsAddressingAsMap.keySet()) {
-
-            String wsaHeaderValue = wsAddressingAsMap.get(wsaHeaderKey);
-            System.out.println(" WSA HEADER KEY -> " + wsaHeaderKey);
-            System.out.println(" WSA HEADER VALUE -> " + wsaHeaderKey);
-            if (Names.WSA_MESSAGEID_NAME.equals(wsaHeaderKey)) {
+        for (Entry<String, String> ent : wsAddressingAsMap.entrySet()) {
+            String wsaHeaderValue = ent.getValue();
+            if (Names.WSA_MESSAGEID_NAME.equals(ent.getKey())) {
                 AttributedURIType aAttributedURIType = WSA_OBJECT_FACTORY
                         .createAttributedURIType();
                 aAttributedURIType.setValue(wsaHeaderValue);
                 maps.setMessageID(aAttributedURIType);
-            } else if (Names.WSA_TO_NAME.equals(wsaHeaderKey)) {
+            } else if (Names.WSA_TO_NAME.equals(ent.getKey())) {
                 maps.setTo(EndpointReferenceUtils
                         .getEndpointReference(wsaHeaderValue));
-            } else if (Names.WSA_FROM_NAME.equals(wsaHeaderKey)) {
+            } else if (Names.WSA_FROM_NAME.equals(ent.getKey())) {
                 maps.setTo(EndpointReferenceUtils
                         .getEndpointReference(wsaHeaderValue));
-            } else if (Names.WSA_REPLYTO_NAME.equals(wsaHeaderKey)) {
+            } else if (Names.WSA_REPLYTO_NAME.equals(ent.getKey())) {
                 maps.setReplyTo(EndpointReferenceUtils
                         .getEndpointReference(wsaHeaderValue));
-            } else if (Names.WSA_FAULTTO_NAME.equals(wsaHeaderKey)) {
+            } else if (Names.WSA_FAULTTO_NAME.equals(ent.getKey())) {
                 // System.out.println( " **WSA_FAULTTO_NAME**");
                 maps.setFaultTo(EndpointReferenceUtils
                         .getEndpointReference(wsaHeaderValue));
-            } else if (Names.WSA_RELATESTO_NAME.equals(wsaHeaderKey)) {
+            } else if (Names.WSA_RELATESTO_NAME.equals(ent.getKey())) {
                 RelatesToType aRelatesToType = WSA_OBJECT_FACTORY
                         .createRelatesToType();
                 aRelatesToType.setValue(wsaHeaderValue);
                 maps.setRelatesTo(aRelatesToType);
-            } else if (Names.WSA_ACTION_NAME.equals(wsaHeaderKey)) {
+            } else if (Names.WSA_ACTION_NAME.equals(ent.getKey())) {
                 AttributedURIType aAttributedURIType = WSA_OBJECT_FACTORY
                         .createAttributedURIType();
                 aAttributedURIType.setValue(wsaHeaderValue);