Author: veithen Date: Wed Dec 21 20:48:26 2011 New Revision: 1221871 URL: http://svn.apache.org/viewvc?rev=1221871&view=rev Log: Merged r1221716 to the 1.6 branch to improve WS-Policy 1.5 support.
Modified: axis/axis2/java/core/branches/1_6/ (props changed) axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/namespace/Constants.java axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/wsdl/WSDLConstants.java Propchange: axis/axis2/java/core/branches/1_6/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Wed Dec 21 20:48:26 2011 @@ -1 +1 @@ -/axis/axis2/java/core/trunk:1068985,1069659,1069898,1070439,1072077,1072271,1072296,1072499,1072510,1075057,1078242,1081563,1081587,1081590,1082316,1082322,1082600,1082702,1082726,1082738,1083180,1083192,1083379,1083381,1083425,1083433,1083446,1084753,1085157,1085173,1085514,1085889,1085927,1085931,1087073,1088239,1088248-1088249,1088251,1088268,1088730,1088904,1089225,1089989,1090429,1090457,1091178,1091191,1094117,1096530,1096557,1099385,1099389,1100628,1101037,1103013,1103336,1103606,1103760,1128580,1128584,1128618,1128645,1130590,1131425,1134438,1134616,1136156,1136159,1136177,1137153,1137159,1138144,1138203,1139448,1139484,1147485,1149224,1149491,1149578,1150055,1154615,1156305,1156382,1157211,1157265,1157373,1157415,1157424,1157501,1157517,1157522,1157535,1157767,1163389,1166038,1166040,1166132,1167045,1174618,1184808,1184810,1184816,1185504,1190469,1190499,1195893,1195972,1195982,1198288,1201467,1201863,1201957,1202867,1203424,1205716,1205939,1208901,1209034,1213639,1 214118,1220630 +/axis/axis2/java/core/trunk:1068985,1069659,1069898,1070439,1072077,1072271,1072296,1072499,1072510,1075057,1078242,1081563,1081587,1081590,1082316,1082322,1082600,1082702,1082726,1082738,1083180,1083192,1083379,1083381,1083425,1083433,1083446,1084753,1085157,1085173,1085514,1085889,1085927,1085931,1087073,1088239,1088248-1088249,1088251,1088268,1088730,1088904,1089225,1089989,1090429,1090457,1091178,1091191,1094117,1096530,1096557,1099385,1099389,1100628,1101037,1103013,1103336,1103606,1103760,1128580,1128584,1128618,1128645,1130590,1131425,1134438,1134616,1136156,1136159,1136177,1137153,1137159,1138144,1138203,1139448,1139484,1147485,1149224,1149491,1149578,1150055,1154615,1156305,1156382,1157211,1157265,1157373,1157415,1157424,1157501,1157517,1157522,1157535,1157767,1163389,1166038,1166040,1166132,1167045,1174618,1184808,1184810,1184816,1185504,1190469,1190499,1195893,1195972,1195982,1198288,1201467,1201863,1201957,1202867,1203424,1205716,1205939,1208901,1209034,1213639,1 214118,1220630,1220888,1221716 Modified: axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java?rev=1221871&r1=1221870&r2=1221871&view=diff ============================================================================== --- axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java (original) +++ axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java Wed Dec 21 20:48:26 2011 @@ -48,6 +48,7 @@ import org.apache.axis2.transport.Transp import org.apache.axis2.transport.TransportSender; import org.apache.axis2.util.JavaUtils; import org.apache.axis2.util.Loader; +import org.apache.axis2.util.PolicyUtil; import org.apache.axis2.util.TargetResolver; import org.apache.axis2.util.ThreadContextMigrator; import org.apache.axis2.util.ThreadContextMigratorUtil; @@ -153,8 +154,7 @@ public class AxisConfigBuilder extends D processModuleConfig(moduleConfigs, axisConfig, axisConfig); // processing <wsp:Policy> .. </..> elements - Iterator policyElements = config_element.getChildrenWithName(new QName(POLICY_NS_URI, - TAG_POLICY)); + Iterator policyElements = PolicyUtil.getPolicyChildren(config_element); if (policyElements != null && policyElements.hasNext()) { processPolicyElements(policyElements, @@ -162,8 +162,7 @@ public class AxisConfigBuilder extends D } // processing <wsp:PolicyReference> .. </..> elements - Iterator policyRefElements = config_element.getChildrenWithName(new QName(POLICY_NS_URI, - TAG_POLICY_REF)); + Iterator policyRefElements = PolicyUtil.getPolicyRefChildren(config_element); if (policyRefElements != null && policyRefElements.hasNext()) { processPolicyRefElements(policyElements, Modified: axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java?rev=1221871&r1=1221870&r2=1221871&view=diff ============================================================================== --- axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java (original) +++ axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java Wed Dec 21 20:48:26 2011 @@ -159,8 +159,22 @@ public interface DeploymentConstants { char SEPARATOR_DOT = '.'; char SEPARATOR_COLON = ':'; + /** + * @deprecated Please use {@link org.apache.neethi.Constants#isPolicyNS(String)} to check for a + * supported policy namespace. + */ String POLICY_NS_URI = Constants.URI_POLICY; + + /** + * @deprecated Please use an appropriate method or constant from + * {@link org.apache.neethi.Constants} instead. + */ String TAG_POLICY = "Policy"; + + /** + * @deprecated Please use an appropriate method or constant from + * {@link org.apache.neethi.Constants} instead. + */ String TAG_POLICY_REF = "PolicyReference"; String TAG_POLICY_ATTACHMENT = "PolicyAttachment"; Modified: axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java?rev=1221871&r1=1221870&r2=1221871&view=diff ============================================================================== --- axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java (original) +++ axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/ModuleBuilder.java Wed Dec 21 20:48:26 2011 @@ -35,6 +35,7 @@ import org.apache.axis2.modules.Module; import org.apache.axis2.phaseresolver.PhaseMetadata; import org.apache.axis2.util.Loader; import org.apache.axis2.util.JavaUtils; +import org.apache.axis2.util.PolicyUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -166,16 +167,14 @@ public class ModuleBuilder extends Descr // setting the PolicyInclude // processing <wsp:Policy> .. </..> elements - Iterator policyElements = - moduleElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY)); + Iterator policyElements = PolicyUtil.getPolicyChildren(moduleElement); if (policyElements != null && policyElements.hasNext()) { processPolicyElements(policyElements, module.getPolicySubject()); } // processing <wsp:PolicyReference> .. </..> elements - Iterator policyRefElements = - moduleElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF)); + Iterator policyRefElements = PolicyUtil.getPolicyRefChildren(moduleElement); if (policyRefElements != null && policyRefElements.hasNext()) { processPolicyRefElements(policyRefElements, module.getPolicySubject()); @@ -318,16 +317,14 @@ public class ModuleBuilder extends Descr processOperationModuleRefs(modules, op_descrip); // processing <wsp:Policy> .. </..> elements - Iterator policyElements = - operation.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY)); + Iterator policyElements = PolicyUtil.getPolicyChildren(operation); if (policyElements != null && policyElements.hasNext()) { processPolicyElements(policyElements, op_descrip.getPolicySubject()); } // processing <wsp:PolicyReference> .. </..> elements - Iterator policyRefElements = - operation.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF)); + Iterator policyRefElements = PolicyUtil.getPolicyRefChildren(operation); if (policyRefElements != null && policyRefElements.hasNext()) { processPolicyRefElements(policyRefElements, module.getPolicySubject()); Modified: axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java?rev=1221871&r1=1221870&r2=1221871&view=diff ============================================================================== --- axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java (original) +++ axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java Wed Dec 21 20:48:26 2011 @@ -37,6 +37,7 @@ import org.apache.axis2.engine.ServiceLi import org.apache.axis2.i18n.Messages; import org.apache.axis2.util.Loader; import org.apache.axis2.util.JavaUtils; +import org.apache.axis2.util.PolicyUtil; import org.apache.axis2.wsdl.WSDLConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -48,6 +49,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; +import java.util.List; import java.util.Map; /** @@ -300,17 +302,14 @@ public class ServiceBuilder extends Desc // <schema targetNamespace="http://x.y.z"/> // setting the PolicyInclude // processing <wsp:Policy> .. </..> elements - Iterator policyElements = service_element - .getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY)); + Iterator policyElements = PolicyUtil.getPolicyChildren(service_element); if (policyElements != null && policyElements.hasNext()) { processPolicyElements(policyElements, service.getPolicySubject()); } // processing <wsp:PolicyReference> .. </..> elements - Iterator policyRefElements = service_element - .getChildrenWithName(new QName(POLICY_NS_URI, - TAG_POLICY_REF)); + Iterator policyRefElements = PolicyUtil.getPolicyRefChildren(service_element); if (policyRefElements != null && policyRefElements.hasNext()) { processPolicyRefElements(policyRefElements, service.getPolicySubject()); @@ -628,17 +627,14 @@ public class ServiceBuilder extends Desc TAG_PARAMETER)); // processing <wsp:Policy> .. </..> elements - Iterator policyElements = messageElement - .getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY)); + Iterator policyElements = PolicyUtil.getPolicyChildren(messageElement); if (policyElements != null) { processPolicyElements(policyElements, message.getPolicySubject()); } // processing <wsp:PolicyReference> .. </..> elements - Iterator policyRefElements = messageElement - .getChildrenWithName(new QName(POLICY_NS_URI, - TAG_POLICY_REF)); + Iterator policyRefElements = PolicyUtil.getPolicyRefChildren(messageElement); if (policyRefElements != null) { processPolicyRefElements(policyRefElements, message.getPolicySubject()); @@ -788,17 +784,14 @@ public class ServiceBuilder extends Desc // setting the PolicyInclude // processing <wsp:Policy> .. </..> elements - Iterator policyElements = operation.getChildrenWithName(new QName( - POLICY_NS_URI, TAG_POLICY)); + Iterator policyElements = PolicyUtil.getPolicyChildren(operation); if (policyElements != null && policyElements.hasNext()) { processPolicyElements(policyElements, op_descrip.getPolicySubject()); } // processing <wsp:PolicyReference> .. </..> elements - Iterator policyRefElements = operation - .getChildrenWithName(new QName(POLICY_NS_URI, - TAG_POLICY_REF)); + Iterator policyRefElements = PolicyUtil.getPolicyRefChildren(operation); if (policyRefElements != null && policyRefElements.hasNext()) { processPolicyRefElements(policyRefElements, op_descrip.getPolicySubject()); @@ -920,10 +913,16 @@ public class ServiceBuilder extends Desc private void processPolicyAttachments(OMElement serviceElement, AxisService service) throws DeploymentException { - Iterator attachmentElements = - serviceElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_ATTACHMENT)); + List<OMElement> attachmentElements = new ArrayList<OMElement>(); + for (Iterator it = serviceElement.getChildElements(); it.hasNext(); ) { + OMElement elem = (OMElement)it.next(); + if (org.apache.neethi.Constants.isPolicyNS(elem.getNamespaceURI()) && + elem.getLocalName().equals(TAG_POLICY_ATTACHMENT)) { + attachmentElements.add(elem); + } + } try { - Utils.processPolicyAttachments(attachmentElements, service); + Utils.processPolicyAttachments(attachmentElements.iterator(), service); } catch (Exception e) { throw new DeploymentException(e); } Modified: axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java?rev=1221871&r1=1221870&r2=1221871&view=diff ============================================================================== --- axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java (original) +++ axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java Wed Dec 21 20:48:26 2011 @@ -1272,18 +1272,20 @@ public class Utils { for (; attachmentElements.hasNext();) { attachmentElement = (OMElement)attachmentElements.next(); - OMElement appliesToElem = attachmentElement - .getFirstChildWithName(new QName( - DeploymentConstants.POLICY_NS_URI, - DeploymentConstants.TAG_APPLIES_TO)); + OMElement appliesToElem = null; + for (Iterator it = attachmentElement.getChildElements(); it.hasNext(); ) { + OMElement elem = (OMElement)it.next(); + if (org.apache.neethi.Constants.isPolicyNS(elem.getNamespaceURI()) + && elem.getLocalName().equals(DeploymentConstants.TAG_APPLIES_TO)) { + appliesToElem = elem; + break; + } + } ArrayList policyComponents = new ArrayList(); // process <wsp:Policy> elements .. - for (Iterator policyElements = attachmentElement - .getChildrenWithName(new QName( - DeploymentConstants.POLICY_NS_URI, - DeploymentConstants.TAG_POLICY)); policyElements - .hasNext();) { + for (Iterator policyElements = PolicyUtil.getPolicyChildren(attachmentElement); + policyElements.hasNext();) { PolicyComponent policy = PolicyUtil .getPolicyFromOMElement((OMElement)policyElements .next()); @@ -1291,11 +1293,8 @@ public class Utils { } // process <wsp:PolicyReference> elements .. - for (Iterator policyRefElements = attachmentElement - .getChildrenWithName(new QName( - DeploymentConstants.POLICY_NS_URI, - DeploymentConstants.TAG_POLICY_REF)); policyRefElements - .hasNext();) { + for (Iterator policyRefElements = PolicyUtil.getPolicyRefChildren(attachmentElement); + policyRefElements.hasNext();) { PolicyComponent policyRef = PolicyUtil .getPolicyReferenceFromOMElement((OMElement)policyRefElements .next()); Modified: axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java?rev=1221871&r1=1221870&r2=1221871&view=diff ============================================================================== --- axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java (original) +++ axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java Wed Dec 21 20:48:26 2011 @@ -2385,7 +2385,7 @@ public class WSDL11ToAxisServiceBuilder QName type = unknown.getElementType(); // <wsp:Policy> - if (WSDLConstants.WSDL11Constants.POLICY.equals(type)) { + if (Constants.isPolicyElement(type)) { if (isTraceEnabled) { log.trace("copyExtensibleElements:: PolicyElement found " + unknown); } @@ -2399,8 +2399,7 @@ public class WSDL11ToAxisServiceBuilder // attachmentScope, policy); // } // <wsp:PolicyReference> - } else if (WSDLConstants.WSDL11Constants.POLICY_REFERENCE - .equals(type)) { + } else if (Constants.isPolicyRef(type)) { if (isTraceEnabled) { log.trace("copyExtensibleElements:: PolicyReference found " + unknown); } @@ -3114,7 +3113,7 @@ public class WSDL11ToAxisServiceBuilder if (extElement instanceof UnknownExtensibilityElement) { unknown = (UnknownExtensibilityElement) extElement; - if (WSDLConstants.WSDL11Constants.POLICY.equals(unknown.getElementType())) { + if (Constants.isPolicyElement(unknown.getElementType())) { policy = (Policy) PolicyUtil.getPolicyComponent(unknown.getElement()); String key; Modified: axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/namespace/Constants.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/namespace/Constants.java?rev=1221871&r1=1221870&r2=1221871&view=diff ============================================================================== --- axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/namespace/Constants.java (original) +++ axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/namespace/Constants.java Wed Dec 21 20:48:26 2011 @@ -110,8 +110,13 @@ public class Constants { "http://www.w3.org/2001/XMLSchema-instance"; public static final String URI_DEFAULT_SCHEMA_XSI = URI_2001_SCHEMA_XSI; + /** + * @deprecated Please use {@link org.apache.neethi.Constants#isPolicyNS(String)} to check for a + * supported policy namespace. + */ public static final String URI_POLICY = "http://schemas.xmlsoap.org/ws/2004/09/policy"; + public static final String FORMAT_BINDING = "http://schemas.xmlsoap.org/wsdl/formatbinding/"; public static final String JAVA_NS = "http://schemas.xmlsoap.org/wsdl/java/"; /** Modified: axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java?rev=1221871&r1=1221870&r2=1221871&view=diff ============================================================================== --- axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java (original) +++ axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java Wed Dec 21 20:48:26 2011 @@ -21,9 +21,11 @@ package org.apache.axis2.util; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import javax.xml.namespace.QName; import javax.xml.stream.FactoryConfigurationError; import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLStreamException; @@ -276,4 +278,28 @@ public class PolicyUtil { return policy; } + + public static Iterator<OMElement> getPolicyChildren(OMElement parent) { + List<OMElement> policies = new ArrayList<OMElement>(); + Iterator children = parent.getChildElements(); + while (children.hasNext()) { + OMElement child = (OMElement)children.next(); + if (Constants.isPolicyElement(child.getQName())) { + policies.add(child); + } + } + return policies.iterator(); + } + + public static Iterator<OMElement> getPolicyRefChildren(OMElement parent) { + List<OMElement> policyRefs = new ArrayList<OMElement>(); + Iterator children = parent.getChildElements(); + while (children.hasNext()) { + OMElement child = (OMElement)children.next(); + if (Constants.isPolicyRef(child.getQName())) { + policyRefs.add(child); + } + } + return policyRefs.iterator(); + } } Modified: axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/wsdl/WSDLConstants.java URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/wsdl/WSDLConstants.java?rev=1221871&r1=1221870&r2=1221871&view=diff ============================================================================== --- axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/wsdl/WSDLConstants.java (original) +++ axis/axis2/java/core/branches/1_6/modules/kernel/src/org/apache/axis2/wsdl/WSDLConstants.java Wed Dec 21 20:48:26 2011 @@ -126,8 +126,18 @@ public interface WSDLConstants { Constants.URI_WSDL11_SOAP, "binding"); QName SOAP_12_BINDING = new QName( Constants.URI_WSDL12_SOAP, "binding"); + + /** + * @deprecated Please use {@link org.apache.neethi.Constants#isPolicyElement(QName)} to + * check for Policy elements. + */ QName POLICY = new QName( Constants.URI_POLICY, "Policy"); + + /** + * @deprecated Please use {@link org.apache.neethi.Constants#isPolicyRef(QName)} to check + * for policy references. + */ QName POLICY_REFERENCE = new QName( Constants.URI_POLICY, "PolicyReference"); }