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 2006/09/18 09:30:07 UTC

svn commit: r447305 [1/2] - in /webservices/axis2/trunk/java/modules: codegen/src/org/apache/axis2/wsdl/codegen/emitter/ codegen/src/org/apache/axis2/wsdl/codegen/extension/ kernel/src/org/apache/axis2/client/ kernel/src/org/apache/axis2/context/ kerne...

Author: sanka
Date: Mon Sep 18 00:30:05 2006
New Revision: 447305

URL: http://svn.apache.org/viewvc?view=rev&rev=447305
Log:
Integrated the new Neethi2 architecture to Axis2. This is only the 
first step. 

Need to add a lot more coding before we make the real use of this
new Neethi2 codebase.

For a start we need to start ammending the code which is commented 
in AxisDescription



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/codegen/emitter/CEmitter.java
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/PolicyEvaluator.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/WSDLBasedPolicyProcessor.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DescriptionBuilder.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/AxisService.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2OM.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/WSDL11ToAxisServiceBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDLToAxisServiceBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/modules/PolicyExtension.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/Constants.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/builders/LayoutBuilder.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/builders/TransportTokenBuilder.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/AbstractSecurityAssertion.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/AlgorithmSuite.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/Layout.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/SupportingToken.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/TransportToken.java
    webservices/axis2/trunk/java/modules/secpolicy/src/org/apache/ws/secpolicy/model/Trust10.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/Rampart.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/policy/model/CryptoConfig.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/rampart/policy/model/RampartConfig.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/extension/WSSCodegenPolicyExtension.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/ws/security/policy1/model/AbstractSecurityAssertion.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?view=diff&rev=447305&r1=447304&r2=447305
==============================================================================
--- 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 Mon Sep 18 00:30:05 2006
@@ -16,8 +16,9 @@
 import org.apache.axis2.wsdl.util.*;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.neethi.Policy;
 import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.policy.Policy;
+
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -547,7 +548,7 @@
         Policy servicePolicy = policyInclude.getPolicy();
 
         if (servicePolicy != null) {
-            String policyString = PolicyUtil.getPolicyAsString(servicePolicy);
+            String policyString = PolicyUtil.policyComponentToString(servicePolicy);
             addAttribute(doc, "policy", policyString, rootElement);
         }
 
@@ -1414,8 +1415,14 @@
 
                 PolicyInclude policyInclude = axisOperation.getPolicyInclude();
                 Policy policy = policyInclude.getPolicy();
+                
+                
                 if (policy != null) {
-                    addAttribute(doc, "policy", PolicyUtil.getPolicyAsString(policy), methodElement);
+                    try  {
+                    addAttribute(doc, "policy", PolicyUtil.policyComponentToString(policy), methodElement);
+                    } catch (Exception ex) {
+                        throw new RuntimeException(" Can't serialize the policy ..");
+                    }
                 }
 
                 methodElement.appendChild(getInputElement(doc, axisOperation, soapHeaderInputParameterList));
@@ -1455,9 +1462,13 @@
 
                     Policy policy = axisOperation.getPolicyInclude().getPolicy();
                     if (policy != null) {
+                        try  {
                         addAttribute(doc, "policy",
-                                PolicyUtil.getPolicyAsString(policy),
+                                PolicyUtil.policyComponentToString(policy),
                                 methodElement);
+                        } catch (Exception ex) {
+                            throw new RuntimeException("can't serialize the policy ..");
+                        }
                     }
 
 

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java?view=diff&rev=447305&r1=447304&r2=447305
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/emitter/CEmitter.java Mon Sep 18 00:30:05 2006
@@ -24,7 +24,7 @@
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.PolicyInclude;
 import org.apache.axis2.description.AxisMessage;
-import org.apache.ws.policy.Policy;
+import org.apache.neethi.Policy;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -381,7 +381,11 @@
                 PolicyInclude policyInclude = axisOperation.getPolicyInclude();
                 Policy policy = policyInclude.getPolicy();
                 if (policy != null) {
-                    addAttribute(doc, "policy", PolicyUtil.getPolicyAsString(policy), methodElement);
+                    try {
+                        addAttribute(doc, "policy", PolicyUtil.policyComponentToString(policy), methodElement);
+                    } catch (Exception ex) {
+                        throw new RuntimeException("can't serialize the policy to a String " , ex);
+                    }
                 }
 
                 methodElement.appendChild(getInputElement(doc, axisOperation, soapHeaderInputParameterList));
@@ -425,9 +429,13 @@
 
                     Policy policy = axisOperation.getPolicyInclude().getPolicy();
                     if (policy != null) {
+                        try {
                         addAttribute(doc, "policy",
-                                PolicyUtil.getPolicyAsString(policy),
+                                PolicyUtil.policyComponentToString(policy),
                                 methodElement);
+                        } catch (Exception ex) {
+                            throw new RuntimeException("can't serialize the policy to a String", ex);
+                        }
                     }
 
 

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/PolicyEvaluator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/PolicyEvaluator.java?view=diff&rev=447305&r1=447304&r2=447305
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/PolicyEvaluator.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/PolicyEvaluator.java Mon Sep 18 00:30:05 2006
@@ -28,10 +28,11 @@
 import org.apache.axis2.modules.PolicyExtension;
 import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
 import org.apache.axis2.wsdl.util.Constants;
-import org.apache.ws.policy.All;
-import org.apache.ws.policy.ExactlyOne;
-import org.apache.ws.policy.Policy;
-import org.apache.ws.policy.PrimitiveAssertion;
+import org.apache.neethi.All;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.ExactlyOne;
+import org.apache.neethi.Policy;
+
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -39,8 +40,11 @@
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
+
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
 public class PolicyEvaluator implements CodeGenExtension {
@@ -142,62 +146,41 @@
     private void processPolicies(Document document, Element rootElement,
                                  Policy policy, QName opName,Map ns2Exts) {
 
-        if (!policy.isNormalized()) {
-            policy = (Policy) policy.normalize();
-        }
-
         HashMap map = new HashMap();
-
-        ExactlyOne XOR = (ExactlyOne) policy.getTerms()
-                .get(0);
-        All iAND = (All) XOR.getTerms().get(
-                0);
-        All AND = new All();
-        AND.addTerms(iAND.getTerms());
-
-        for (Iterator iterator = AND.getTerms().iterator(); iterator.hasNext();) {
-
-            All nAND = new All();
-            PrimitiveAssertion pa = (PrimitiveAssertion) iterator.next();
-
-            String namespace = pa.getName().getNamespaceURI();
-            nAND.addTerm(pa);
-
-            while (iterator.hasNext()) {
-                pa = (PrimitiveAssertion) iterator.next();
-
-                if (namespace.equals(pa.getName().getNamespaceURI())) {
-                    nAND.addTerm(pa);
+        
+        for (Iterator iterator = policy.getAlternatives(); iterator.hasNext();) {
+            
+            String targetNamesapce = null;
+            Assertion assertion;
+            List assertionList;
+            
+            for (Iterator assertions = ((List) iterator.next()).iterator(); assertions.hasNext();) {
+                assertion = (Assertion) iterator.next();
+                targetNamesapce = assertion.getName().getNamespaceURI();
+                
+                if ((assertionList = (List) map.get(targetNamesapce)) == null)  {
+                    assertionList = new ArrayList();
+                    map.put(targetNamesapce,assertionList);
                 }
+                
+                assertionList.add(assertions);
             }
-
-            map.put(namespace, nAND);
-            AND.getTerms().removeAll(nAND.getTerms());
-
-            iterator = AND.getTerms().iterator();
+            
+            // here we pick the first policy alternative and ignor the rest
+            break;
         }
-
+                
         for (Iterator iterator = map.keySet().iterator(); iterator.hasNext();) {
-            String namespace = (String) iterator.next();
-            PolicyExtension policyExtension = (PolicyExtension) ns2Exts.get(namespace);
-
-//			AxisModule axisModule = (AxisModule) ns2modules.get(namespace);
+            String targetNamespace = (String) iterator.next();
+            PolicyExtension policyExtension = (PolicyExtension) ns2Exts.get(targetNamespace);
 
             if (policyExtension == null) {
                 System.err.println("cannot find a PolicyExtension to process "
-                        + namespace + "type assertions");
+                        + targetNamespace + "type assertions");
                 continue;
             }
-
-            Policy nPolicy = new Policy();
-            ExactlyOne nXOR = new ExactlyOne();
-            nPolicy.addTerm(nXOR);
-
-            All nAND = (All) map
-                    .get(namespace);
-            nXOR.addTerm(nAND);
-
-            policyExtension.addMethodsToStub(document, rootElement, opName, nPolicy);
+            
+            policyExtension.addMethodsToStub(document, rootElement, opName, (List) map.get(targetNamespace));
         }
     }
 
@@ -221,29 +204,31 @@
             this.configuration = configuration;
         }
 
-        public void addMethodsToStub(Document document, Element element, QName operationName, Policy policy) {
-
-            if (!setOnce) {
-                 Object plainBase64PropertyMap = configuration.getProperty(Constants.PLAIN_BASE_64_PROPERTY_KEY);
-                 configuration.putProperty(Constants.BASE_64_PROPERTY_KEY, plainBase64PropertyMap);
-
-                 setOnce = true;
-            }
-
-            Element optimizeContent = document.createElement("optimizeContent");
-            Element opNameElement = document.createElement("opName");
-
-            opNameElement.setAttribute("ns-url", operationName.getNamespaceURI());
-            opNameElement.setAttribute("localName", operationName.getLocalPart());
-
-            optimizeContent.appendChild(opNameElement);
-
-            element.appendChild(optimizeContent);
+        public void addMethodsToStub(Document document, Element element, QName operationName, List assertions) {
+            
+            // FIXME
+
+//            if (!setOnce) {
+//                 Object plainBase64PropertyMap = configuration.getProperty(Constants.PLAIN_BASE_64_PROPERTY_KEY);
+//                 configuration.putProperty(Constants.BASE_64_PROPERTY_KEY, plainBase64PropertyMap);
+//
+//                 setOnce = true;
+//            }
+//
+//            Element optimizeContent = document.createElement("optimizeContent");
+//            Element opNameElement = document.createElement("opName");
+//
+//            opNameElement.setAttribute("ns-url", operationName.getNamespaceURI());
+//            opNameElement.setAttribute("localName", operationName.getLocalPart());
+//
+//            optimizeContent.appendChild(opNameElement);
+//
+//            element.appendChild(optimizeContent);
         }
     }
 
     class EncodePolicyExtension implements PolicyExtension {
-        public void addMethodsToStub(Document document, Element element, QName operationName, Policy policy) {
+        public void addMethodsToStub(Document document, Element element, QName operationName, List assertions) {
             // TODO implement encoding
         }
     }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/WSDLBasedPolicyProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/WSDLBasedPolicyProcessor.java?view=diff&rev=447305&r1=447304&r2=447305
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/WSDLBasedPolicyProcessor.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/WSDLBasedPolicyProcessor.java Mon Sep 18 00:30:05 2006
@@ -18,117 +18,147 @@
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisDescription;
 import org.apache.axis2.description.AxisModule;
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.PolicyInclude;
 import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.ws.policy.All;
-import org.apache.ws.policy.Policy;
-import org.apache.ws.policy.PrimitiveAssertion;
-import org.apache.ws.policy.ExactlyOne;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
 
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.namespace.QName;
 
 public class WSDLBasedPolicyProcessor {
-	private HashMap ns2modules = new HashMap();
-	private ConfigurationContext configctx;
-	
-	
-	public WSDLBasedPolicyProcessor(ConfigurationContext configctx){
-		//create the Map for namespaces to modules this is 1:N mapping
-		// so we got to use array lists
-		this.configctx = configctx;
-		AxisConfiguration axisConfiguration = configctx.getAxisConfiguration();
-		for (Iterator iterator = axisConfiguration.getModules().values()
-				.iterator(); iterator.hasNext();) {
-			AxisModule axisModule = (AxisModule) iterator.next();
-			String[] namespaces = axisModule.getSupportedPolicyNamespaces();
-
-			if (namespaces == null) {
-				continue;
-			}
-
-			for (int i = 0; i < namespaces.length; i++) {
-				ArrayList moduleList = null;
-				Object obj = ns2modules.get(namespaces[i]);
-				if(obj == null){
-					moduleList = new ArrayList(5);
-					ns2modules.put(namespaces[i], moduleList);
-				}else{
-					moduleList = (ArrayList)obj;
-				}
-				moduleList.add(axisModule);
-				
-			}
-		}
-		
-	}
-	
-	
-	
-	public void configureServicePolices(AxisService axisService) throws AxisFault{
-		Iterator operations = axisService.getOperations();
-		while(operations.hasNext()){
-			AxisOperation axisOp = (AxisOperation)operations.next();
-			//TODO we support only Operation level Policy now
-			configureOperationPolices(axisOp);
-		}
-	}
-	
-	
-	public void configureOperationPolices(AxisOperation op) throws AxisFault {
+    private HashMap ns2modules = new HashMap();
+
+    public WSDLBasedPolicyProcessor(ConfigurationContext configctx) {
+        AxisConfiguration axisConfiguration = configctx.getAxisConfiguration();
+        for (Iterator iterator = axisConfiguration.getModules().values()
+                .iterator(); iterator.hasNext();) {
+            AxisModule axisModule = (AxisModule) iterator.next();
+            String[] namespaces = axisModule.getSupportedPolicyNamespaces();
+
+            if (namespaces == null) {
+                continue;
+            }
+
+            for (int i = 0; i < namespaces.length; i++) {
+                ArrayList moduleList = null;
+                Object obj = ns2modules.get(namespaces[i]);
+                if (obj == null) {
+                    moduleList = new ArrayList(5);
+                    ns2modules.put(namespaces[i], moduleList);
+                } else {
+                    moduleList = (ArrayList) obj;
+                }
+                moduleList.add(axisModule);
+
+            }
+        }
+
+    }
+
+    public void configureServicePolices(AxisService axisService)
+            throws AxisFault {
+        Iterator operations = axisService.getOperations();
+        while (operations.hasNext()) {
+            AxisOperation axisOp = (AxisOperation) operations.next();
+            // TODO we support only Operation level Policy now
+            configureOperationPolices(axisOp);
+        }
+    }
+
+    public void configureOperationPolices(AxisOperation op) throws AxisFault {
         PolicyInclude policyInclude = op.getPolicyInclude();
+        Policy policy = policyInclude.getEffectivePolicy();
+        if (policy != null) {
+
+            policy = (Policy) policy.normalize(policyInclude
+                    .getPolicyRegistry(), false);
+
+            for (Iterator iterator = policy.getAlternatives(); iterator
+                    .hasNext();) {
 
-        if (policyInclude != null) {
-            Policy policy = policyInclude.getEffectivePolicy();
-            if (policy != null) {
-                if (!policy.isNormalized()) {
-                    policy = (Policy) policy.normalize();
+                List namespaceList = new ArrayList();
+                Assertion assertion;
+
+                /*
+                 * Fist we computes the set of distinct namesapces of assertions
+                 * of this particular policy alternative.
+                 */
+                for (Iterator assertions = ((List) iterator.next()).iterator(); assertions
+                        .hasNext();) {
+
+                    assertion = (Assertion) iterator.next();
+                    QName name = assertion.getName();
+                    String namespaceURI = name.getNamespaceURI();
+
+                    if (!namespaceList.contains(namespaceURI)) {
+                        namespaceList.add(namespaceURI);
+                    }
                 }
 
-                ExactlyOne XOR = (ExactlyOne) policy
-                        .getTerms().get(0);
-                All AND = (All) XOR
-                        .getTerms().get(0);
-
-                Iterator pAsserations = AND.getTerms().iterator();
-                while (pAsserations.hasNext()) {
-                    PrimitiveAssertion pa = (PrimitiveAssertion) pAsserations
-                            .next();
-                    String namespace = pa.getName().getNamespaceURI();
-                    ArrayList moduleList = (ArrayList) ns2modules
-                            .get(namespace);
-
-                    if (moduleList == null) {
-                        System.err.println("cannot find a module to process "
-                                + namespace + "type assertions");
+                /*
+                 * Now we compute all the modules that are are involved in
+                 * process assertions that are belonged to any of the namespace
+                 * list.
+                 */
+                List modulesToEngage;
+               
+                for (Iterator namespaces = namespaceList.iterator(); iterator
+                        .hasNext();) {
+                    String namespace = (String) namespaces.next();
+                    modulesToEngage = (List) ns2modules.get(namespace);
+
+                    if (modulesToEngage == null) {
+                        /*
+                         * If there isn't a single module that is not interested
+                         * of assertions that belongs to a particular namespace,
+                         * we simply ignor it.
+                         */
+                        System.err
+                                .println("cannot find any modules to process "
+                                        + namespace + "type assertions");
+                        // TODO: Log this ..
+                        continue;
+                        
                     } else {
-                        for (int i = 0; i < moduleList.size(); i++) {
-                            AxisModule axisModule = (AxisModule) moduleList
-                                    .get(i);
-                            Iterator engagedModules = op.getEngagedModules()
-                                    .iterator();
-                            boolean found = false;
-                            while (engagedModules.hasNext()) {
-                                AxisModule module = (AxisModule) engagedModules
-                                        .next();
-                                if (module.getName().equals(
-                                        axisModule.getName())) {
-                                    found = true;
-                                    break;
-                                }
-                            }
-                            if (!found) {
-                                op.engageModule(axisModule, configctx
-                                        .getAxisConfiguration());
-                                axisModule.getModule().engageNotify(op);
-                            }
-                        }
+                        engageModulesToAxisDescription(modulesToEngage, op);
                     }
                 }
+                
+
+                /*
+                 * We only pick the first policy alternative. Other policy
+                 * alternatives are ignored.
+                 */
+                break;
+            }
+        }
+    }
+
+    /**
+     * Engages the list of Modules to the specified AxisDescription. 
+     */
+    private void engageModulesToAxisDescription(List modulesToEngage,
+            AxisDescription axisDescription) throws AxisFault {
+        AxisModule axisModule;
+        QName moduleName;
+
+        for (Iterator iterator = modulesToEngage.iterator(); iterator.hasNext();) {
+            axisModule = (AxisModule) iterator.next();
+            moduleName = axisModule.getName();
+
+            if (!axisDescription.isEngaged(moduleName)) {
+                axisDescription.engageModule(axisModule, axisDescription
+                        .getAxisConfiguration());
+                (axisModule.getModule()).engageNotify(axisDescription);
             }
         }
     }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java?view=diff&rev=447305&r1=447304&r2=447305
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/MessageContext.java Mon Sep 18 00:30:05 2006
@@ -29,7 +29,7 @@
 import org.apache.axis2.client.Options;
 import org.apache.axis2.description.*;
 import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.ws.policy.Policy;
+import org.apache.neethi.Policy;
 
 import javax.activation.DataHandler;
 import javax.xml.namespace.QName;

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DescriptionBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DescriptionBuilder.java?view=diff&rev=447305&r1=447304&r2=447305
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DescriptionBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DescriptionBuilder.java Mon Sep 18 00:30:05 2006
@@ -1,19 +1,18 @@
 /*
-* Copyright 2004,2005 The Apache Software Foundation.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-*      http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 package org.apache.axis2.deployment;
 
@@ -38,10 +37,9 @@
 import org.apache.axis2.i18n.Messages;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.ws.policy.Policy;
-import org.apache.ws.policy.PolicyReference;
-import org.apache.ws.policy.util.OMPolicyReader;
-import org.apache.ws.policy.util.PolicyFactory;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyEngine;
+import org.apache.neethi.PolicyReference;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
@@ -56,7 +54,8 @@
  */
 public class DescriptionBuilder implements DeploymentConstants {
 
-	private static final Log log = LogFactory.getLog(DescriptionBuilder.class);
+    private static final Log log = LogFactory.getLog(DescriptionBuilder.class);
+
     protected AxisConfiguration axisConfig;
 
     protected InputStream descriptionStream;
@@ -64,22 +63,23 @@
     public DescriptionBuilder() {
     }
 
-    public DescriptionBuilder(InputStream serviceInputStream, AxisConfiguration axisConfig) {
+    public DescriptionBuilder(InputStream serviceInputStream,
+            AxisConfiguration axisConfig) {
         this.descriptionStream = serviceInputStream;
         this.axisConfig = axisConfig;
     }
 
     /**
-     * Creates OMElement for a given description document (axis2.xml , services.xml and
-     * module.xml).
-     *
+     * Creates OMElement for a given description document (axis2.xml ,
+     * services.xml and module.xml).
+     * 
      * @return Returns <code>OMElement</code> .
      * @throws javax.xml.stream.XMLStreamException
-     *
+     * 
      */
     public OMElement buildOM() throws XMLStreamException {
-        XMLStreamReader xmlReader =
-                StAXUtils.createXMLStreamReader(descriptionStream);
+        XMLStreamReader xmlReader = StAXUtils
+                .createXMLStreamReader(descriptionStream);
         OMFactory fac = OMAbstractFactory.getOMFactory();
         StAXOMBuilder staxOMBuilder = new StAXOMBuilder(fac, xmlReader);
         OMElement element = staxOMBuilder.getDocumentElement();
@@ -91,12 +91,16 @@
 
     /**
      * Loads default message receivers. First searches in Axiservice for the
-     * given mepURL, if not found searches in AxisConfiguration with the given mepURL.
-     *
-     * @param mepURL  : can be null
-     * @param service :  This can be null <code>AxisService</code>
+     * given mepURL, if not found searches in AxisConfiguration with the given
+     * mepURL.
+     * 
+     * @param mepURL :
+     *            can be null
+     * @param service :
+     *            This can be null <code>AxisService</code>
      */
-    protected MessageReceiver loadDefaultMessageReceiver(String mepURL, AxisService service) {
+    protected MessageReceiver loadDefaultMessageReceiver(String mepURL,
+            AxisService service) {
         MessageReceiver messageReceiver;
         if (mepURL == null) {
             mepURL = WSDLConstants.WSDL20_2004Constants.MEP_URI_IN_OUT;
@@ -110,17 +114,20 @@
     }
 
     /**
-     * Processes default message receivers specified either in axis2.xml or services.xml.
-     *
+     * Processes default message receivers specified either in axis2.xml or
+     * services.xml.
+     * 
      * @param messageReceivers
      */
-    protected HashMap processMessageReceivers(OMElement messageReceivers) throws DeploymentException {
+    protected HashMap processMessageReceivers(OMElement messageReceivers)
+            throws DeploymentException {
         HashMap mr_mep = new HashMap();
-        Iterator msgReceivers = messageReceivers.getChildrenWithName(new QName(TAG_MESSAGE_RECEIVER));
+        Iterator msgReceivers = messageReceivers.getChildrenWithName(new QName(
+                TAG_MESSAGE_RECEIVER));
         while (msgReceivers.hasNext()) {
             OMElement msgReceiver = (OMElement) msgReceivers.next();
-            MessageReceiver receiver =
-                    loadMessageReceiver(Thread.currentThread().getContextClassLoader(), msgReceiver);
+            MessageReceiver receiver = loadMessageReceiver(Thread
+                    .currentThread().getContextClassLoader(), msgReceiver);
             OMAttribute mepAtt = msgReceiver.getAttribute(new QName(TAG_MEP));
             mr_mep.put(mepAtt.getAttributeValue(), receiver);
         }
@@ -128,26 +135,31 @@
     }
 
     /**
-     * Processes default message receivers specified either in axis2.xml or services.xml.
-     *
+     * Processes default message receivers specified either in axis2.xml or
+     * services.xml.
+     * 
      * @param element
      */
-    protected HashMap processMessageReceivers(ClassLoader loader, OMElement element) throws DeploymentException {
+    protected HashMap processMessageReceivers(ClassLoader loader,
+            OMElement element) throws DeploymentException {
         HashMap meps = new HashMap();
-        Iterator iterator = element.getChildrenWithName(new QName(TAG_MESSAGE_RECEIVER));
+        Iterator iterator = element.getChildrenWithName(new QName(
+                TAG_MESSAGE_RECEIVER));
         while (iterator.hasNext()) {
             OMElement receiverElement = (OMElement) iterator.next();
-            MessageReceiver receiver =
-                    loadMessageReceiver(loader, receiverElement);
-            OMAttribute mepAtt = receiverElement.getAttribute(new QName(TAG_MEP));
+            MessageReceiver receiver = loadMessageReceiver(loader,
+                    receiverElement);
+            OMAttribute mepAtt = receiverElement
+                    .getAttribute(new QName(TAG_MEP));
             meps.put(mepAtt.getAttributeValue(), receiver);
         }
         return meps;
     }
 
-    protected MessageReceiver loadMessageReceiver(ClassLoader loader, OMElement element)
-            throws DeploymentException {
-        OMAttribute receiverName = element.getAttribute(new QName(TAG_CLASS_NAME));
+    protected MessageReceiver loadMessageReceiver(ClassLoader loader,
+            OMElement element) throws DeploymentException {
+        OMAttribute receiverName = element.getAttribute(new QName(
+                TAG_CLASS_NAME));
         String className = receiverName.getAttributeValue();
         MessageReceiver receiver = null;
 
@@ -159,17 +171,17 @@
                 receiver = (MessageReceiver) messageReceiver.newInstance();
             }
         } catch (ClassNotFoundException e) {
-            throw new DeploymentException(
-                    Messages.getMessage(
-                            DeploymentErrorMsgs.ERROR_IN_LOADING_MESSAGE_RECEIVER, "ClassNotFoundException", className));
+            throw new DeploymentException(Messages.getMessage(
+                    DeploymentErrorMsgs.ERROR_IN_LOADING_MESSAGE_RECEIVER,
+                    "ClassNotFoundException", className));
         } catch (IllegalAccessException e) {
-            throw new DeploymentException(
-                    Messages.getMessage(
-                            DeploymentErrorMsgs.ERROR_IN_LOADING_MESSAGE_RECEIVER, "IllegalAccessException", className));
+            throw new DeploymentException(Messages.getMessage(
+                    DeploymentErrorMsgs.ERROR_IN_LOADING_MESSAGE_RECEIVER,
+                    "IllegalAccessException", className));
         } catch (InstantiationException e) {
-            throw new DeploymentException(
-                    Messages.getMessage(
-                            DeploymentErrorMsgs.ERROR_IN_LOADING_MESSAGE_RECEIVER, "InstantiationException", className));
+            throw new DeploymentException(Messages.getMessage(
+                    DeploymentErrorMsgs.ERROR_IN_LOADING_MESSAGE_RECEIVER,
+                    "InstantiationException", className));
         }
 
         return receiver;
@@ -177,10 +189,12 @@
 
     /**
      * Processes flow elements in services.xml .
-     *
-     * @param flowelement <code>OMElement</code>
+     * 
+     * @param flowelement
+     *            <code>OMElement</code>
      * @return Returns Flow.
-     * @throws DeploymentException <code>DeploymentException</code>
+     * @throws DeploymentException
+     *             <code>DeploymentException</code>
      */
     protected Flow processFlow(OMElement flowelement, ParameterInclude parent)
             throws DeploymentException {
@@ -190,7 +204,8 @@
             return flow;
         }
 
-        Iterator handlers = flowelement.getChildrenWithName(new QName(TAG_HANDLER));
+        Iterator handlers = flowelement.getChildrenWithName(new QName(
+                TAG_HANDLER));
 
         while (handlers.hasNext()) {
             OMElement handlerElement = (OMElement) handlers.next();
@@ -201,11 +216,13 @@
         return flow;
     }
 
-    protected String[] processSupportedPolicyNamespaces(OMElement supportedPolicyElements) {
-        OMAttribute namespaces = supportedPolicyElements.getAttribute(new QName(TAG_NAMESPACES));
+    protected String[] processSupportedPolicyNamespaces(
+            OMElement supportedPolicyElements) {
+        OMAttribute namespaces = supportedPolicyElements
+                .getAttribute(new QName(TAG_NAMESPACES));
         if (namespaces != null) {
             String value = namespaces.getAttributeValue();
-            if (! value.trim().equals("")) {
+            if (!value.trim().equals("")) {
                 return value.split(" ");
             }
         }
@@ -214,40 +231,47 @@
 
     /**
      * Processes Handler element.
-     *
-     * @param handler_element <code>OMElement</code>
+     * 
+     * @param handler_element
+     *            <code>OMElement</code>
      * @return Returns HandlerDescription.
-     * @throws DeploymentException <code>DeploymentException</code>
+     * @throws DeploymentException
+     *             <code>DeploymentException</code>
      */
-    protected HandlerDescription processHandler(OMElement handler_element, ParameterInclude parent)
-            throws DeploymentException {
+    protected HandlerDescription processHandler(OMElement handler_element,
+            ParameterInclude parent) throws DeploymentException {
         HandlerDescription handler = new HandlerDescription();
 
         // Setting Handler name
-        OMAttribute name_attribute = handler_element.getAttribute(new QName(ATTRIBUTE_NAME));
+        OMAttribute name_attribute = handler_element.getAttribute(new QName(
+                ATTRIBUTE_NAME));
 
         if (name_attribute == null) {
-            throw new DeploymentException(Messages.getMessage(DeploymentErrorMsgs.INVALID_HANDLER,
-                    "Name missing"));
+            throw new DeploymentException(Messages.getMessage(
+                    DeploymentErrorMsgs.INVALID_HANDLER, "Name missing"));
         } else {
             handler.setName(name_attribute.getAttributeValue());
         }
 
         // Setting Handler Class name
-        OMAttribute class_attribute = handler_element.getAttribute(new QName(TAG_CLASS_NAME));
+        OMAttribute class_attribute = handler_element.getAttribute(new QName(
+                TAG_CLASS_NAME));
 
         if (class_attribute == null) {
-            throw new DeploymentException((Messages.getMessage(DeploymentErrorMsgs.INVALID_HANDLER,
+            throw new DeploymentException((Messages.getMessage(
+                    DeploymentErrorMsgs.INVALID_HANDLER,
                     "class name is missing")));
         } else {
             handler.setClassName(class_attribute.getAttributeValue());
         }
 
         // processing phase Rules (order)
-        OMElement order_element = handler_element.getFirstChildWithName(new QName(TAG_ORDER));
+        OMElement order_element = handler_element
+                .getFirstChildWithName(new QName(TAG_ORDER));
 
         if (order_element == null) {
-            throw new DeploymentException((Messages.getMessage(DeploymentErrorMsgs.INVALID_HANDLER,
+            throw new DeploymentException((Messages.getMessage(
+                    DeploymentErrorMsgs.INVALID_HANDLER,
                     "phase rule has not been specified")));
         } else {
             Iterator order_itr = order_element.getAllAttributes();
@@ -282,7 +306,8 @@
                 }
             }
 
-            Iterator parameters = handler_element.getChildrenWithName(new QName(TAG_PARAMETER));
+            Iterator parameters = handler_element
+                    .getChildrenWithName(new QName(TAG_PARAMETER));
 
             processParameters(parameters, handler, parent);
         }
@@ -292,52 +317,59 @@
         return handler;
     }
 
-    protected void processOperationModuleRefs(Iterator moduleRefs, AxisOperation operation)
-            throws DeploymentException {
+    protected void processOperationModuleRefs(Iterator moduleRefs,
+            AxisOperation operation) throws DeploymentException {
         try {
             while (moduleRefs.hasNext()) {
                 OMElement moduleref = (OMElement) moduleRefs.next();
-                OMAttribute moduleRefAttribute = moduleref.getAttribute(new QName(TAG_REFERENCE));
+                OMAttribute moduleRefAttribute = moduleref
+                        .getAttribute(new QName(TAG_REFERENCE));
 
                 if (moduleRefAttribute != null) {
                     String refName = moduleRefAttribute.getAttributeValue();
 
                     if (axisConfig.getModule(new QName(refName)) == null) {
-                        throw new DeploymentException(
-                                Messages.getMessage(DeploymentErrorMsgs.MODULE_NOT_FOUND, refName));
+                        throw new DeploymentException(Messages.getMessage(
+                                DeploymentErrorMsgs.MODULE_NOT_FOUND, refName));
                     } else {
                         operation.addModule(new QName(refName));
                     }
                 }
             }
         } catch (AxisFault axisFault) {
-            throw new DeploymentException(Messages.getMessage(DeploymentErrorMsgs.MODULE_NOT_FOUND,
-                    axisFault.getMessage()));
+            throw new DeploymentException(Messages.getMessage(
+                    DeploymentErrorMsgs.MODULE_NOT_FOUND, axisFault
+                            .getMessage()));
         }
     }
 
     /**
      * Gets the Parameter object from the OM.
-     *
-     * @param parameters       <code>Parameter</code>
-     * @param parameterInclude <code>ParameterInclude</code>
-     * @param parent           <code>ParameterInclude</code>
+     * 
+     * @param parameters
+     *            <code>Parameter</code>
+     * @param parameterInclude
+     *            <code>ParameterInclude</code>
+     * @param parent
+     *            <code>ParameterInclude</code>
      */
-    protected void processParameters(Iterator parameters, ParameterInclude parameterInclude,
-                                     ParameterInclude parent)
+    protected void processParameters(Iterator parameters,
+            ParameterInclude parameterInclude, ParameterInclude parent)
             throws DeploymentException {
         while (parameters.hasNext()) {
-            // this is to check whether some one has locked the parmter at the top level
+            // this is to check whether some one has locked the parmter at the
+            // top level
             OMElement parameterElement = (OMElement) parameters.next();
             Parameter parameter = new Parameter();
             // setting parameterElement
             parameter.setParameterElement(parameterElement);
             // setting parameter Name
-            OMAttribute paramName = parameterElement.getAttribute(new QName(ATTRIBUTE_NAME));
+            OMAttribute paramName = parameterElement.getAttribute(new QName(
+                    ATTRIBUTE_NAME));
             if (paramName == null) {
-                throw new DeploymentException(
-                        Messages.getMessage(DeploymentErrorMsgs.BAD_PARAMETER_ARGUMENT,
-                                parameterElement.toString()));
+                throw new DeploymentException(Messages.getMessage(
+                        DeploymentErrorMsgs.BAD_PARAMETER_ARGUMENT,
+                        parameterElement.toString()));
             }
             parameter.setName(paramName.getAttributeValue());
             // setting parameter Value (the chiled elemnt of the parameter)
@@ -352,7 +384,8 @@
                 parameter.setParameterType(Parameter.TEXT_PARAMETER);
             }
             // setting locking attribute
-            OMAttribute paramLocked = parameterElement.getAttribute(new QName(ATTRIBUTE_LOCKED));
+            OMAttribute paramLocked = parameterElement.getAttribute(new QName(
+                    ATTRIBUTE_LOCKED));
             Parameter parentParam = null;
             if (parent != null) {
                 parentParam = parent.getParameter(parameter.getName());
@@ -360,11 +393,13 @@
             if (paramLocked != null) {
                 String lockedValue = paramLocked.getAttributeValue();
                 if (BOOLEAN_TRUE.equals(lockedValue)) {
-                    // if the parameter is locked at some level parameter value replace by that
-                    if ((parent != null) && parent.isParameterLocked(parameter.getName())) {
-                        throw new DeploymentException(
-                                Messages.getMessage(
-                                        DeploymentErrorMsgs.CONFIG_NOT_FOUND, parameter.getName()));
+                    // if the parameter is locked at some level parameter value
+                    // replace by that
+                    if ((parent != null)
+                            && parent.isParameterLocked(parameter.getName())) {
+                        throw new DeploymentException(Messages.getMessage(
+                                DeploymentErrorMsgs.CONFIG_NOT_FOUND, parameter
+                                        .getName()));
                     } else {
                         parameter.setLocked(true);
                     }
@@ -374,7 +409,8 @@
             }
             try {
                 if (parent != null) {
-                    if ((parentParam == null) || !parent.isParameterLocked(parameter.getName())) {
+                    if ((parentParam == null)
+                            || !parent.isParameterLocked(parameter.getName())) {
                         parameterInclude.addParameter(parameter);
                     }
                 } else {
@@ -387,74 +423,77 @@
     }
 
     /**
-     * Populate the AxisOperation with details from the actionMapping, outputActionMapping
-     * and faultActionMapping elements from the operation element.
+     * Populate the AxisOperation with details from the actionMapping,
+     * outputActionMapping and faultActionMapping elements from the operation
+     * element.
+     * 
      * @param operation
      * @param op_descrip
      */
-    protected void processActionMappings(OMElement operation, AxisOperation op_descrip){
-        Iterator mappingIterator = operation.getChildrenWithName(new QName(Constants.ACTION_MAPPING));
+    protected void processActionMappings(OMElement operation,
+            AxisOperation op_descrip) {
+        Iterator mappingIterator = operation.getChildrenWithName(new QName(
+                Constants.ACTION_MAPPING));
         ArrayList mappingList = new ArrayList();
         while (mappingIterator.hasNext()) {
             OMElement mappingElement = (OMElement) mappingIterator.next();
             String inputActionString = mappingElement.getText().trim();
-            if(log.isTraceEnabled()){
-                log.trace("Input Action Mapping found: "+inputActionString);
+            if (log.isTraceEnabled()) {
+                log.trace("Input Action Mapping found: " + inputActionString);
             }
             mappingList.add(inputActionString);
         }
         op_descrip.setWsamappingList(mappingList);
-        
-        OMElement outputAction = operation.getFirstChildWithName(new QName(Constants.OUTPUT_ACTION_MAPPING));
-        if((outputAction != null) && (outputAction.getText() != null)){
+
+        OMElement outputAction = operation.getFirstChildWithName(new QName(
+                Constants.OUTPUT_ACTION_MAPPING));
+        if ((outputAction != null) && (outputAction.getText() != null)) {
             String outputActionString = outputAction.getText().trim();
-            if(log.isTraceEnabled()){
-                log.trace("Output Action Mapping found: "+outputActionString);
+            if (log.isTraceEnabled()) {
+                log.trace("Output Action Mapping found: " + outputActionString);
             }
             op_descrip.setOutputAction(outputActionString);
         }
-        Iterator faultActionsIterator = operation.getChildrenWithName(new QName(Constants.FAULT_ACTION_MAPPING));
+        Iterator faultActionsIterator = operation
+                .getChildrenWithName(new QName(Constants.FAULT_ACTION_MAPPING));
         while (faultActionsIterator.hasNext()) {
-            OMElement faultMappingElement = (OMElement) faultActionsIterator.next();
+            OMElement faultMappingElement = (OMElement) faultActionsIterator
+                    .next();
             String faultActionString = faultMappingElement.getText().trim();
-            String faultActionName = faultMappingElement.getAttributeValue(new QName(Constants.FAULT_ACTION_NAME));
-            if(faultActionName != null && faultActionString!=null){
-                if(log.isTraceEnabled()){
-                    log.trace("Fault Action Mapping found: "+faultActionName+", "+faultActionString);
+            String faultActionName = faultMappingElement
+                    .getAttributeValue(new QName(Constants.FAULT_ACTION_NAME));
+            if (faultActionName != null && faultActionString != null) {
+                if (log.isTraceEnabled()) {
+                    log.trace("Fault Action Mapping found: " + faultActionName
+                            + ", " + faultActionString);
                 }
                 op_descrip.addFaultAction(faultActionName, faultActionString);
             }
         }
     }
-    
-    
-    protected void processPolicyElements(int type, Iterator policyElements,
-                                         PolicyInclude policyInclude) {
-        OMPolicyReader reader = (OMPolicyReader) PolicyFactory
-                .getPolicyReader(PolicyFactory.OM_POLICY_READER);
 
+    protected void processPolicyElements(int type, Iterator policyElements,
+            PolicyInclude policyInclude) {
         while (policyElements.hasNext()) {
-            Policy p = reader.readPolicy((OMElement) policyElements.next());
+            Policy p = PolicyEngine
+                    .getPolicy((OMElement) policyElements.next());
             policyInclude.addPolicyElement(type, p);
         }
     }
 
-    protected void processPolicyRefElements(int type, Iterator policyRefElements,
-                                            PolicyInclude policyInclude) {
-        OMPolicyReader reader = (OMPolicyReader) PolicyFactory
-                .getPolicyReader(PolicyFactory.OM_POLICY_READER);
+    protected void processPolicyRefElements(int type,
+            Iterator policyRefElements, PolicyInclude policyInclude) {
 
         while (policyRefElements.hasNext()) {
-            PolicyReference policyReference = reader
-                    .readPolicyReference((OMElement) policyRefElements.next());
+            PolicyReference policyReference = PolicyEngine
+                    .getPolicyReference((OMElement) policyRefElements.next());
             policyInclude.addPolicyRefElement(type, policyReference);
         }
     }
 
-
     /**
      * Gets the short file name. Short file name is the name before the dot.
-     *
+     * 
      * @param fileName
      * @return Returns String.
      */
@@ -473,9 +512,8 @@
     }
 
     /**
-     * Gets the value of an attribute.
-     * eg xsd:anyVal --> anyVal
-     *
+     * Gets the value of an attribute. eg xsd:anyVal --> anyVal
+     * 
      * @return Returns String.
      */
     protected String getValue(String in) {

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?view=diff&rev=447305&r1=447304&r2=447305
==============================================================================
--- 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 Mon Sep 18 00:30:05 2006
@@ -20,10 +20,7 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.i18n.Messages;
-import org.apache.ws.policy.All;
-import org.apache.ws.policy.ExactlyOne;
-import org.apache.ws.policy.Policy;
-import org.apache.ws.policy.PrimitiveAssertion;
+import org.apache.neethi.Policy;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -162,96 +159,98 @@
     public void applyPolicy(Policy policy) throws AxisFault {
         AxisConfiguration configuration = getAxisConfiguration();
 
-        this.policyInclude.setPolicy(policy);
-
-        Policy effPolicy = this.policyInclude.getEffectivePolicy();
-        ExactlyOne exactlyOne = (ExactlyOne) effPolicy.getTerms().get(0);
-
-        ArrayList list = new ArrayList();
-
-        for (Iterator iterator = exactlyOne.getTerms().iterator(); iterator.hasNext();) {
-            All all = (All) iterator.next();
-            if (!checkAllternative(all.getTerms(), configuration)) {
-                list.add(all);
-            }
-        }
-
-        exactlyOne.getTerms().removeAll(list);
-
-        if (exactlyOne.isEmpty()) {
-            throw new AxisFault("can't find any Alternative with known Policy assertions");
-        }
-
-        Map modules = configuration.getModules();
-
-        for (Iterator iterator = modules.values().iterator(); iterator.hasNext();) {
-            AxisModule module = (AxisModule) iterator.next();
-            // TODO needs to implement this method
-//            module.validate(effPolicy);
-        }
-
-        if (exactlyOne.isEmpty()) {
-            throw new AxisFault("can't find any compaitible Alternative");
-        }
-
-        // pick an arbitary Alternative
-        All target = (All) exactlyOne.getTerms().get(0);
-        exactlyOne.getTerms().removeAll(exactlyOne.getTerms());
-        exactlyOne.addTerm(target);
-
-        List requiredModules =  getModulesForAlternative(target.getTerms(), configuration);
-
-        for (Iterator iterator = requiredModules.iterator(); iterator.hasNext();) {
-            AxisModule module = (AxisModule) iterator.next();
-            if (! isEngaged(module.getName())) {
-                engageModule(module, configuration);
-            } else {
-                // TODO needs to implement this method
-//                module.applyPolicy(effPolicy, this);
-            }
-        }
+//        this.policyInclude.setPolicy(policy);
+//
+//        Policy effPolicy = this.policyInclude.getEffectivePolicy();
+//        ExactlyOne exactlyOne = (ExactlyOne) effPolicy.getTerms().get(0);
+//
+//        ArrayList list = new ArrayList();
+//
+//        for (Iterator iterator = exactlyOne.getTerms().iterator(); iterator.hasNext();) {
+//            All all = (All) iterator.next();
+//            if (!checkAllternative(all.getTerms(), configuration)) {
+//                list.add(all);
+//            }
+//        }
+//
+//        exactlyOne.getTerms().removeAll(list);
+//
+//        if (exactlyOne.isEmpty()) {
+//            throw new AxisFault("can't find any Alternative with known Policy assertions");
+//        }
+//
+//        Map modules = configuration.getModules();
+//
+//        for (Iterator iterator = modules.values().iterator(); iterator.hasNext();) {
+//            AxisModule module = (AxisModule) iterator.next();
+//            // TODO needs to implement this method
+////            module.validate(effPolicy);
+//        }
+//
+//        if (exactlyOne.isEmpty()) {
+//            throw new AxisFault("can't find any compaitible Alternative");
+//        }
+//
+//        // pick an arbitary Alternative
+//        All target = (All) exactlyOne.getTerms().get(0);
+//        exactlyOne.getTerms().removeAll(exactlyOne.getTerms());
+//        exactlyOne.addTerm(target);
+//
+//        List requiredModules =  getModulesForAlternative(target.getTerms(), configuration);
+//
+//        for (Iterator iterator = requiredModules.iterator(); iterator.hasNext();) {
+//            AxisModule module = (AxisModule) iterator.next();
+//            if (! isEngaged(module.getName())) {
+//                engageModule(module, configuration);
+//            } else {
+//                // TODO needs to implement this method
+////                module.applyPolicy(effPolicy, this);
+//            }
+//        }
 
     }
 
     private List getModulesForAlternative(List primitiveTerms, AxisConfiguration configuration) {
 
-        ArrayList namespaceURIs = new ArrayList();
-        ArrayList modulesList = new ArrayList();
-
-        PrimitiveAssertion primitive;
-        String namespaceURI;
-
-        for (Iterator iterator = primitiveTerms.iterator(); iterator.hasNext();) {
-            primitive = (PrimitiveAssertion) iterator.next();
-            namespaceURI = primitive.getName().getNamespaceURI();
-
-            if (! namespaceURIs.contains(namespaceURI)) {
-                namespaceURIs.add(namespaceURI);
-            }
-        }
-
-        for (Iterator iterator = namespaceURIs.iterator(); iterator.hasNext();) {
-            modulesList.addAll(configuration.getModulesForPolicyNamesapce((String) iterator.next()));
-        }
-
-        return modulesList;
+//        ArrayList namespaceURIs = new ArrayList();
+//        ArrayList modulesList = new ArrayList();
+//
+//        PrimitiveAssertion primitive;
+//        String namespaceURI;
+//
+//        for (Iterator iterator = primitiveTerms.iterator(); iterator.hasNext();) {
+//            primitive = (PrimitiveAssertion) iterator.next();
+//            namespaceURI = primitive.getName().getNamespaceURI();
+//
+//            if (! namespaceURIs.contains(namespaceURI)) {
+//                namespaceURIs.add(namespaceURI);
+//            }
+//        }
+//
+//        for (Iterator iterator = namespaceURIs.iterator(); iterator.hasNext();) {
+//            modulesList.addAll(configuration.getModulesForPolicyNamesapce((String) iterator.next()));
+//        }
+//
+//        return modulesList;
+        throw new UnsupportedOperationException("TODO");
     }
     
     private boolean checkAllternative(List terms, AxisConfiguration configuration) {
-
-        PrimitiveAssertion assertion;
-
-        for (Iterator iterator = terms.iterator(); iterator.hasNext();) {
-            assertion = (PrimitiveAssertion) iterator.next();
-
-            String namespace = assertion.getName().getNamespaceURI();
-            List modulesList = configuration.getModulesForPolicyNamesapce(namespace);
-            if (modulesList != null) {
-                return false;
-            }
-
-        }
-        return true;
+//
+//        PrimitiveAssertion assertion;
+//
+//        for (Iterator iterator = terms.iterator(); iterator.hasNext();) {
+//            assertion = (PrimitiveAssertion) iterator.next();
+//
+//            String namespace = assertion.getName().getNamespaceURI();
+//            List modulesList = configuration.getModulesForPolicyNamesapce(namespace);
+//            if (modulesList != null) {
+//                return false;
+//            }
+//
+//        }
+//        return true;
+        throw new UnsupportedOperationException("TODO");
     }
 
     

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java?view=diff&rev=447305&r1=447304&r2=447305
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService.java Mon Sep 18 00:30:05 2006
@@ -514,19 +514,6 @@
         return schema;
     }
 
-    public void printPolicy(OutputStream out) throws AxisFault {
-        PolicyUtil.writePolicy(getPolicyInclude(), out);
-    }
-
-    public void printPolicy(OutputStream out, String operationName) throws AxisFault {
-        AxisOperation axisOperation = getOperation(new QName(operationName));
-        if (axisOperation == null) {
-            throw new AxisFault(Messages.getMessage("invalidoperation",
-                    operationName));
-        }
-        PolicyUtil.writePolicy(axisOperation.getPolicyInclude(), out);
-    }
-
     public AxisConfiguration getAxisConfiguration() {
         if (getParent() != null) {
             return (AxisConfiguration) getParent().getParent();

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2OM.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2OM.java?view=diff&rev=447305&r1=447304&r2=447305
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2OM.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisService2OM.java Mon Sep 18 00:30:05 2006
@@ -1,32 +1,36 @@
 package org.apache.axis2.description;
 
-import org.apache.axiom.om.*;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
 import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.namespace.Constants;
+import org.apache.axis2.util.PolicyUtil;
 import org.apache.axis2.wsdl.SOAPHeaderMessage;
 import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyComponent;
+import org.apache.neethi.PolicyReference;
+import org.apache.neethi.PolicyRegistry;
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.java2wsdl.Java2WSDLConstants;
-import org.apache.ws.policy.Policy;
-import org.apache.ws.policy.PolicyConstants;
-import org.apache.ws.policy.PolicyReference;
-import org.apache.ws.policy.util.PolicyFactory;
-import org.apache.ws.policy.util.PolicyRegistry;
-import org.apache.ws.policy.util.PolicyWriter;
-import org.apache.ws.policy.util.StAXPolicyWriter;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.net.URI;
-import java.util.*;
 
 /*
  * Copyright 2004,2005 The Apache Software Foundation.
@@ -865,57 +869,32 @@
     private void addPolicyAsExtElement(int type, PolicyInclude policyInclude,
                                        OMElement element, OMFactory factory) throws Exception {
         ArrayList elementList = policyInclude.getPolicyElements(type);
-        StAXPolicyWriter pwrt = (StAXPolicyWriter) PolicyFactory
-                .getPolicyWriter(PolicyFactory.StAX_POLICY_WRITER);
-
+        
         for (Iterator iterator = elementList.iterator(); iterator.hasNext();) {
             Object policyElement = iterator.next();
 
             if (policyElement instanceof Policy) {
-                ByteArrayOutputStream baos = new ByteArrayOutputStream();
-                pwrt.writePolicy((Policy) policyElement, baos);
-
-                ByteArrayInputStream bais = new ByteArrayInputStream(baos
-                        .toByteArray());
-                element.addChild(OMXMLBuilderFactory.createStAXOMBuilder(
-                        factory, StAXUtils.createXMLStreamReader(bais))
-                        .getDocumentElement());
-
+                element.addChild(PolicyUtil.getPolicyComponentAsOMElement((PolicyComponent) policyElement));
+                
             } else if (policyElement instanceof PolicyReference) {
-                OMNamespace ns = factory.createOMNamespace(
-                        PolicyConstants.POLICY_NAMESPACE_URI,
-                        PolicyConstants.POLICY_PREFIX);
-                OMElement refElement = factory.createOMElement(
-                        PolicyConstants.POLICY_REFERENCE, ns);
-
-                String policyURIString = ((PolicyReference) policyElement)
-                        .getPolicyURIString();
-
-                OMAttribute attribute = factory.createOMAttribute("URI", null,
-                        policyURIString);
-                refElement.addAttribute(attribute);
-                element.addChild(refElement);
-
+                element.addChild(PolicyUtil.getPolicyComponentAsOMElement((PolicyComponent) policyElement));
+                
                 PolicyRegistry reg = policyInclude.getPolicyRegistry();
-
-                String key = policyURIString;
-
-                if (policyURIString.startsWith("#")) {
-                    key = policyURIString.substring(policyURIString
-                            .indexOf("#") + 1);
+                String key = ((PolicyReference) policyElement).getURI();
+                
+                if (key.startsWith("#")) {
+                    key = key.substring(key.indexOf("#") + 1);
                 }
 
                 Policy p = reg.lookup(key);
 
                 if (p == null) {
                     throw new Exception("Policy not found for uri : "
-                            + policyURIString);
+                            + key);
                 }
-
+                
                 addPolicyToDefinitionElement(key, p);
-
             }
-
         }
     }
 
@@ -923,47 +902,42 @@
                                          OMElement element, OMFactory factory) throws Exception {
 
         ArrayList elementList = policyInclude.getPolicyElements(type);
-//        StAXPolicyWriter pwrt = (StAXPolicyWriter) PolicyFactory
-//                .getPolicyWriter(PolicyFactory.StAX_POLICY_WRITER);
-
         ArrayList policyURIs = new ArrayList();
 
         for (Iterator iterator = elementList.iterator(); iterator.hasNext();) {
             Object policyElement = iterator.next();
-
-            String id;
+            String key;
 
             if (policyElement instanceof Policy) {
                 Policy p = (Policy) policyElement;
-
+                
                 if (p.getId() != null) {
-                    id = "#" + p.getId();
+                    key = "#" + p.getId();
                 } else if (p.getName() != null) {
-                    id = p.getName();
+                    key = p.getName();
                 } else {
                     throw new RuntimeException(
                             "Can't add the Policy as an extensibility attribute since it doesn't have a id or a name attribute");
                 }
 
-                policyURIs.add(id);
-                addPolicyToDefinitionElement(id, p);
+                policyURIs.add(key);
+                addPolicyToDefinitionElement(key, p);
 
             } else {
-                String policyURIString = ((PolicyReference) policyElement)
-                        .getPolicyURIString();
+                String uri = ((PolicyReference) policyElement)
+                        .getURI();
                 PolicyRegistry registry = policyInclude.getPolicyRegistry();
 
-                String key;
-                if (policyURIString.startsWith("#")) {
-                    key = policyURIString.substring(policyURIString.indexOf('#') + 1);
+                if (uri.startsWith("#")) {
+                    key = uri.substring(uri.indexOf('#') + 1);
                 } else {
-                    key = policyURIString;
+                    key = uri;
                 }
 
                 Policy p = registry.lookup(key);
 
                 if (p == null) {
-                    throw new RuntimeException("Cannot resolve " + policyURIString + " to a Policy");
+                    throw new RuntimeException("Cannot resolve " + uri + " to a Policy");
                 }
                 addPolicyToDefinitionElement(key, p);
             }
@@ -972,40 +946,33 @@
         if (!policyURIs.isEmpty()) {
             String value = null;
 
+            /*
+             * We need to create a String that is like 'uri1 uri2 .." to set as the value of 
+             * the wsp:PolicyURIs attribute.
+             */
             for (Iterator iterator = policyURIs.iterator(); iterator.hasNext();) {
                 String uri = (String) iterator.next();
                 value = (value == null) ? uri : " " + uri;
             }
 
             OMNamespace ns = factory.createOMNamespace(
-                    PolicyConstants.POLICY_NAMESPACE_URI,
-                    PolicyConstants.POLICY_PREFIX);
+                    org.apache.neethi.Constants.URI_POLICY_NS,
+                    org.apache.neethi.Constants.POLICY_PREFIX);
             OMAttribute URIs = factory.createOMAttribute("PolicyURIs", ns,
                     value);
             element.addAttribute(URIs);
-
         }
-
     }
 
     private void addPoliciesToDefinitionElement(Iterator iterator,
                                                 OMElement definitionElement) throws Exception {
         Policy policy;
-        ByteArrayInputStream bais;
-        ByteArrayOutputStream baos;
         OMElement policyElement;
         OMNode firstChild;
 
         for (; iterator.hasNext();) {
             policy = (Policy) iterator.next();
-            baos = new ByteArrayOutputStream();
-            getPolicyWriter().writePolicy(policy, baos);
-
-            bais = new ByteArrayInputStream(baos.toByteArray());
-            policyElement = OMXMLBuilderFactory.createStAXOMBuilder(
-                    OMAbstractFactory.getOMFactory(),
-                    XMLInputFactory.newInstance().createXMLStreamReader(bais))
-                    .getDocumentElement();
+            policyElement = PolicyUtil.getPolicyComponentAsOMElement(policy);
 
             firstChild = definition.getFirstOMChild();
 
@@ -1019,12 +986,5 @@
 
     private void addPolicyToDefinitionElement(String key, Policy policy) {
         policiesInDefinitions.put(key, policy);
-    }
-
-    /**
-     * Returns a StAX based PolicyWriter.
-     */
-    private PolicyWriter getPolicyWriter() {
-        return PolicyFactory.getPolicyWriter(PolicyFactory.StAX_POLICY_WRITER);
     }
 }

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?view=diff&rev=447305&r1=447304&r2=447305
==============================================================================
--- 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 Mon Sep 18 00:30:05 2006
@@ -18,9 +18,10 @@
 
 import org.apache.axiom.om.util.UUIDGenerator;
 import org.apache.axis2.i18n.Messages;
-import org.apache.ws.policy.Policy;
-import org.apache.ws.policy.PolicyReference;
-import org.apache.ws.policy.util.PolicyRegistry;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyReference;
+import org.apache.neethi.PolicyRegistry;
+import org.apache.neethi.PolicyRegistryImpl;
 
 import java.util.ArrayList;
 import java.util.Hashtable;
@@ -79,18 +80,18 @@
 	private Hashtable wrapperElements = new Hashtable();
 
 	public PolicyInclude() {
-		reg = new PolicyRegistry();
+		reg = new PolicyRegistryImpl();
 	}
-	
+    
 	public PolicyInclude(AxisDescription axisDescription) {
-		reg = new PolicyRegistry();
-		setDescription(axisDescription);
 		
 		if (axisDescription.getParent() != null) {
 			PolicyInclude parentPolicyInclude = axisDescription.getParent().getPolicyInclude();
-			reg.setParent(parentPolicyInclude.getPolicyRegistry());
-		}
-		
+            reg = new PolicyRegistryImpl(parentPolicyInclude.getPolicyRegistry());
+		} else {
+		    reg = new PolicyRegistryImpl();
+        }
+        setDescription(axisDescription);
 	}
 
 	public void setPolicyRegistry(PolicyRegistry reg) {
@@ -103,25 +104,30 @@
 
 	public void setPolicy(Policy policy) {
 		wrapperElements.clear();
-		
-		if (policy.getPolicyURI() != null && policy.getPolicyURI().equals("")) {
-			policy.setId(UUIDGenerator.getUUID());
-		}
-		
-		Wrapper wrapper = new Wrapper(PolicyInclude.ANON_POLICY, policy);
-		wrapperElements.put(policy.getPolicyURI(), wrapper);
-		
+        
+        if (policy.getName() == null && policy.getId() == null) {
+            policy.setId(UUIDGenerator.getUUID());
+        }
+        
+        Wrapper wrapper = new Wrapper(PolicyInclude.ANON_POLICY, policy);
+        if (policy.getName() != null) {
+            wrapperElements.put(policy.getName(), wrapper);
+        } else {
+            wrapperElements.put(policy.getId(), wrapper);
+        }
+        
 		useCacheP = false;
 	}
 	
 	public void updatePolicy(Policy policy) {
-		String policyURI = policy.getPolicyURI();
-		
-		if (policyURI == null && "".equals(policyURI)) {
-			throw new RuntimeException(Messages.getMessage("emptypolicy"));
-		}
+		String key;
+        
+        if ((key = policy.getName()) == null && (key = policy.getId()) == null) {
+            // TODO throw more meaningful exception ..
+            throw new RuntimeException("policy doesn't have a name or an id ");            
+        }
 		
-		Wrapper wrapper = (Wrapper) wrapperElements.get(policyURI);
+		Wrapper wrapper = (Wrapper) wrapperElements.get(key);
 		wrapper.value = policy;
 		
 		useCacheP = false;		
@@ -158,7 +164,7 @@
 
 			if (policyElement instanceof PolicyReference) {
 				p = (Policy) ((PolicyReference) policyElement)
-						.normalize(getPolicyRegistry());
+						.normalize(getPolicyRegistry(), false);
 
 			} else if (policyElement instanceof Policy) {
 				p = (Policy) policyElement;
@@ -167,10 +173,10 @@
 				// TODO AxisFault?
 				throw new RuntimeException();
 			}
-
-			result = (result == null) ? (Policy) p.normalize(reg)
-					: (Policy) result.merge(p, reg);
-		}
+            
+            result = (result == null) ? (Policy) p : (Policy) result.merge(p);
+        }
+        
 		this.policy = result;
 		useCacheP(true);
 	}
@@ -187,7 +193,7 @@
 			} else {
 				
 				if (getPolicy() != null) {
-					result = (Policy) parentPolicy.merge(getPolicy(), reg);
+					result = (Policy) parentPolicy.merge(getPolicy());
 					
 				} else {
 					result = parentPolicy;
@@ -245,38 +251,38 @@
 		return policyElementList;
 	}
 
-	public void registerPolicy(Policy policy) {
-		reg.register(policy.getPolicyURI(), policy);
+	public void registerPolicy(String key, Policy policy) {
+		reg.register(key, policy);
 	}
 
-	public Policy getPolicy(String policyURI) {
-		return reg.lookup(policyURI);
+	public Policy getPolicy(String key) {
+		return reg.lookup(key);
 	}
 
 	public void addPolicyElement(int type, Policy policy) {
-		if (policy.getPolicyURI() == null || policy.getPolicyURI().equals("")) {
-			policy.setId(UUIDGenerator.getUUID());
-		}
-		Wrapper wrapper = new Wrapper(type, policy);
-		wrapperElements.put(policy.getPolicyURI(), wrapper);
-
-        if (policy.getId() != null) {
-            reg.register(policy.getId(), policy);
-        }
         
-        if (policy.getName() != null) {
-            reg.register(policy.getName(), policy);
+        String key;
+        
+        if ((key = policy.getName()) == null && (key = policy.getId()) == null) {
+            policy.setId(UUIDGenerator.getUUID());
         }
+        
+        key = (policy.getName() != null) ? policy.getName() : policy.getId();
+        
+		Wrapper wrapper = new Wrapper(type, policy);
+		wrapperElements.put(key, wrapper);
+        reg.register(key, policy);
 	}
 
 	public void addPolicyRefElement(int type, PolicyReference policyReference) {
 		Wrapper wrapper = new Wrapper(type, policyReference);
-		wrapperElements.put(policyReference.getPolicyURIString(), wrapper);
+		wrapperElements.put(policyReference.getURI(), wrapper);
 	}
 
 	public void invalidate() {
 		
 		if (description != null) {
+            //FIXME
 //			Iterator children = description.getChildren();
 //			
 //			if (children != null) {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java?view=diff&rev=447305&r1=447304&r2=447305
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java Mon Sep 18 00:30:05 2006
@@ -6,17 +6,16 @@
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.AddressingHelper;
 import org.apache.axis2.addressing.wsdl.WSDL11ActionHelper;
+import org.apache.axis2.util.PolicyUtil;
 import org.apache.axis2.util.XMLUtils;
 import org.apache.axis2.wsdl.SOAPHeaderMessage;
 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.ws.policy.Policy;
-import org.apache.ws.policy.PolicyConstants;
-import org.apache.ws.policy.PolicyReference;
-import org.apache.ws.policy.util.DOMPolicyReader;
-import org.apache.ws.policy.util.PolicyFactory;
+import org.apache.neethi.Constants;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyReference;
 import org.apache.ws.commons.schema.utils.NamespaceMap;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -768,14 +767,10 @@
             String MEP = getMEP(wsdl4jOperation);
             axisOperation = AxisOperationFactory.getOperationDescription(MEP);
             axisOperation.setName(opName);
-
-            //All policy includes must share same registry
-            PolicyInclude pi = axisOperation.getPolicyInclude();
-            if (pi == null) {
-                pi = new PolicyInclude();
-                axisOperation.setPolicyInclude(pi);
-            }
-            pi.setPolicyRegistry(registry);
+            
+            // setting the PolicyInclude property of the AxisOperation 
+            PolicyInclude policyInclude = new PolicyInclude(axisOperation);
+            axisOperation.setPolicyInclude(policyInclude);
         }
 
         copyExtensibleElements(wsdl4jOperation.getExtensibilityElements(), dif,
@@ -1511,24 +1506,17 @@
                             "location"));
                 } else if (WSDLConstants.WSDL11Constants.POLICY
                         .equals(unknown.getElementType())) {
-
-                    DOMPolicyReader policyReader = (DOMPolicyReader) PolicyFactory
-                            .getPolicyReader(PolicyFactory.DOM_POLICY_READER);
-                    Policy policy = policyReader.readPolicy(unknown
-                            .getElement());
-
+                    
+                    Policy policy = (Policy) PolicyUtil.getPolicyComponent(unknown.getElement());
                     addPolicy(description, originOfExtensibilityElements,
                             policy);
 
                 } else if (WSDLConstants.WSDL11Constants.POLICY_REFERENCE.equals(unknown
                         .getElementType())) {
-
-                    DOMPolicyReader policyReader = (DOMPolicyReader) PolicyFactory
-                            .getPolicyReader(PolicyFactory.DOM_POLICY_READER);
-                    PolicyReference policyRef = policyReader
-                            .readPolicyReference(unknown.getElement());
-                    addPolicyRef(description, originOfExtensibilityElements,
-                            policyRef);
+                    
+                    PolicyReference policyReference = (PolicyReference) PolicyUtil.getPolicyComponent(unknown.getElement());
+                    addPolicyRef(description, originOfExtensibilityElements, policyReference);
+                    
                 } else if (AddressingConstants.Final.WSAW_USING_ADDRESSING
                         .equals(unknown.getElementType())
                         || AddressingConstants.Submission.WSAW_USING_ADDRESSING
@@ -1898,9 +1886,11 @@
         for (Iterator iterator = extAttributes.keySet().iterator(); iterator
                 .hasNext();) {
             key = (QName) iterator.next();
-            if (PolicyConstants.POLICY_NAMESPACE_URI.equals(key
+            
+            if (Constants.URI_POLICY_NS.equals(key
                     .getNamespaceURI())
                     && "PolicyURIs".equals(key.getLocalPart())) {
+                
                 value = (QName) extAttributes.get(key);
                 String policyURIs = value.getLocalPart();
 
@@ -1909,8 +1899,9 @@
 
                     PolicyReference ref;
                     for (int i = 0; i < uris.length; i++) {
-                        ref = new PolicyReference(uris[i]);
-
+                        ref = new PolicyReference();
+                        ref.setURI(uris[i]);
+                        
                         if (PORT_TYPE.equals(origin)) {
                             PolicyInclude include = description
                                     .getPolicyInclude();
@@ -1921,7 +1912,6 @@
                 }
             }
         }
-
     }
 
     /**
@@ -1939,19 +1929,14 @@
             if (extElement instanceof UnknownExtensibilityElement) {
                 UnknownExtensibilityElement unknown = (UnknownExtensibilityElement) extElement;
                 if (WSDLConstants.WSDL11Constants.POLICY.equals(unknown.getElementType())) {
-
-                    DOMPolicyReader policyReader = (DOMPolicyReader) PolicyFactory
-                            .getPolicyReader(PolicyFactory.DOM_POLICY_READER);
-                    Policy policy = policyReader.readPolicy(unknown
-                            .getElement());
-
-                    if (policy.getId() != null) {
-                        registry.register(policy.getId(), policy);
-                    }
-
-                    if (policy.getName() != null) {
-                        registry.register(policy.getName(), policy);
+                    
+                    Policy policy = (Policy) PolicyUtil.getPolicyComponent(unknown.getElement());
+                    
+                    String key;
+                    if ((key = policy.getName()) != null || (key = policy.getId()) != null) {
+                        registry.register(key, policy);
                     }
+                    
                 }
             }
         }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDLToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDLToAxisServiceBuilder.java?view=diff&rev=447305&r1=447304&r2=447305
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDLToAxisServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDLToAxisServiceBuilder.java Mon Sep 18 00:30:05 2006
@@ -2,10 +2,10 @@
 
 import org.apache.axis2.namespace.Constants;
 import org.apache.axis2.AxisFault;
+import org.apache.neethi.PolicyRegistry;
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
 import org.apache.ws.commons.schema.resolver.URIResolver;
-import org.apache.ws.policy.util.PolicyRegistry;
 import org.w3c.dom.Element;
 
 import javax.xml.namespace.QName;

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/modules/PolicyExtension.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/modules/PolicyExtension.java?view=diff&rev=447305&r1=447304&r2=447305
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/modules/PolicyExtension.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/modules/PolicyExtension.java Mon Sep 18 00:30:05 2006
@@ -16,13 +16,14 @@
 
 package org.apache.axis2.modules;
 
-import org.apache.ws.policy.Policy;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
+import java.util.List;
 
 import javax.xml.namespace.QName;
 
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
 public interface PolicyExtension {
-	public void addMethodsToStub(Document document, Element element, QName methodName,Policy policy);
+	public void addMethodsToStub(Document document, Element element, QName methodName, List assertions);
 
 }



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