cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1446658 - /cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
Date Fri, 15 Feb 2013 16:05:30 GMT
Author: dkulp
Date: Fri Feb 15 16:05:30 2013
New Revision: 1446658

URL: http://svn.apache.org/r1446658
Log:
Check if a policy is already registered to avoid a bunch of duplicates.

Modified:
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java?rev=1446658&r1=1446657&r2=1446658&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
(original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
Fri Feb 15 16:05:30 2013
@@ -183,18 +183,20 @@ public class Wsdl11AttachmentPolicyProvi
                     
                     if (Constants.isPolicyElement(e.getElementType())
                         && !StringUtils.isEmpty(uri)) {
-                        try {
-                            Policy policy = builder.getPolicy(e.getElement());
-                            String fragement = "#" + uri;
-                            registry.register(fragement, policy);
-                            if (di.getBaseURI() == null) {
-                                registry.register(Integer.toString(di.hashCode()) + fragement,
policy);
-                            } else {
-                                registry.register(di.getBaseURI() + fragement, policy);
+                        
+                        String id = (di.getBaseURI() == null ? Integer.toString(di.hashCode())
: di.getBaseURI()) 
+                                + "#" + uri;
+                        Policy policy = registry.lookup(id);
+                        if (policy == null) {
+                            try {
+                                policy = builder.getPolicy(e.getElement());
+                                String fragement = "#" + uri;
+                                registry.register(fragement, policy);
+                                registry.register(id, policy);
+                            } catch (Exception policyEx) {
+                                //ignore the policy can not be built
+                                LOG.warning("Failed to build the policy '" + uri + "':" +
policyEx.getMessage());
                             }
-                        } catch (Exception policyEx) {
-                            //ignore the policy can not be built
-                            LOG.warning("Failed to build the policy '" + uri + "':" + policyEx.getMessage());
                         }
                     }
                 }



Mime
View raw message