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 2005/12/28 05:21:47 UTC

svn commit: r359387 - in /webservices/axis2/trunk/java: etc/ modules/addressing/ modules/codegen/ modules/core/ modules/core/src/org/apache/axis2/ modules/core/src/org/apache/axis2/context/ modules/core/src/org/apache/axis2/deployment/ modules/core/src...

Author: sanka
Date: Tue Dec 27 20:21:10 2005
New Revision: 359387

URL: http://svn.apache.org/viewcvs?rev=359387&view=rev
Log:
Adding PolicyInclude class to hold policy information in Axis2 
description classes.
Modifying required Builder classes to extract Policy Information in 
aixs2.xml, services.xml ... etc and store it in appropriate description 
classes


Added:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/PolicyInclude.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/PolicyUtil.java
    webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/PolicyExtensibilityElement.java
    webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/PolicyExtensitbilityElementImpl.java
Modified:
    webservices/axis2/trunk/java/etc/project.properties
    webservices/axis2/trunk/java/modules/addressing/project.xml
    webservices/axis2/trunk/java/modules/codegen/project.xml
    webservices/axis2/trunk/java/modules/core/project.xml
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContextFactory.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisConfigBuilder.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentConstants.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DescriptionBuilder.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ModuleBuilder.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ModuleDescription.java
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfiguration.java
    webservices/axis2/trunk/java/modules/integration/project.xml
    webservices/axis2/trunk/java/modules/wsdl/project.xml
    webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/ExtensionConstants.java
    webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/ExtensionFactoryImpl.java

Modified: webservices/axis2/trunk/java/etc/project.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/etc/project.properties?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/etc/project.properties (original)
+++ webservices/axis2/trunk/java/etc/project.properties Tue Dec 27 20:21:10 2005
@@ -93,7 +93,7 @@
 stax.api.version=1.0
 stax.impl.groupid=woodstox
 stax.impl.artifactid=wstx
-stax.impl.version=asl-2.8.1
+stax.impl.version=asl-2.8
 wss4j.version=SNAPSHOT
 xalan.version=2.6.0
 xbean.version=2.1.0
@@ -101,7 +101,9 @@
 xml_apis.version=1.3.02
 XmlSchema.version=SNAPSHOT
 xmlsec.version=1.2.1
-xmlunit.version=1.0
+xmlunit.version=1.0
+ws_policy.version=SNAPSHOT
+
 #for JAM
 annogen.version=0.1.0
 

Modified: webservices/axis2/trunk/java/modules/addressing/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/project.xml?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/project.xml (original)
+++ webservices/axis2/trunk/java/modules/addressing/project.xml Tue Dec 27 20:21:10 2005
@@ -122,6 +122,14 @@
                 <module>true</module>
             </properties>
         </dependency>
+       <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>ws-policy</artifactId>
+            <version>${ws_policy.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
 
     </dependencies>
 

Modified: webservices/axis2/trunk/java/modules/codegen/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/project.xml?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/project.xml (original)
+++ webservices/axis2/trunk/java/modules/codegen/project.xml Tue Dec 27 20:21:10 2005
@@ -152,6 +152,14 @@
                 <module>true</module>
             </properties>
         </dependency>
+	<dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>ws-policy</artifactId>
+            <version>${ws_policy.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
     </dependencies>
 
     <reports/>

Modified: webservices/axis2/trunk/java/modules/core/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/project.xml?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/project.xml (original)
+++ webservices/axis2/trunk/java/modules/core/project.xml Tue Dec 27 20:21:10 2005
@@ -157,6 +157,15 @@
                 <module>true</module>
             </properties>
         </dependency>
+        <!-- Added this to support WS Policy in Axis2 -->
+        <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>ws-policy</artifactId>
+            <version>${ws_policy.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
     </dependencies>
 
     <reports/>

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/Constants.java Tue Dec 27 20:21:10 2005
@@ -153,7 +153,7 @@
     public static final String WSA_ACTION = "wsamapping";
     public static final String VALUE_TRUE = "true";
     public static final String VALUE_FALSE = "false";
-    public static final String TESTING_PATH = "target/test-resources/";
+    public static final String TESTING_PATH = "/home/sanka/axis2-src/java/modules/integration/target/test-resources/";
     public static final String TESTING_REPOSITORY = TESTING_PATH + "samples";
     public static final char SERVICE_NAME_SPLIT_CHAR = ':';
     public static final String SERVICE_GROUP_ID = "ServiceGroupId";

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContextFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContextFactory.java?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContextFactory.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/context/ConfigurationContextFactory.java Tue Dec 27 20:21:10 2005
@@ -59,6 +59,7 @@
     /**
      * To initilizae modules and , create Tranpsorts, this method is bean used
      */
+    
     private void init(ConfigurationContext configContext) throws AxisFault {
         try {
             PhaseResolver phaseResolver = new PhaseResolver(configContext.getAxisConfiguration());

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisConfigBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisConfigBuilder.java?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisConfigBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/AxisConfigBuilder.java Tue Dec 27 20:21:10 2005
@@ -107,6 +107,25 @@
             if (hostElement != null) {
                 processHostCongiguration(hostElement, axisConfiguration);
             }
+            
+            // setting the PolicyInclude
+            PolicyInclude policyInclude = new PolicyInclude();
+            axisConfiguration.setPolicyInclude(policyInclude);
+            
+            // processing <wsp:Policy> .. </..> elements
+            Iterator policyElements = config_element.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));
+            
+            if (policyElements != null) {
+                processPolicyElements(policyElements, axisConfiguration.getPolicyInclude());
+            }
+            
+            // processing <wsp:PolicyReference> .. </..> elements
+            Iterator policyRefElements = config_element.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF));
+            
+            if (policyRefElements != null) {
+                processPolicyRefElements(policyElements, axisConfiguration.getPolicyInclude());
+            }
+            
         } catch (XMLStreamException e) {
             throw new DeploymentException(e);
         }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentConstants.java?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentConstants.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DeploymentConstants.java Tue Dec 27 20:21:10 2005
@@ -91,4 +91,9 @@
     String BOOLEAN_FALSE = "false";
     char SEPARATOR_DOT = '.';
     char SEPARATOR_COLON = ':';
+    
+    String POLICY_NS_URI = "http://schemas.xmlsoap.org/ws/2004/09/policy";
+    String TAG_POLICY = "Policy";
+    String TAG_POLICY_REF = "PolicyReference";
+    
 }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DescriptionBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DescriptionBuilder.java?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DescriptionBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/DescriptionBuilder.java Tue Dec 27 20:21:10 2005
@@ -30,6 +30,10 @@
 import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
 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.wsdl.WSDLConstants;
 
 import javax.xml.namespace.QName;
@@ -371,6 +375,32 @@
 
         return wsamapping;
     }
+    
+    protected void processPolicyElements(Iterator policyElements,
+            PolicyInclude policyInclude) {
+        OMPolicyReader reader = (OMPolicyReader) PolicyFactory
+                .getPolicyReader(PolicyFactory.OM_POLICY_READER);
+        OMElement policyElement;
+
+        while (policyElements.hasNext()) {
+            Policy p = reader.readPolicy((OMElement) policyElements.next());
+            policyInclude.addPolicyElement(p);
+        }
+    }
+
+    protected void processPolicyRefElements(Iterator policyRefElements,
+            PolicyInclude policyInclude) {
+        OMPolicyReader reader = (OMPolicyReader) PolicyFactory
+                .getPolicyReader(PolicyFactory.OM_POLICY_READER);
+        OMElement policyRefElement;
+
+        while (policyRefElements.hasNext()) {
+            PolicyReference policyReference = reader
+                    .readPolicyReference((OMElement) policyRefElements.next());
+            policyInclude.addPolicyRefElement(policyReference);
+        }
+    }
+    
 
     /**
      * This method is used to retrive service name form the arechive file name

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ModuleBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ModuleBuilder.java?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ModuleBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ModuleBuilder.java Tue Dec 27 20:21:10 2005
@@ -23,6 +23,7 @@
 import org.apache.axis2.description.AxisOperationFactory;
 import org.apache.axis2.description.InOnlyAxisOperation;
 import org.apache.axis2.description.ModuleDescription;
+import org.apache.axis2.description.PolicyInclude;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.MessageReceiver;
 import org.apache.axis2.i18n.Messages;
@@ -89,6 +90,32 @@
                 if ((moduleClass != null) && !"".equals(moduleClass)) {
                     loadModuleClass(module, moduleClass);
                 }
+            }
+            
+            // setting the PolicyInclude
+            PolicyInclude policyInclude;
+            
+            if (axisConfig != null) {
+                PolicyInclude parent = axisConfig.getPolicyInclude();
+                policyInclude = new PolicyInclude(parent);
+                
+            } else {
+                policyInclude = new PolicyInclude();
+            }
+            module.setPolicyInclude(policyInclude);
+            
+            // processing <wsp:Policy> .. </..> elements
+            Iterator policyElements = moduleElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));
+            
+            if (policyElements != null) {
+                processPolicyElements(policyElements, module.getPolicyInclude());
+            }
+            
+            // processing <wsp:PolicyReference> .. </..> elements
+            Iterator policyRefElements = moduleElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF));
+            
+            if (policyRefElements != null) {
+                processPolicyRefElements(policyRefElements, module.getPolicyInclude());
             }
 
             // processing Parameters

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/ServiceBuilder.java Tue Dec 27 20:21:10 2005
@@ -25,11 +25,13 @@
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.om.OMAttribute;
 import org.apache.axis2.om.OMElement;
+import org.apache.ws.policy.util.PolicyRegistry;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import java.io.InputStream;
 import java.io.StringWriter;
+import java.security.cert.PolicyNode;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -51,7 +53,7 @@
     public ServiceBuilder(InputStream serviceInputStream, AxisConfiguration axisConfig,
                           AxisService service) {
         super(serviceInputStream, axisConfig);
-        this.service = service;
+        this.service = service;       
     }
 
     /**
@@ -89,6 +91,32 @@
                     service.setServiceDescription(serviceNameatt.getAttributeValue());
                 }
             }
+            
+            // setting the PolicyInclude
+            PolicyInclude policyInclude;
+            
+            if (axisConfig != null) {
+                PolicyInclude parent = axisConfig.getPolicyInclude();
+                policyInclude = new PolicyInclude(parent);
+            
+            } else {
+                policyInclude = new PolicyInclude();
+            }
+            service.setPolicyInclude(policyInclude);
+            
+            // processing <wsp:Policy> .. </..> elements
+            Iterator policyElements = service_element.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));
+            
+            if (policyElements != null) {
+                processPolicyElements(policyElements, service.getPolicyInclude());
+            }
+            
+            // processing <wsp:PolicyReference> .. </..> elements
+            Iterator policyRefElements = service_element.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF));
+            
+            if (policyRefElements != null) {
+                processPolicyRefElements(policyRefElements, service.getPolicyInclude());
+            }
 
             //processin Service Scop
             String sessionScope = service_element.getAttributeValue(new QName(ATTRIBUTE_SCOPE));
@@ -132,6 +160,10 @@
 
             Iterator moduleConfigs = service_element.getChildrenWithName(new QName(TAG_MODULE_CONFIG));
             processServiceModuleConfig(moduleConfigs, service, service);
+            
+            
+            
+            
         } catch (XMLStreamException e) {
             throw new DeploymentException(e);
         } catch (AxisFault axisFault) {
@@ -154,8 +186,29 @@
 
             AxisMessage message = new AxisMessage();
             Iterator parameters = messageElement.getChildrenWithName(new QName(TAG_PARAMETER));
+            
+            // setting the PolicyInclude
+            PolicyInclude parent = operation.getPolicyInclude();
+            PolicyInclude policyInclude = new PolicyInclude(parent);
+            message.setPolicyInclude(policyInclude);
+            
+            // processing <wsp:Policy> .. </..> elements
+            Iterator policyElements = messageElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));
+            
+            if (policyElements != null) {
+                processPolicyElements(policyElements, message.getPolicyInclude());
+            }
+            
+            // processing <wsp:PolicyReference> .. </..> elements
+            Iterator policyRefElements = messageElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF));
+            
+            if (policyRefElements != null) {
+                processPolicyRefElements(policyRefElements, message.getPolicyInclude());
+            }
 
             processParameters(parameters, message, operation);
+            
+            
             operation.addMessage(message, lable.getAttributeValue().trim());
         }
     }
@@ -246,7 +299,34 @@
                 }
                 op_descrip.setName(new QName(opname));
             }
-
+            
+            // setting the PolicyInclude
+            PolicyInclude policyInclude;
+            
+            if (service != null) {
+                PolicyInclude parent = service.getPolicyInclude();
+                policyInclude = new PolicyInclude(parent);
+                
+            } else {
+                policyInclude = new PolicyInclude();
+            }
+            
+            op_descrip.setPolicyInclude(policyInclude);
+            
+            // processing <wsp:Policy> .. </..> elements
+            Iterator policyElements = operation.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY));
+            
+            if (policyElements != null) {
+                processPolicyElements(policyElements, op_descrip.getPolicyInclude());
+            }
+            
+            // processing <wsp:PolicyReference> .. </..> elements
+            Iterator policyRefElements = operation.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF));
+            
+            if (policyRefElements != null) {
+                processPolicyRefElements(policyRefElements, op_descrip.getPolicyInclude());
+            }
+            
             // Operation Parameters
             Iterator parameters = operation.getChildrenWithName(new QName(TAG_PARAMETER));
             ArrayList wsamappings = processParameters(parameters, op_descrip, service);
@@ -287,7 +367,7 @@
             Iterator moduleConfigs = operation.getChildrenWithName(new QName(TAG_MODULE_CONFIG));
 
             processOperationModuleConfig(moduleConfigs, op_descrip, op_descrip);
-
+            
             // adding the operation
             operations.add(op_descrip);
         }
@@ -315,5 +395,6 @@
                 service.addModuleConfig(moduleConfiguration);
             }
         }
-    }
+    }    
+  
 }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java Tue Dec 27 20:21:10 2005
@@ -36,6 +36,8 @@
     //to keep data in WSDL message refference and to keep the Java2WSDL data
     // such as SchemaElementName , direction etc.
     private MessageReference messageReference;
+    
+    private PolicyInclude policyInclude;
 
     public AxisMessage() {
         parameterinclude = new ParameterIncludeImpl();
@@ -115,5 +117,13 @@
 
     public void setElementQName(QName element) {
         messageReference.setElementQName(element);
+    }
+    
+    public void setPolicyInclude(PolicyInclude policyInclude) {
+        this.policyInclude = policyInclude;
+    }
+    
+    public PolicyInclude getPolicyInclude() {
+        return policyInclude;
     }
 }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisOperation.java Tue Dec 27 20:21:10 2005
@@ -53,6 +53,9 @@
 
     private AxisService parent;
     private ArrayList wsamappingList;
+    
+    // to store policies which are valid for entire operation
+    private PolicyInclude policyInclude;
 
     public AxisOperation() {
         mepURI = MEP_URI_IN_OUT;
@@ -417,5 +420,13 @@
      */
     public OperationClient createClient (ServiceContext sc, Options options){
         throw new UnsupportedOperationException ("The MEP you are using (" + mepURI + ") has not implemented createClient().");
+    }
+    
+    public void setPolicyInclude(PolicyInclude policyInclude) {
+        this.policyInclude = policyInclude;
+    }
+    
+    public PolicyInclude getPolicyInclude() {
+        return policyInclude;
     }
 }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisService.java Tue Dec 27 20:21:10 2005
@@ -24,6 +24,7 @@
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.MessageReceiver;
 import org.apache.axis2.om.OMElement;
+import org.apache.axis2.util.PolicyUtil;
 import org.apache.axis2.wsdl.writer.WOMWriter;
 import org.apache.axis2.wsdl.writer.WOMWriterFactory;
 import org.apache.commons.logging.Log;
@@ -82,6 +83,9 @@
 
     //to store default message receivers
     private HashMap messageReceivers;
+    
+    // to store policies which are valid for the entire service
+    private PolicyInclude policyInclude;
 
     /**
      * Constructor AxisService
@@ -344,6 +348,10 @@
         AxisService2WOM axisService2WOM = new AxisService2WOM(getSchema(), this, null, null, serviceURL);
         try {
             WSDLDescription desc = axisService2WOM.generateWOM();
+            
+            // populate it with policy information ..
+            PolicyUtil.populatePolicy(desc, this);
+            
             WOMWriter womWriter = WOMWriterFactory.createWriter(org.apache.wsdl.WSDLConstants.WSDL_1_1);
             womWriter.setdefaultWSDLPrefix("wsdl");
             womWriter.writeWOM(desc, out);
@@ -632,5 +640,13 @@
                 Constants.SCOPE_REQUEST.equals(scope)) {
             this.scope = scope;
         }
+    }
+    
+    public void setPolicyInclude(PolicyInclude policyInclude) {
+        this.policyInclude = policyInclude;
+    }
+    
+    public PolicyInclude getPolicyInclude() {
+        return policyInclude;
     }
 }

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ModuleDescription.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ModuleDescription.java?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ModuleDescription.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/ModuleDescription.java Tue Dec 27 20:21:10 2005
@@ -57,6 +57,11 @@
     // to store module operations , which are suppose to be added to a service if it is engaged to a service
     private HashMap operations;
     private AxisConfiguration parent;
+    
+    /*
+     * to store policies which are falid for any service for which the module is
+     */ 
+    private PolicyInclude policyInclude;
 
     /**
      * Constructor ModuleDescription
@@ -228,5 +233,13 @@
 
     public void setParent(AxisConfiguration parent) {
         this.parent = parent;
+    }
+    
+    public void setPolicyInclude(PolicyInclude policyInclude) {
+        this.policyInclude = policyInclude;
+    }
+    
+    public PolicyInclude getPolicyInclude() {
+        return policyInclude;
     }
 }

Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/PolicyInclude.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/PolicyInclude.java?rev=359387&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/PolicyInclude.java (added)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/PolicyInclude.java Tue Dec 27 20:21:10 2005
@@ -0,0 +1,117 @@
+/*
+ * 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.description;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.apache.ws.policy.Policy;
+import org.apache.ws.policy.PolicyReference;
+import org.apache.ws.policy.util.PolicyRegistry;
+
+/**
+ * @author Sanka Samaranayake (sanka@apache.org)
+ */
+public class PolicyInclude {
+
+    private Policy policy = null;
+    private Policy effectivePolicy = null;
+    
+    private PolicyInclude parent = null;
+    private PolicyRegistry reg;
+
+    private ArrayList policyElements = new ArrayList();
+
+    public PolicyInclude() {
+        reg = new PolicyRegistry();
+    }
+
+    public PolicyInclude(PolicyInclude parent) {
+        reg = new PolicyRegistry(parent.getPolicyRegistry());
+    }
+
+    public void setPolicyRegistry(PolicyRegistry reg) {
+        this.reg = reg;
+    }
+    
+    public PolicyRegistry getPolicyRegistry() {
+        return reg;
+    }
+    
+    public void setPolicy(Policy policy) {
+        this.policy = policy;
+    }
+
+    public Policy getPolicy() {
+
+        if (policy == null) {
+            Iterator iterator = policyElements.iterator();
+
+            while (iterator.hasNext()) {
+                Object policyElement = iterator.next();
+                Policy p = null;
+
+                if (policyElement instanceof PolicyReference) {
+                    p = (Policy) ((PolicyReference) policyElement)
+                            .normalize(getPolicyRegistry());
+
+                } else if (policyElement instanceof Policy) {
+                    p = (Policy) iterator.next();
+
+                } else {
+                    // TODO an exception ?
+                }
+                policy = (policy == null) ? p : (Policy) policy.merge(p, reg);
+            }
+        }
+        return policy;
+    }
+
+    public Policy getEffectivePolicy() {
+
+        if (parent == null || parent.getEffectivePolicy() == null) {
+            return getPolicy();
+        }
+        
+        if (getPolicy() != null) {
+            return parent.getEffectivePolicy();
+        }
+        
+        return (Policy) parent.getEffectivePolicy().merge(getPolicy(), reg);
+
+    }
+    
+    public void setPolicyElements(ArrayList policyElements) {
+        this.policyElements = policyElements;
+    }
+    
+    public ArrayList getPolicyElements() {
+        return policyElements;
+    }
+
+    public void addPolicyElement(Policy policyElement) {
+        if (policyElement.getPolicyURI() != null) {
+            reg.register(policyElement.getPolicyURI(), policyElement);
+        }
+        
+        policyElements.add(policyElement);
+    }
+
+    public void addPolicyRefElement(PolicyReference policyRefElement) {
+        policyElements.add(policyRefElement);
+    }
+}

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfiguration.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfiguration.java?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfiguration.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/engine/AxisConfiguration.java Tue Dec 27 20:21:10 2005
@@ -69,6 +69,9 @@
     private ArrayList inFaultPhases;
     private ArrayList inPhasesUptoAndIncludingPostDispatch;
     private HashMap messageReceivers;
+    
+    // to store policies which are valid for entire system
+    private PolicyInclude policyInclude;
 
     private ClassLoader moduleClassLoader;
     private HashMap moduleConfigmap;
@@ -94,6 +97,9 @@
         faultyModules = new Hashtable();
         observersList = new ArrayList();
         inPhasesUptoAndIncludingPostDispatch = new ArrayList();
+        
+        policyInclude = new PolicyInclude();
+        
         systemClassLoader = Thread.currentThread().getContextClassLoader();
         serviceClassLoader = Thread.currentThread().getContextClassLoader();
         moduleClassLoader = Thread.currentThread().getContextClassLoader();
@@ -554,6 +560,14 @@
 
     public void setSystemClassLoader(ClassLoader classLoader) {
         this.systemClassLoader = classLoader;
+    }
+    
+    public void setPolicyInclude(PolicyInclude policyInclude) {
+        this.policyInclude = policyInclude;
+    }
+    
+    public PolicyInclude getPolicyInclude() {
+        return policyInclude;
     }
     
     public static String getAxis2HomeDirectory() {

Added: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/PolicyUtil.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/PolicyUtil.java?rev=359387&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/PolicyUtil.java (added)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/PolicyUtil.java Tue Dec 27 20:21:10 2005
@@ -0,0 +1,126 @@
+/*
+ * 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.util;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.description.AxisMessage;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.ws.policy.Policy;
+import org.apache.wsdl.Component;
+import org.apache.wsdl.WSDLBinding;
+import org.apache.wsdl.WSDLBindingMessageReference;
+import org.apache.wsdl.WSDLBindingOperation;
+import org.apache.wsdl.WSDLConstants;
+import org.apache.wsdl.WSDLDescription;
+import org.apache.wsdl.WSDLEndpoint;
+import org.apache.wsdl.WSDLExtensibilityElement;
+import org.apache.wsdl.WSDLService;
+import org.apache.wsdl.extensions.ExtensionConstants;
+import org.apache.wsdl.extensions.impl.ExtensionFactoryImpl;
+import org.apache.wsdl.impl.WSDLProcessingException;
+
+/**
+ * @author Sanka Samaranayake (sanka@apache.org)
+ */
+public class PolicyUtil {
+    public static void populatePolicy(WSDLDescription description,
+            AxisService axisService) {
+        WSDLService wsdlService = description.getService(new QName(axisService
+                .getName()));
+        populatePolicy(wsdlService, axisService);
+    }
+
+    public static void populatePolicy(WSDLService wsdlService,
+            AxisService axisService) {
+        Policy servicePolicy = axisService.getPolicyInclude().getPolicy();
+
+        if (servicePolicy != null) {
+            addPolicyToComponent(servicePolicy, wsdlService);
+        }
+
+        // TODO CHECK ME //////////////////////////////////
+
+        Iterator wsdlEndpoints = wsdlService.getEndpoints().values().iterator();
+        if (!wsdlEndpoints.hasNext()) {
+            throw new WSDLProcessingException("should at least one endpoints");
+        }
+
+        WSDLEndpoint wsdlEndpoint = (WSDLEndpoint) wsdlEndpoints.next();
+        WSDLBinding wsdlBinding = wsdlEndpoint.getBinding();
+
+        ////////////////////////////////////////////////////
+
+        Iterator wsdlOperations = wsdlBinding.getBindingOperations().values()
+                .iterator();
+        WSDLBindingOperation wsdlBindingOperation;
+
+        while (wsdlOperations.hasNext()) {
+            wsdlBindingOperation = (WSDLBindingOperation) wsdlOperations.next();
+            populatePolicy(wsdlBindingOperation, axisService
+                    .getOperation(wsdlBindingOperation.getName()));
+        }
+
+    }
+
+    private static void populatePolicy(
+            WSDLBindingOperation wsdlBindingOperation,
+            AxisOperation axisOperation) {
+        Policy operationPolicy = axisOperation.getPolicyInclude().getPolicy();
+
+        if (operationPolicy != null) {
+            addPolicyToComponent(operationPolicy, wsdlBindingOperation);
+        }
+
+        if (WSDLConstants.MEP_URI_IN_ONLY.equals(axisOperation
+                .getMessageExchangePattern())) {
+            populatePolicy(wsdlBindingOperation.getInput(), axisOperation
+                    .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
+
+        } else if (WSDLConstants.MEP_URI_IN_OUT.equals(axisOperation
+                .getMessageExchangePattern())) {
+            populatePolicy(wsdlBindingOperation.getInput(), axisOperation
+                    .getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
+            populatePolicy(wsdlBindingOperation.getOutput(), axisOperation
+                    .getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE));
+        }
+    }
+
+    private static void populatePolicy(
+            WSDLBindingMessageReference wsdlBindingMsgReference,
+            AxisMessage axisMessage) {
+        Policy messagePolicy = axisMessage.getPolicyInclude().getPolicy();
+
+        if (messagePolicy != null) {
+            addPolicyToComponent(messagePolicy, wsdlBindingMsgReference);
+        }
+    }
+
+    private static void addPolicyToComponent(Policy policy, Component component) {
+        component.addExtensibilityElement(getExtensibilityElement(policy));
+    }
+
+    private static WSDLExtensibilityElement getExtensibilityElement(
+            Policy policy) {
+        WSDLExtensibilityElement element = (new ExtensionFactoryImpl())
+                .getExtensionElement(ExtensionConstants.POLICY);
+        return element;
+    }
+}

Modified: webservices/axis2/trunk/java/modules/integration/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/project.xml?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/project.xml (original)
+++ webservices/axis2/trunk/java/modules/integration/project.xml Tue Dec 27 20:21:10 2005
@@ -279,6 +279,14 @@
             <artifactId>XmlSchema</artifactId>
             <version>${XmlSchema.version}</version>
         </dependency>
+        <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>ws-policy</artifactId>
+            <version>${ws_policy.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
 
     </dependencies>
 

Modified: webservices/axis2/trunk/java/modules/wsdl/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/project.xml?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/project.xml (original)
+++ webservices/axis2/trunk/java/modules/wsdl/project.xml Tue Dec 27 20:21:10 2005
@@ -118,6 +118,15 @@
                 <module>true</module>
             </properties>
         </dependency>
+        <!-- Added this to support WS Policy in Axis2 -->
+        <dependency>
+            <groupId>ws-commons</groupId>
+            <artifactId>ws-policy</artifactId>
+            <version>${ws_policy.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
     </dependencies>
 	<!-- add the build properties-->
 	<build>

Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/ExtensionConstants.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/ExtensionConstants.java?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/ExtensionConstants.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/ExtensionConstants.java Tue Dec 27 20:21:10 2005
@@ -51,5 +51,8 @@
             "http://schemas.xmlsoap.org/wsdl/soap/", "binding");
      public static final QName SOAP_12_BINDING = new QName(
             "http://schemas.xmlsoap.org/wsdl/soap12/", "binding");
+     
+     public static final QName POLICY = new QName(
+             "http://schemas.xmlsoap.org/ws/2004/09/policy", "Policy");
 
 }

Added: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/PolicyExtensibilityElement.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/PolicyExtensibilityElement.java?rev=359387&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/PolicyExtensibilityElement.java (added)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/PolicyExtensibilityElement.java Tue Dec 27 20:21:10 2005
@@ -0,0 +1,30 @@
+/*
+ * 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.wsdl.extensions;
+
+import org.apache.ws.policy.Policy;
+import org.apache.wsdl.WSDLExtensibilityElement;
+
+/**
+ * @author Sanka Samaranayake (sanka@apache.org)
+ */
+public interface PolicyExtensibilityElement extends WSDLExtensibilityElement {
+    
+    public void setPolicy(Policy policy);
+    
+    public Policy getPolicy();
+}

Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/ExtensionFactoryImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/ExtensionFactoryImpl.java?rev=359387&r1=359386&r2=359387&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/ExtensionFactoryImpl.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/ExtensionFactoryImpl.java Tue Dec 27 20:21:10 2005
@@ -55,6 +55,9 @@
             return new SOAPHeadeImpl(SOAP_12_HEADER);
         if (SOAP_12_ADDRESS.equals(qName))
             return new SOAPAddressImpl();
+        if (POLICY.equals(qName)) {
+            return new PolicyExtensitbilityElementImpl();
+        }
         return new DefaultExtensibilityElementImpl();
     }
 

Added: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/PolicyExtensitbilityElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/PolicyExtensitbilityElementImpl.java?rev=359387&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/PolicyExtensitbilityElementImpl.java (added)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/wsdl/extensions/impl/PolicyExtensitbilityElementImpl.java Tue Dec 27 20:21:10 2005
@@ -0,0 +1,43 @@
+/*
+ * 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.wsdl.extensions.impl;
+
+import org.apache.ws.policy.Policy;
+import org.apache.wsdl.extensions.PolicyExtensibilityElement;
+import org.apache.wsdl.impl.WSDLExtensibilityElementImpl;
+
+/**
+ * @author Sanka Samaranayake (sanka@apache.org)
+ */
+public class PolicyExtensitbilityElementImpl extends WSDLExtensibilityElementImpl implements PolicyExtensibilityElement {
+    private Policy policy;
+    
+    public PolicyExtensitbilityElementImpl() {
+    }
+    
+    public PolicyExtensitbilityElementImpl(Policy policy) {
+        setPolicy(policy);
+    }
+    
+    public void setPolicy(Policy policy) {
+        this.policy = policy;
+    }
+    
+    public Policy getPolicy() {
+        return policy;
+    }
+}