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 sa...@apache.org on 2008/04/04 20:47:27 UTC

svn commit: r644817 - in /webservices/axis2/trunk/java/modules: codegen/src/org/apache/axis2/wsdl/codegen/emitter/ codegen/src/org/apache/axis2/wsdl/template/java/ kernel/src/org/apache/axis2/deployment/util/ kernel/src/org/apache/axis2/description/ ke...

Author: sanka
Date: Fri Apr  4 11:47:02 2008
New Revision: 644817

URL: http://svn.apache.org/viewvc?rev=644817&view=rev
Log:
Applied the patch file provided in AXIS2-3702

Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/PolicyInclude.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/PolicySubject.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/ExternalPolicySerializer.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java?rev=644817&r1=644816&r2=644817&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/AxisServiceBasedMultiLanguageEmitter.java Fri Apr  4 11:47:02 2008
@@ -75,6 +75,8 @@
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLStreamException;
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
@@ -2719,7 +2721,7 @@
             * Setting the effective policy of input message
             */
             Policy policy = getBindingPolicyFromMessage(bindingOperation,
-                    WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
+                    WSDLConstants.MESSAGE_LABEL_IN_VALUE);
 
             if (policy != null) {
                 try {
@@ -2792,7 +2794,7 @@
             * Setting the effective policy for the output message.
             */
             Policy policy = getBindingPolicyFromMessage(bindingOperation,
-                    WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
+                    WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
 
             if (policy != null) {
                 try {

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl?rev=644817&r1=644816&r2=644817&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/template/java/InterfaceImplementationTemplate.xsl Fri Apr  4 11:47:02 2008
@@ -103,11 +103,11 @@
 	    
 
 	    <xsl:if test="input/@policy">
-	    (__operation).getMessage(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_OUT_VALUE).getPolicyInclude().setPolicy(getPolicy("<xsl:value-of select="input/@policy"/>"));
+	    (__operation).getMessage(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_OUT_VALUE).getPolicySubject().attachPolicy(getPolicy("<xsl:value-of select="input/@policy"/>"));
 	    </xsl:if>
 	    
 	    <xsl:if test="output/@policy">
-	    (__operation).getMessage(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE).getPolicyInclude().setPolicy(getPolicy("<xsl:value-of select="output/@policy"/>"));
+	    (__operation).getMessage(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE).getPolicySubject().attachPolicy(getPolicy("<xsl:value-of select="output/@policy"/>"));
 	    </xsl:if>
 	    
             _operations[<xsl:value-of select="position()-1"/>]=__operation;

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java?rev=644817&r1=644816&r2=644817&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java Fri Apr  4 11:47:02 2008
@@ -1476,7 +1476,7 @@
 			axisBindingOutMessage.setDirection(axisOutMessage.getDirection());
 			axisBindingOutMessage.setAxisMessage(axisOutMessage);
 
-			axisBindingOutMessage.setParent(axisOutMessage);
+			axisBindingOutMessage.setParent(axisBindingOperation);
 			axisBindingOperation.addChild(
 					WSDLConstants.MESSAGE_LABEL_OUT_VALUE,
 					axisBindingOutMessage);

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java?rev=644817&r1=644816&r2=644817&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisBindingMessage.java Fri Apr  4 11:47:02 2008
@@ -19,6 +19,10 @@
 
 package org.apache.axis2.description;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
@@ -31,10 +35,6 @@
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.neethi.Policy;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
 public class AxisBindingMessage extends AxisDescription {
 
 	private String name;
@@ -230,13 +230,13 @@
 
 		// AxisBindingMessage
 		policySubject = getPolicySubject();
-		policyList.addAll(policySubject.getAttachPolicyComponents());
+		policyList.addAll(policySubject.getAttachedPolicyComponents());
 
 		// AxisBindingOperation policies
 		AxisBindingOperation axisBindingOperation = getAxisBindingOperation();
 		if (axisBindingOperation != null) {
 			policyList.addAll(axisBindingOperation.getPolicySubject()
-					.getAttachPolicyComponents());
+					.getAttachedPolicyComponents());
 		}
 
 		// AxisBinding
@@ -244,7 +244,7 @@
 				: axisBindingOperation.getAxisBinding();
 		if (axisBinding != null) {
 			policyList.addAll(axisBinding.getPolicySubject()
-					.getAttachPolicyComponents());
+					.getAttachedPolicyComponents());
 		}
 
 		// AxisEndpoint
@@ -252,13 +252,13 @@
 				.getAxisEndpoint();
 		if (axisEndpoint != null) {
 			policyList.addAll(axisEndpoint.getPolicySubject()
-					.getAttachPolicyComponents());
+					.getAttachedPolicyComponents());
 		}
 
 		// AxisMessage
 		if (axisMessage != null) {
 			policyList.addAll(axisMessage.getPolicySubject()
-					.getAttachPolicyComponents());
+					.getAttachedPolicyComponents());
 		}
 
 		// AxisOperation
@@ -266,7 +266,7 @@
 				: axisMessage.getAxisOperation();
 		if (axisOperation != null) {
 			policyList.addAll(axisOperation.getPolicySubject()
-					.getAttachPolicyComponents());
+					.getAttachedPolicyComponents());
 		}
 
 		// AxisService
@@ -274,7 +274,7 @@
 				: axisOperation.getAxisService();
 		if (axisService != null) {
 			policyList.addAll(axisService.getPolicySubject()
-					.getAttachPolicyComponents());
+					.getAttachedPolicyComponents());
 		}
 
 		// AxisConfiguration
@@ -282,10 +282,9 @@
 				: axisService.getAxisConfiguration();
 		if (axisConfiguration != null) {
 			policyList.addAll(axisConfiguration.getPolicySubject()
-					.getAttachPolicyComponents());
+					.getAttachedPolicyComponents());
 		}
 
 		return PolicyUtil.getMergedPolicy(policyList, axisService);
 	}
-
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java?rev=644817&r1=644816&r2=644817&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisDescription.java Fri Apr  4 11:47:02 2008
@@ -31,6 +31,8 @@
 import org.apache.axis2.modules.Module;
 import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.util.Utils;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.axis2.wsdl.WSDLUtil;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.neethi.Assertion;
@@ -216,10 +218,23 @@
 		return parent;
 	}
 
+	/**
+	 * @see org.apache.axis2.description.AxisDescription#setPolicyInclude(PolicyInclude)
+	 * @deprecated As of release 1.4, if you want to access the policy cache of
+	 *             a particular AxisDescription object use
+	 *             {@line #getPolicySubject()} instead.
+	 * 
+	 * @param policyInclude
+	 */
 	public void setPolicyInclude(PolicyInclude policyInclude) {
 		this.policyInclude = policyInclude;
 	}
 
+
+	/**
+	 * @see org.apache.axis2.description.AxisDescription#getPolicySubject()
+	 * @deprecated As of release 1.4, replaced by {@link #getPolicySubject()}
+	 */
 	public PolicyInclude getPolicyInclude() {
 		if (policyInclude == null) {
 			policyInclude = new PolicyInclude(this);
@@ -227,6 +242,7 @@
 		return policyInclude;
 	}
 
+
     // NOTE - These are NOT typesafe!
     public void addChild(AxisDescription child) {
         if (child.getKey() == null) {
@@ -281,29 +297,71 @@
 	 *             that effective policy.
 	 */
 	public void applyPolicy(Policy policy) throws AxisFault {
-		AxisConfiguration configuration = getAxisConfiguration();
+		// sets AxisDescription policy
+		getPolicySubject().clear();
+		getPolicySubject().attachPolicy(policy);
 
+		/*
+		 * now we try to engage appropriate modules based on the merged policy
+		 * of axis description object and the corresponding axis binding
+		 * description object.
+		 */
+		applyPolicy();
+	}
+
+	/**
+	 * Applies the policies on the Description Hierarchy recursively.
+	 * 
+	 * @throws AxisFault
+	 *             an error occurred applying the policy
+	 */
+	public void applyPolicy() throws AxisFault {
+		AxisConfiguration configuration = getAxisConfiguration();
 		if (configuration == null) {
-			// FIXME return or throw an Exception?
 			return;
 		}
 
-		// sets AxisDescription policy
-		getPolicyInclude().setPolicy(policy);
+		Policy applicablePolicy = getApplicablePolicy(this);
+		if (applicablePolicy != null) {
+			engageModulesForPolicy(this, applicablePolicy, configuration);
+		}
 
-		/*
-		 * now we should take the effective one .. it is necessary since
-		 * AxisDescription.applyPolicy(..) doesn't override policies at the
-		 * Upper levels.
-		 */
-		Policy effPolicy = getPolicyInclude().getEffectivePolicy();
+		for (Iterator children = getChildren(); children.hasNext();) {
+			AxisDescription child = (AxisDescription) children.next();
+			child.applyPolicy();
+		}
+	}
+
+	private boolean canSupportAssertion(Assertion assertion, List moduleList) {
+
+		AxisModule axisModule;
+		Module module;
 
+		for (Iterator iterator = moduleList.iterator(); iterator.hasNext();) {
+			axisModule = (AxisModule) iterator.next();
+			// FIXME is this step really needed ??
+			// Shouldn't axisMoudle.getModule always return not-null value ??
+			module = axisModule.getModule();
+
+			if (!(module == null || module.canSupportAssertion(assertion))) {
+				log.debug(axisModule.getName() + " says it can't support "
+						+ assertion.getName());
+				return false;
+			}
+		}
+
+		return true;
+	}
+	
+	private void engageModulesForPolicy(AxisDescription axisDescription,
+			Policy policy, AxisConfiguration axisConfiguration)
+			throws AxisFault {
 		/*
 		 * for the moment we consider policies with only one alternative. If the
 		 * policy contains multiple alternatives only the first alternative will
 		 * be considered.
 		 */
-		Iterator iterator = effPolicy.getAlternatives();
+		Iterator iterator = policy.getAlternatives();
 		if (!iterator.hasNext()) {
 			throw new AxisFault(
 					"Policy doesn't contain any policy alternatives");
@@ -324,7 +382,7 @@
 			assertion = (Assertion) assertions.next();
 			namespaceURI = assertion.getName().getNamespaceURI();
 
-			moduleList = configuration
+			moduleList = axisConfiguration
 					.getModulesForPolicyNamesapce(namespaceURI);
 
 			if (moduleList == null) {
@@ -343,116 +401,9 @@
 				modulesToEngage.addAll(moduleList);
 			}
 		}
-
-		/*
-		 * FIXME We need to disengage any modules that are already engaged *but*
-		 * has nothing to do with the policy to apply
-		 */
-
 		engageModulesToAxisDescription(modulesToEngage, this);
 	}
 
-	/**
-	 * Applies the policies on the Description Hierarchy recursively.
-	 * 
-	 * @throws AxisFault
-	 *             an error occurred applying the policy
-	 */
-	public void applyPolicy() throws AxisFault {
-
-		AxisConfiguration configuration = getAxisConfiguration();
-		if (configuration == null) {
-			return; // CHECKME: May be we need to throw an Exception ??
-		}
-
-		Policy effPolicy = getApplicablePolicy(this);
-
-		if (effPolicy != null) {
-
-			/*
-			 * for the moment we consider policies with only one alternative. If
-			 * the policy contains multiple alternatives only the first
-			 * alternative will be considered.
-			 */
-			Iterator iterator = effPolicy.getAlternatives();
-			if (!iterator.hasNext()) {
-				throw new AxisFault(
-						"Policy doesn't contain any policy alternatives");
-			}
-
-			List assertionList = (List) iterator.next();
-
-			Assertion assertion;
-			String namespaceURI;
-
-			List moduleList;
-
-			List namespaceList = new ArrayList();
-			List modulesToEngage = new ArrayList();
-
-			for (Iterator assertions = assertionList.iterator(); assertions
-					.hasNext();) {
-				assertion = (Assertion) assertions.next();
-				namespaceURI = assertion.getName().getNamespaceURI();
-
-				moduleList = configuration
-						.getModulesForPolicyNamesapce(namespaceURI);
-
-				if (moduleList == null) {
-					log.debug("can't find any module to process "
-							+ assertion.getName() + " type assertions");
-					continue;
-				}
-
-				if (!canSupportAssertion(assertion, moduleList)) {
-					throw new AxisFault("atleast one module can't support "
-							+ assertion.getName());
-				}
-
-				if (!namespaceList.contains(namespaceURI)) {
-					namespaceList.add(namespaceURI);
-					modulesToEngage.addAll(moduleList);
-				}
-			}
-
-			/*
-			 * FIXME We need to disengage any modules that are already engaged
-			 * *but* has nothing to do with the policy to apply
-			 */
-
-			engageModulesToAxisDescription(modulesToEngage, this);
-
-		}
-
-		AxisDescription child;
-
-		for (Iterator children = getChildren(); children.hasNext();) {
-			child = (AxisDescription) children.next();
-			child.applyPolicy();
-		}
-	}
-
-	private boolean canSupportAssertion(Assertion assertion, List moduleList) {
-
-		AxisModule axisModule;
-		Module module;
-
-		for (Iterator iterator = moduleList.iterator(); iterator.hasNext();) {
-			axisModule = (AxisModule) iterator.next();
-			// FIXME is this step really needed ??
-			// Shouldn't axisMoudle.getModule always return not-null value ??
-			module = axisModule.getModule();
-
-			if (!(module == null || module.canSupportAssertion(assertion))) {
-				log.debug(axisModule.getName() + " says it can't support "
-						+ assertion.getName());
-				return false;
-			}
-		}
-
-		return true;
-	}
-
 	private void engageModulesToAxisDescription(List moduleList,
 			AxisDescription description) throws AxisFault {
 
@@ -590,56 +541,48 @@
 	}
 
 	private Policy getApplicablePolicy(AxisDescription axisDescription) {
+		if (axisDescription instanceof AxisMessage) {
+			AxisMessage axisMessage = (AxisMessage) axisDescription;
+			AxisOperation axisOperation = axisMessage.getAxisOperation();
+			if (axisOperation != null) {
+				AxisService axisService = (AxisService) axisOperation
+						.getAxisService();
+				if (axisService != null) {
+					if (axisService.getEndpointName() != null) {
+						AxisEndpoint axisEndpoint = axisService
+								.getEndpoint(axisService.getEndpointName());
+						if (axisEndpoint != null) {
+							AxisBinding axisBinding = axisEndpoint.getBinding();
+							AxisBindingOperation axisBindingOperation = (AxisBindingOperation) axisBinding
+									.getChild(axisOperation.getName());
+							String direction = axisMessage.getDirection();
+							AxisBindingMessage axisBindingMessage = null;
+							if (WSDLConstants.WSDL_MESSAGE_DIRECTION_IN
+									.equals(direction)
+									&& WSDLUtil
+											.isInputPresentForMEP(axisOperation
+													.getMessageExchangePattern())) {
+								axisBindingMessage = (AxisBindingMessage) axisBindingOperation
+										.getChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+								return axisBindingMessage.getEffectivePolicy();
+								
+							} else if (WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT
+									.equals(direction)
+									&& WSDLUtil
+											.isOutputPresentForMEP(axisOperation
+													.getMessageExchangePattern())) {
+								axisBindingMessage = (AxisBindingMessage) axisBindingOperation
+										.getChild(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
+								return axisBindingMessage.getEffectivePolicy();
+							}
+						}
 
-		if (axisDescription instanceof AxisOperation) {
-			AxisOperation operation = (AxisOperation) axisDescription;
-			AxisService service = operation.getAxisService();
-
-			if (service != null) {
-
-				AxisEndpoint axisEndpoint = service.getEndpoint(service
-						.getEndpointName());
-
-				AxisBinding axisBinding = null;
-
-				if (axisEndpoint != null) {
-					axisBinding = axisEndpoint.getBinding();
-				}
-
-				AxisBindingOperation axisBindingOperation = null;
-
-				if (axisBinding != null) {
-					axisBindingOperation = (AxisBindingOperation) axisBinding
-							.getChild(operation.getName());
+					}
 				}
-
-				if (axisBindingOperation != null) {
-					return axisBindingOperation.getEffectivePolicy();
-				}
-			}
-
-			return operation.getPolicyInclude().getEffectivePolicy();
-
-		} else if (axisDescription instanceof AxisService) {
-			AxisService service = (AxisService) axisDescription;
-
-			AxisEndpoint axisEndpoint = service.getEndpoint(service
-					.getEndpointName());
-			AxisBinding axisBinding = null;
-
-			if (axisEndpoint != null) {
-				axisBinding = axisEndpoint.getBinding();
-			}
-
-			if (axisBinding != null) {
-				return axisBinding.getEffectivePolicy();
 			}
-
-			return service.getPolicyInclude().getEffectivePolicy();
-
-		} else {
-			return axisDescription.getPolicyInclude().getEffectivePolicy();
+			return ((AxisMessage) axisDescription).getEffectivePolicy();
 		}
+		return null;
 	}
 
 	public PolicySubject getPolicySubject() {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java?rev=644817&r1=644816&r2=644817&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisMessage.java Fri Apr  4 11:47:02 2008
@@ -240,9 +240,12 @@
     }
     
 	public Policy getEffectivePolicy() {
-		if (effectivePolicy == null && !policyCalculated) {
+		if (getPolicySubject().isUpdated()) {
 			effectivePolicy = calculateEffectivePolicy();
-			policyCalculated = true;
+		} else {
+			if (effectivePolicy == null && !policyCalculated) {
+				effectivePolicy = calculateEffectivePolicy();
+			}
 		}
 		return effectivePolicy;
 	}
@@ -253,13 +256,13 @@
 
 		// AxisMessage
 		policySubject = getPolicySubject();
-		policyList.addAll(policySubject.getAttachPolicyComponents());
-		
+		policyList.addAll(policySubject.getAttachedPolicyComponents());
+
 		// AxisOperation
 		AxisOperation axisOperation = getAxisOperation();
 		if (axisOperation != null) {
 			policyList.addAll(axisOperation.getPolicySubject()
-					.getAttachPolicyComponents());
+					.getAttachedPolicyComponents());
 		}
 
 		// AxisService
@@ -267,7 +270,7 @@
 				: axisOperation.getAxisService();
 		if (axisService != null) {
 			policyList.addAll(axisService.getPolicySubject()
-					.getAttachPolicyComponents());
+					.getAttachedPolicyComponents());
 		}
 
 		// AxisConfiguration
@@ -275,9 +278,42 @@
 				: axisService.getAxisConfiguration();
 		if (axisConfiguration != null) {
 			policyList.addAll(axisConfiguration.getPolicySubject()
-					.getAttachPolicyComponents());
+					.getAttachedPolicyComponents());
+		}
+
+		Policy result = PolicyUtil.getMergedPolicy(policyList, axisService);
+		policyCalculated = true;
+		return result;
+	}
+	
+	public boolean isPolicyUpdated() {
+		// AxisMessage
+		PolicySubject policySubject = getPolicySubject();
+		if (policySubject.isUpdated()) {
+			return true;
+		}
+
+		// AxisOperation
+		AxisOperation axisOperation = getAxisOperation();
+		if (axisOperation != null
+				&& axisOperation.getPolicySubject().isUpdated()) {
+			return true;
 		}
 
-		return PolicyUtil.getMergedPolicy(policyList, axisService);
+		// AxisService
+		AxisService axisService = (axisOperation == null) ? null
+				: axisOperation.getAxisService();
+		if (axisService != null && axisService.getPolicySubject().isUpdated()) {
+			return true;
+		}
+
+		// AxisConfiguration
+		AxisConfiguration axisConfiguration = (axisService == null) ? null
+				: axisService.getAxisConfiguration();
+		if (axisConfiguration != null
+				&& axisConfiguration.getPolicySubject().isUpdated()) {
+			return true;
+		}
+		return false;
 	}
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java?rev=644817&r1=644816&r2=644817&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2WSDL11.java Fri Apr  4 11:47:02 2008
@@ -1147,7 +1147,7 @@
 			OMElement wsdlElement) throws Exception {
 		PolicySubject policySubject = axisDescription.getPolicySubject();
 		Collection attachPolicyComponents = policySubject
-				.getAttachPolicyComponents();
+				.getAttachedPolicyComponents();
 
 		for (Iterator iterator = attachPolicyComponents.iterator(); iterator
 				.hasNext();) {
@@ -1205,7 +1205,7 @@
 		PolicySubject policySubject = axisDescription.getPolicySubject();
 		ArrayList policyURIs = new ArrayList();
 
-		for (Iterator iterator = policySubject.getAttachPolicyComponents()
+		for (Iterator iterator = policySubject.getAttachedPolicyComponents()
 				.iterator(); iterator.hasNext();) {
 			Object policyElement = iterator.next();
 			String key;

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/PolicyInclude.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/PolicyInclude.java?rev=644817&r1=644816&r2=644817&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/PolicyInclude.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/PolicyInclude.java Fri Apr  4 11:47:02 2008
@@ -21,7 +21,9 @@
 
 import org.apache.axiom.om.util.UUIDGenerator;
 import org.apache.axis2.util.AxisPolicyLocator;
+import org.apache.axis2.util.PolicyUtil;
 import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyComponent;
 import org.apache.neethi.PolicyReference;
 import org.apache.neethi.PolicyRegistry;
 import org.apache.neethi.PolicyRegistryImpl;
@@ -102,6 +104,16 @@
         return reg;
     }
 
+    /**
+	 * @param policy
+	 * @see org.apache.axis2.description.PolicySubject#attachPolicy(Policy)
+	 * @see org.apache.axis2.description.PolicySubject#clear()
+	 * @deprecated As of 1.4 release, replaced by
+	 *             {@link PolicySubject #attachPolicy(Policy)} Use
+	 *             {@link PolicySubject #clear()} beforehand effective policy of
+	 *             {@link AxisDescription} has to be set as the argument.
+	 * 
+	 */
     public void setPolicy(Policy policy) {
         wrapperElements.clear();
 
@@ -115,8 +127,17 @@
         } else {
             wrapperElements.put(policy.getId(), wrapper);
         }
+        
+        if (description != null) {
+			description.getPolicySubject().clear();
+			description.getPolicySubject().attachPolicy(policy);
+		}
     }
 
+    /**
+	 * @deprecated As of 1.4 release, replaced by
+	 *             {@link PolicySubject #updatePolicy(Policy)}.
+	 */
     public void updatePolicy(Policy policy) {
         String key;
 
@@ -127,10 +148,29 @@
 
         Wrapper wrapper = (Wrapper) wrapperElements.get(key);
         wrapper.value = policy;
-    }
-
+        
+        if (description != null) {
+			description.getPolicySubject().updatePolicy(policy);
+		}
+    }
+
+    /**
+	 * @deprecated As of 1.4 release. You can't override a policies that
+	 *             applicable for the current policy scope via
+	 *             {@link PolicyInclude #setEffectivePolicy(Policy)}. In case
+	 *             you need to make a policy the only policy that is within the
+	 *             policy cache of an {@link AxisDescription} please use
+	 *             {@link PolicySubject #clear()} and
+	 *             {@link PolicySubject #attachPolicy(Policy)} accordingly.
+	 * 
+	 */
     public void setEffectivePolicy(Policy effectivePolicy) {
         this.effectivePolicy = effectivePolicy;
+        
+        if (description != null && effectivePolicy != null) {
+			description.getPolicySubject().clear();
+			description.getPolicySubject().attachPolicy(effectivePolicy);
+		}
     }
 
     public void setDescription(AxisDescription description) {
@@ -202,17 +242,52 @@
         setEffectivePolicy(result);
     }
 
+    /**
+	 * @deprecated As of 1.4 release. If you need to calculate merged policy of
+	 *             all policies that are in the policy cache of
+	 *             {@link AxisDescription}, use
+	 *             {@link PolicySubject #getAttachedPolicyComponents() and {@link org.PolicyUtil #getMergedPolicy(List, AxisDescription)}}
+	 */
     public Policy getPolicy() {
+    	if (description != null) {
+			ArrayList policyList = new ArrayList(description.getPolicySubject()
+					.getAttachedPolicyComponents());
+			return PolicyUtil.getMergedPolicy(policyList, description);
+		}
+    	
         calculatePolicy();
         return policy;
     }
 
+    /**
+	 * @deprecated As of 1.4 release. Use
+	 *             {@link AxisMessage #getEffectivePolicy()} or
+	 *             {@link AxisBindingMessage #getEffectivePolicy()} when
+	 *             applicable.
+	 */
     public Policy getEffectivePolicy() {
+    	if (description != null) {
+			if (description instanceof AxisMessage) {
+				return ((AxisMessage) description).getEffectivePolicy();
+			} else if (description instanceof AxisBindingMessage) {
+				return ((AxisBindingMessage) description).getEffectivePolicy();
+			}
+		}
+    	
         calculateEffectivePolicy();
         return effectivePolicy;
     }
 
+    /**
+	 * @deprecated As of 1.4 release, replaced by
+	 *             {@link PolicySubject #getAttachedPolicyComponents()}
+	 */
     public ArrayList getPolicyElements() {
+    	if (description != null) {
+			return new ArrayList(description.getPolicySubject()
+					.getAttachedPolicyComponents());
+		}
+    	
         ArrayList policyElementsList = new ArrayList();
         Iterator policyElementIterator = wrapperElements.values().iterator();
 
@@ -223,6 +298,13 @@
         return policyElementsList;
     }
 
+    /**
+	 * @deprecated As of 1.4 release. The policy element type is no longer
+	 *             required since we maintain a complete binding description
+	 *             hierarchy for the static description the service. Hence use
+	 *             {@link PolicySubject #getAttachedPolicyComponents()} on
+	 *             appropriate description object.
+	 */
     public ArrayList getPolicyElements(int type) {
         ArrayList policyElementList = new ArrayList();
         Iterator wrapperElementIterator = wrapperElements.values().iterator();
@@ -238,14 +320,34 @@
         return policyElementList;
     }
 
+    /**
+	 * @deprecated As of 1.4 release. Use ServiceData.xml or Axis2 DataLocators
+	 *             to configure policies that are stored separately.
+	 */
     public void registerPolicy(String key, Policy policy) {
         reg.register(key, policy);
     }
 
+    /**
+	 * @deprecated As of 1.4 release, replaced by
+	 *             {@link PolicySubject #getAttachedPolicyComponent(String)}
+	 */
     public Policy getPolicy(String key) {
+    	if (description != null) {
+			PolicyComponent result = description.getPolicySubject()
+					.getAttachedPolicyComponent(key);
+			if (result != null && result instanceof Policy) {
+				return (Policy) result;
+			}
+		}
+    	
         return reg.lookup(key);
     }
 
+    /**
+	 * @deprecated As of 1.4 release, replaced by
+	 *             {@link PolicySubject #attachPolicy(Policy)}
+	 */
     public void addPolicyElement(int type, Policy policy) {
 
         String key;
@@ -259,11 +361,24 @@
         Wrapper wrapper = new Wrapper(type, policy);
         wrapperElements.put(key, wrapper);
         reg.register(key, policy);
+        
+        if (description != null) {
+			description.getPolicySubject().attachPolicy(policy);
+		}
     }
 
+    /**
+	 * @deprecated As of 1.4 release, replaced by
+	 *             {@link PolicySubject #attachPolicyReference(PolicyReference)}
+	 */
     public void addPolicyRefElement(int type, PolicyReference policyReference) {
         Wrapper wrapper = new Wrapper(type, policyReference);
         wrapperElements.put(policyReference.getURI(), wrapper);
+        
+        if (description != null) {
+			description.getPolicySubject().attachPolicyReference(
+					policyReference);
+		}
     }
 
     class Wrapper {
@@ -292,17 +407,40 @@
         }
     }
 
+    /**
+	 * @deprecated As of 1.4 release, replaced by
+	 *             {@link PolicySubject #detachPolicyComponent(String)}
+	 */
     public void removePolicyElement(String policyURI) {
         wrapperElements.remove(policyURI);
         reg.remove(policyURI);
+        
+        if (description != null) {
+			description.getPolicySubject().detachPolicyComponent(policyURI);
+		}
     }
 
+    /**
+	 * @deprecated As of 1.4 release, replaced by {@link PolicySubject #clear()}
+	 */
     public void removeAllPolicyElements() {
         wrapperElements.clear();
+        
+        if (description != null) {
+			description.getPolicySubject().clear();
+		}
     }
     
+    /**
+	 * @deprecated As of 1.4 release, replaced by
+	 *             {@link PolicySubject #getAttachedPolicyComponents()}
+	 */
     public List getAttachedPolicies() {
-    
+    	if (description != null) {
+			return new ArrayList(description.getPolicySubject()
+					.getAttachedPolicyComponents());
+		}
+    	
         ArrayList  arrayList = new ArrayList();
         
         for (Iterator iterator = wrapperElements.values().iterator(); iterator.hasNext();) {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/PolicySubject.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/PolicySubject.java?rev=644817&r1=644816&r2=644817&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/PolicySubject.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/PolicySubject.java Fri Apr  4 11:47:02 2008
@@ -19,20 +19,22 @@
 
 package org.apache.axis2.description;
 
-import org.apache.axiom.om.util.UUIDGenerator;
-import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyComponent;
-import org.apache.neethi.PolicyReference;
-
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Set;
+
+import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyComponent;
+import org.apache.neethi.PolicyReference;
 
 public class PolicySubject {
+
+	private boolean updated = false;
+
 	private HashMap attachedPolicyComponents = new HashMap();
-	
+
 	public void attachPolicy(Policy policy) {
 		String key = policy.getName();
 		if (key == null) {
@@ -44,34 +46,79 @@
 		}
 		attachPolicyComponent(key, policy);
 	}
-	
+
 	public void attachPolicyReference(PolicyReference reference) {
-		attachedPolicyComponents.put(reference.getURI(), reference); 
+		attachedPolicyComponents.put(reference.getURI(), reference);
 	}
-	
+
 	public void attachPolicyComponents(List policyComponents) {
-		for (Iterator iterator = policyComponents.iterator(); iterator.hasNext();) {
+		for (Iterator iterator = policyComponents.iterator(); iterator
+				.hasNext();) {
 			attachPolicyComponent((PolicyComponent) iterator.next());
 		}
 	}
-	
+
 	public void attachPolicyComponent(PolicyComponent policyComponent) {
 		if (policyComponent instanceof Policy) {
 			attachPolicy((Policy) policyComponent);
 		} else if (policyComponent instanceof PolicyReference) {
 			attachPolicyReference((PolicyReference) policyComponent);
 		} else {
-			throw new IllegalArgumentException("Invalid top level policy component type");
+			throw new IllegalArgumentException(
+					"Invalid top level policy component type");
 		}
-		
+
 	}
-	public void attachPolicyComponent(String key, PolicyComponent policyComponent) {
+
+	public void attachPolicyComponent(String key,
+			PolicyComponent policyComponent) {
 		attachedPolicyComponents.put(key, policyComponent);
+		if (!isUpdated()) {
+			setUpdated(true);
+		}
 	}
-	
-	
-	
-	public Collection getAttachPolicyComponents() {
+
+	public PolicyComponent getAttachedPolicyComponent(String key) {
+		return (PolicyComponent) attachedPolicyComponents.get(key);
+
+	}
+
+	public Collection getAttachedPolicyComponents() {
 		return attachedPolicyComponents.values();
+	}
+
+	public boolean isUpdated() {
+		return updated;
+	}
+
+	public void setUpdated(boolean updated) {
+		this.updated = updated;
+	}
+
+	public void updatePolicy(Policy policy) {
+		String key = (policy.getName() != null) ? policy.getName() : policy
+				.getId();
+		if (key == null) {
+			throw new IllegalArgumentException(
+					"policy doesn't have a name or an id ");
+		}
+		attachedPolicyComponents.put(key, policy);
+		if (!isUpdated()) {
+			setUpdated(true);
+		}
+	}
+
+	public void detachPolicyComponent(String key) {
+		attachedPolicyComponents.remove(key);
+		if (!isUpdated()) {
+			setUpdated(true);
+		}
+	}
+
+	public void clear() {
+		attachedPolicyComponents.clear();
+		if (!isUpdated()) {
+			setUpdated(true);
+		}
 	}
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java?rev=644817&r1=644816&r2=644817&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java Fri Apr  4 11:47:02 2008
@@ -291,7 +291,7 @@
         axisServiceGroup.setParent(this);
         axisServiceGroup.addService(service);
         addServiceGroup(axisServiceGroup);
-        processEndpoints(service, service.getAxisConfiguration());
+//        processEndpoints(service, service.getAxisConfiguration());
     }
 
     public synchronized void addServiceGroup(AxisServiceGroup axisServiceGroup)
@@ -326,6 +326,7 @@
         ArrayList servicesIAdded = new ArrayList();
         while (services.hasNext()) {
             axisService = (AxisService) services.next();
+            processEndpoints(axisService, axisService.getAxisConfiguration());
 
             Map endpoints = axisService.getEndpoints();
             String serviceName = axisService.getName();

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/ExternalPolicySerializer.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/ExternalPolicySerializer.java?rev=644817&r1=644816&r2=644817&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/ExternalPolicySerializer.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/ExternalPolicySerializer.java Fri Apr  4 11:47:02 2008
@@ -28,6 +28,7 @@
 import javax.xml.stream.XMLStreamWriter;
 import java.io.OutputStream;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 
@@ -55,38 +56,81 @@
                     .createXMLStreamWriter(os);
             policy = (Policy) policy.normalize(false);
 
-            String prefix = writer.getPrefix(Constants.ATTR_WSP);
-            String wsuPrefix = writer.getPrefix(Constants.URI_WSU_NS);
+            String wspPrefix = writer.getPrefix(Constants.URI_POLICY_NS);
 
-            if (prefix == null) {
-                prefix = Constants.ATTR_WSP;
-                writer.setPrefix(prefix, Constants.URI_POLICY_NS);
-            }
-
-            if (wsuPrefix == null) {
-                // TODO move this 'wsu' value to Neethi2 constants
-                wsuPrefix = "wsu";
-                writer.setPrefix(wsuPrefix, Constants.URI_WSU_NS);
-            }
-
-            // write <wsp:Policy tag
-
-            writer.writeStartElement(prefix, Constants.ELEM_POLICY,
-                                     Constants.URI_POLICY_NS);
-            // write xmlns:wsp=".."
-            writer.writeNamespace(prefix, Constants.URI_POLICY_NS);
-
-            String name = policy.getName();
-            if (name != null) {
-                // write Name=".."
-                writer.writeAttribute(Constants.ATTR_NAME, name);
-            }
-
-            String id = policy.getId();
-            if (id != null) {
-                // write wsu:Id=".."
-                writer.writeAttribute(Constants.ATTR_ID, id);
-            }
+			if (wspPrefix == null) {
+				wspPrefix = Constants.ATTR_WSP;
+				writer.setPrefix(wspPrefix, Constants.URI_POLICY_NS);
+			}
+
+			String wsuPrefix = writer.getPrefix(Constants.URI_WSU_NS);
+			if (wsuPrefix == null) {
+				wsuPrefix = Constants.ATTR_WSU;
+				writer.setPrefix(wsuPrefix, Constants.URI_WSU_NS);
+			}
+
+			writer.writeStartElement(wspPrefix, Constants.ELEM_POLICY,
+					Constants.URI_POLICY_NS);
+
+			QName key;
+
+			String prefix = null;
+			String namespaceURI = null;
+			String localName = null;
+
+			HashMap prefix2ns = new HashMap();
+
+			for (Iterator iterator = policy.getAttributes().keySet().iterator(); iterator
+					.hasNext();) {
+
+				key = (QName) iterator.next();
+				localName = key.getLocalPart();
+
+				namespaceURI = key.getNamespaceURI();
+				namespaceURI = (namespaceURI == null || namespaceURI.length() == 0) ? null
+						: namespaceURI;
+
+				if (namespaceURI != null) {
+
+					String writerPrefix = writer.getPrefix(namespaceURI);
+					writerPrefix = (writerPrefix == null || writerPrefix
+							.length() == 0) ? null : writerPrefix;
+
+					if (writerPrefix == null) {
+						prefix = key.getPrefix();
+						prefix = (prefix == null || prefix.length() == 0) ? null
+								: prefix;
+
+					} else {
+						prefix = writerPrefix;
+					}
+
+					if (prefix != null) {
+						writer.writeAttribute(prefix, namespaceURI, localName,
+								policy.getAttribute(key));
+						prefix2ns.put(prefix, key.getNamespaceURI());
+
+					} else {
+						writer.writeAttribute(namespaceURI, localName, policy
+								.getAttribute(key));
+					}
+
+				} else {
+					writer.writeAttribute(localName, policy.getAttribute(key));
+				}
+
+			}
+
+			// writes xmlns:wsp=".."
+			writer.writeNamespace(wspPrefix, Constants.URI_POLICY_NS);
+
+			String prefiX;
+
+			for (Iterator iterator = prefix2ns.keySet().iterator(); iterator
+					.hasNext();) {
+				prefiX = (String) iterator.next();
+				writer.writeNamespace(prefiX, (String) prefix2ns.get(prefiX));
+			}
 
             writer.writeStartElement(Constants.ATTR_WSP,
                                      Constants.ELEM_EXACTLYONE, Constants.URI_POLICY_NS);



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