You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by an...@apache.org on 2007/02/15 10:36:44 UTC

svn commit: r507867 [1/2] - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/phase/ api/src/main/java/org/apache/cxf/ws/policy/ api/src/main/java/org/apache/cxf/ws/policy/builders/primitive/ api/src/main/java/org/apache/cxf/ws/policy/builders/...

Author: andreasmyth
Date: Thu Feb 15 01:36:42 2007
New Revision: 507867

URL: http://svn.apache.org/viewvc?view=rev&rev=507867
Log:
[JIRA CXF-380, CXF-378] Interceptors to dynamically install further interceptors as required by a message's or fault's policy - on server side and client side.
These interceptors themselves can be auto-installed as bus interceptors if property "registerInterceptors" in bus extension PoliyEngine is set to true (default: false).
Added a new outbound phase "SETUP" (to which the outbound versions of the above interceptors belong).

Added:
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientRequestPolicyInfo.java   (with props)
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyInfo.java   (with props)
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java   (with props)
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java   (with props)
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java   (with props)
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerResponsePolicyInfo.java   (with props)
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java   (with props)
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/references/
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/references/ReferenceResolver.java   (with props)
Removed:
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInfo.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/AssertingConduit.java
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/Phase.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyConstants.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builders/primitive/NestedPrimitiveAssertion.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builders/primitive/PrimitiveAssertion.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builders/xml/XmlPrimitiveAssertion.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/policy/AddressingAssertionBuilder.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyOutInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/Messages.properties
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/ClientPolicyInfoTest.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/GreeterImpl.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/Phase.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/Phase.java?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/Phase.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/Phase.java Thu Feb 15 01:36:42 2007
@@ -22,8 +22,8 @@
 public class Phase implements Comparable {
     
     // can be removed from once defined as default value in configuration metadata for bus
-
-    public static final String POST_INVOKE = "post-invoke";
+  
+    public static final String SETUP = "setup";
     public static final String PRE_LOGICAL = "pre-logical";
     public static final String USER_LOGICAL = "user-logical";
     public static final String POST_LOGICAL = "post-logical";
@@ -44,6 +44,7 @@
     public static final String UNMARSHAL = "unmarshal";
     public static final String PRE_INVOKE = "pre-invoke";
     public static final String INVOKE = "invoke";
+    public static final String POST_INVOKE = "post-invoke";
     
     
     private String name;

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyConstants.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyConstants.java?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyConstants.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyConstants.java Thu Feb 15 01:36:42 2007
@@ -26,24 +26,37 @@
  */
 public final class PolicyConstants {
     
-    private static final String NAMESPACE_URI = 
+    public static final String NAMESPACE_URI = 
         "http://schemas.xmlsoap.org/ws/2004/09/policy";
     
-    private static final String POLICY_ELEM_NAME = "Policy";
+    public static final String POLICY_ELEM_NAME = "Policy";
     
-    private static final String POLICYREF_ELEM_NAME = "PolicyReference";
+    public static final String POLICYREF_ELEM_NAME = "PolicyReference";
     
-    private static final String OPTIONAL_ATTR_NAME = "Optional";
+    public static final String OPTIONAL_ATTR_NAME = "Optional"; 
     
-    private static final QName POLICY_ELEM_QNAME = 
+    public static final QName POLICY_ELEM_QNAME = 
         new QName(NAMESPACE_URI, POLICY_ELEM_NAME);
     
-    private static final QName POLICYREF_QNAME = 
+    public static final QName POLICYREF_ELEM_QNAME = 
         new QName(NAMESPACE_URI, POLICYREF_ELEM_NAME);
     
-    private static final QName OPTIONAL_ATTR_QNAME = 
+    public static final QName OPTIONAL_ATTR_QNAME = 
         new QName(NAMESPACE_URI, OPTIONAL_ATTR_NAME);
     
+    public static final String CLIENT_POLICY_OUT_INTERCEPTOR_ID
+        = "org.apache.cxf.ws.policy.ClientPolicyOutInterceptor";
+    public static final String CLIENT_POLICY_IN_INTERCEPTOR_ID
+        = "org.apache.cxf.ws.policy.ClientPolicyInInterceptor";
+    public static final String CLIENT_POLICY_IN_FAULT_INTERCEPTOR_ID
+        = "org.apache.cxf.ws.policy.ClientPolicyInFaultInterceptor";
+    
+    public static final String SERVER_POLICY_IN_INTERCEPTOR_ID
+        = "org.apache.cxf.ws.policy.ServerPolicyInInterceptor";
+    public static final String SERVER_POLICY_OUT_INTERCEPTOR_ID
+        = "org.apache.cxf.ws.policy.ServerPolicyOutInterceptor";
+    public static final String SERVER_POLICY_OUT_FAULT_INTERCEPTOR_ID
+        = "org.apache.cxf.ws.policy.ServerPolicyOutFaultInterceptor";
     
     /**
      * Prevents instantiation.
@@ -51,44 +64,5 @@
     
     private PolicyConstants() {
     }
-    
-    /**
-     * @return namespace defined by the WS-Policy schema
-     */
-    public static String getNamespaceURI() {
-        return NAMESPACE_URI;
-    }
-    
-    /**
-     * @return the QName of the Policy element
-     */
-    public static QName getPolicyElementQName() {
-        return POLICY_ELEM_QNAME;
-    }
-    
-    public static String getPolicyElementLocalName() {
-        return POLICY_ELEM_NAME;
-    }
-    
-    /**
-     * @return the QName of the PolicyReference element
-     */
-    public static QName getPolicyReferenceElementQName() {
-        return POLICYREF_QNAME;
-    }
-    
-    public static String getPolicyReferenceElementLocalName() {
-        return POLICYREF_ELEM_NAME;
-    }
-    
-    public static QName getOptionalAttributeQName() {
-        return OPTIONAL_ATTR_QNAME;
-    }
-    
-    public static String getOptionalAttrLocalName() {
-        return OPTIONAL_ATTR_NAME;
-    }
-    
-    
     
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builders/primitive/NestedPrimitiveAssertion.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builders/primitive/NestedPrimitiveAssertion.java?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builders/primitive/NestedPrimitiveAssertion.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builders/primitive/NestedPrimitiveAssertion.java Thu Feb 15 01:36:42 2007
@@ -63,18 +63,18 @@
         for (Node nd = elem.getFirstChild(); nd != null; nd = nd.getNextSibling()) {
             if (Node.ELEMENT_NODE == nd.getNodeType()) {
                 QName qn = new QName(nd.getNamespaceURI(), nd.getLocalName());
-                if (PolicyConstants.getPolicyElementQName().equals(qn)
+                if (PolicyConstants.POLICY_ELEM_QNAME.equals(qn)
                     && null == policyElem) {
                     policyElem = (Element)nd;
                 } else {
                     throw new PolicyException(new Message("UNEXPECTED_CHILD_ELEMENT_EXC", BUNDLE, 
-                                                          PolicyConstants.getPolicyElementQName()));
+                                                          PolicyConstants.POLICY_ELEM_QNAME));
                 }                
             }
         }
         if (null == policyElem) {
             throw new PolicyException(new Message("UNEXPECTED_CHILD_ELEMENT_EXC", BUNDLE, 
-                                                  PolicyConstants.getPolicyElementQName()));
+                                                  PolicyConstants.POLICY_ELEM_QNAME));
         }
         
         nested = builder.getPolicy(policyElem);  

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builders/primitive/PrimitiveAssertion.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builders/primitive/PrimitiveAssertion.java?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builders/primitive/PrimitiveAssertion.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builders/primitive/PrimitiveAssertion.java Thu Feb 15 01:36:42 2007
@@ -57,8 +57,8 @@
     
     public PrimitiveAssertion(Element element) {
         name = new QName(element.getNamespaceURI(), element.getLocalName());
-        Attr attribute = element.getAttributeNodeNS(PolicyConstants.getNamespaceURI(), 
-                                              PolicyConstants.getOptionalAttrLocalName());
+        Attr attribute = element.getAttributeNodeNS(PolicyConstants.NAMESPACE_URI, 
+                                              PolicyConstants.OPTIONAL_ATTR_NAME);
         if (attribute != null) {
             optional = Boolean.valueOf(attribute.getValue());
         }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builders/xml/XmlPrimitiveAssertion.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builders/xml/XmlPrimitiveAssertion.java?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builders/xml/XmlPrimitiveAssertion.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builders/xml/XmlPrimitiveAssertion.java Thu Feb 15 01:36:42 2007
@@ -67,8 +67,8 @@
     protected Assertion cloneMandatory() {
         Element e = (Element)element.cloneNode(true);
         if (isOptional()) {
-            e.removeAttributeNode(e.getAttributeNodeNS(PolicyConstants.getNamespaceURI(), 
-                                                   PolicyConstants.getOptionalAttrLocalName()));
+            e.removeAttributeNode(e.getAttributeNodeNS(PolicyConstants.NAMESPACE_URI, 
+                                                   PolicyConstants.OPTIONAL_ATTR_NAME));
         }
         return new XmlPrimitiveAssertion(e);        
     }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/phase/PhaseManagerImpl.java Thu Feb 15 01:36:42 2007
@@ -93,6 +93,7 @@
         outPhases = new ArrayList<Phase>();
         int i = 0;
         
+        outPhases.add(new Phase(Phase.SETUP, ++i * 1000));
         outPhases.add(new Phase(Phase.PRE_LOGICAL, ++i * 1000));
         outPhases.add(new Phase(Phase.USER_LOGICAL, ++i * 1000));
         outPhases.add(new Phase(Phase.POST_LOGICAL, ++i * 1000));

Modified: incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/policy/AddressingAssertionBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/policy/AddressingAssertionBuilder.java?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/policy/AddressingAssertionBuilder.java (original)
+++ incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/policy/AddressingAssertionBuilder.java Thu Feb 15 01:36:42 2007
@@ -60,8 +60,8 @@
         System.out.println("Using AddressingAssertionBuilder to build assertion for " + n);
         
         boolean optional = false;
-        Attr attribute = elem.getAttributeNodeNS(PolicyConstants.getNamespaceURI(), 
-                                              PolicyConstants.getOptionalAttrLocalName());
+        Attr attribute = elem.getAttributeNodeNS(PolicyConstants.NAMESPACE_URI, 
+                                              PolicyConstants.OPTIONAL_ATTR_NAME);
         if (attribute != null) {
             optional = Boolean.valueOf(attribute.getValue());
         }

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java Thu Feb 15 01:36:42 2007
@@ -26,7 +26,6 @@
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
-import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.Conduit;
 
@@ -38,7 +37,8 @@
     private Bus bus;
     
     public ClientPolicyInFaultInterceptor() {
-        setPhase(Phase.PRE_LOGICAL);
+        setId(PolicyConstants.CLIENT_POLICY_IN_FAULT_INTERCEPTOR_ID);
+        setPhase(Phase.RECEIVE);
     }
         
     public void setBus(Bus b) {
@@ -54,11 +54,6 @@
             return;
         }
         
-        BindingOperationInfo boi = msg.get(BindingOperationInfo.class);
-        if (null == boi) {
-            return;
-        }
-        
         EndpointInfo ei = msg.get(EndpointInfo.class);
         if (null == ei) {
             return;
@@ -74,15 +69,9 @@
         // We do not know the underlying message type yet - so we pre-emptively add interceptors 
         // that can deal with the response and all of the operation's possible fault messages.
         
-        List<Interceptor> policyInFaultInterceptors = pe.getClientInFaultInterceptors(boi, ei, conduit);
+        List<Interceptor> policyInFaultInterceptors = pe.getClientInFaultInterceptors(ei, conduit);
         for (Interceptor poi : policyInFaultInterceptors) {
             msg.getInterceptorChain().add(poi);
         }
-        
-        // TODO:
-        // In addition we add an interceptor that towards the end of the chain determines the
-        // effective policy of the underlying message and checks if any of its alternatives are
-        // supported.
-        
     }
 }

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInInterceptor.java?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInInterceptor.java Thu Feb 15 01:36:42 2007
@@ -26,7 +26,6 @@
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
-import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.Conduit;
 
@@ -38,7 +37,8 @@
     private Bus bus;
     
     public ClientPolicyInInterceptor() {
-        setPhase(Phase.PRE_LOGICAL);
+        setId(PolicyConstants.CLIENT_POLICY_IN_INTERCEPTOR_ID);
+        setPhase(Phase.RECEIVE);
     }
         
     public void setBus(Bus b) {
@@ -54,11 +54,6 @@
             return;
         }
         
-        BindingOperationInfo boi = msg.get(BindingOperationInfo.class);
-        if (null == boi) {
-            return;
-        }
-        
         EndpointInfo ei = msg.get(EndpointInfo.class);
         if (null == ei) {
             return;
@@ -74,15 +69,10 @@
         // We do not know the underlying message type yet - so we pre-emptively add interceptors 
         // that can deal with the response and all of the operation's possible fault messages.
         
-        List<Interceptor> policyInInterceptors = pe.getClientInInterceptors(boi, ei, conduit);
+        List<Interceptor> policyInInterceptors = pe.getClientInInterceptors(ei, conduit);
         for (Interceptor poi : policyInInterceptors) {
             msg.getInterceptorChain().add(poi);
         }
-        
-        // TODO:
-        // In addition we add an interceptor that towards the end of the chain determines the
-        // effective policy of the underlying message and checks if any of its alternatives are
-        // supported..
         
     }
 }

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyOutInterceptor.java?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyOutInterceptor.java Thu Feb 15 01:36:42 2007
@@ -38,7 +38,8 @@
     private Bus bus;
     
     public ClientPolicyOutInterceptor() {
-        setPhase(Phase.PRE_LOGICAL);
+        setId(PolicyConstants.CLIENT_POLICY_OUT_INTERCEPTOR_ID);
+        setPhase(Phase.SETUP);
     }
     
     public void setBus(Bus b) {
@@ -71,8 +72,6 @@
         
         Conduit conduit = msg.getConduit();
         
-        // add the interceptors required to satisfy the policies
-        // for this operation
         List<Interceptor> policyOutInterceptors = pe.getClientOutInterceptors(boi, ei, conduit);
         for (Interceptor poi : policyOutInterceptors) {
             msg.getInterceptorChain().add(poi);

Added: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientRequestPolicyInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientRequestPolicyInfo.java?view=auto&rev=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientRequestPolicyInfo.java (added)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientRequestPolicyInfo.java Thu Feb 15 01:36:42 2007
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.ws.policy;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.service.model.BindingMessageInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
+
+/**
+ * 
+ */
+public class ClientRequestPolicyInfo  {
+    
+    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(ClientRequestPolicyInfo.class);
+    
+    private Policy requestPolicy;     
+    private List<Assertion> chosenAlternative;
+    private List<Interceptor> outInterceptors;
+    
+    void initialise(BindingOperationInfo boi, EndpointInfo ei, PolicyEngine engine, Assertor assertor) {
+        initialiseRequestPolicy(boi, ei, engine);
+        chooseAlternative(engine, assertor);
+        initialiseInterceptors(engine);  
+    }
+   
+    public Policy getRequestPolicy() {
+        return requestPolicy;        
+    }
+    
+    public List<Interceptor> getOutInterceptors() {
+        return outInterceptors;
+    }
+    
+    public List<Assertion> getChosenAlternative() {
+        return chosenAlternative;
+    }
+    
+    
+    
+    void initialiseRequestPolicy(BindingOperationInfo boi, EndpointInfo ei, PolicyEngine engine) {
+        BindingMessageInfo bmi = boi.getInput();
+
+        requestPolicy = engine.getAggregatedMessagePolicy(bmi);
+        requestPolicy = requestPolicy.merge(engine.getAggregatedOperationPolicy(boi));
+        requestPolicy = requestPolicy.merge(engine.getAggregatedEndpointPolicy(ei));
+        requestPolicy = requestPolicy.merge(engine.getAggregatedServicePolicy(ei.getService()));
+        requestPolicy = (Policy)requestPolicy.normalize(true);
+    }
+
+    void chooseAlternative(PolicyEngine engine, Assertor assertor) {
+        Iterator alternatives = requestPolicy.getAlternatives();
+        while (alternatives.hasNext()) {
+            List<Assertion> alternative = CastUtils.cast((List)alternatives.next(), Assertion.class);
+            if (engine.supportsAlternative(alternative, assertor)) {
+                setChosenAlternative(alternative);
+                return;
+            }
+        }
+        throw new PolicyException(new Message("CLIENT_OUT_NO_ALTERNATIVE_EXC", BUNDLE));
+
+    }
+
+    void initialiseInterceptors(PolicyEngine engine) {
+        PolicyInterceptorProviderRegistry reg 
+            = engine.getBus().getExtension(PolicyInterceptorProviderRegistry.class);
+        List<Interceptor> out = new ArrayList<Interceptor>();
+        for (Assertion a : getChosenAlternative()) {
+            if (a.isOptional()) {
+                continue;
+            }
+            QName qn = a.getName();
+            PolicyInterceptorProvider pp = reg.get(qn);
+            if (null != pp) {
+                out.addAll(pp.getOutInterceptors());
+            }
+        }
+        setOutInterceptors(out);
+    }
+    
+    // for tests
+    
+    void setRequestPolicy(Policy ep) {
+        requestPolicy = ep;
+    }
+    
+    void setChosenAlternative(List<Assertion> c) {
+        chosenAlternative = c;
+    }
+    
+    void setOutInterceptors(List<Interceptor> out) {
+        outInterceptors = out;
+    }
+   
+}

Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientRequestPolicyInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientRequestPolicyInfo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyInfo.java?view=auto&rev=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyInfo.java (added)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyInfo.java Thu Feb 15 01:36:42 2007
@@ -0,0 +1,188 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.ws.policy;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.service.model.BindingFaultInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
+
+/**
+ * 
+ */
+public class EndpointPolicyInfo {
+    
+    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(EndpointPolicyInfo.class);
+    
+    private Policy policy;
+    private List<Assertion> chosenAlternative;
+    private List<Interceptor> inInterceptors;
+    private List<Interceptor> inFaultInterceptors;
+    
+    void initialise(EndpointInfo ei, boolean isServer, PolicyEngine engine, Assertor assertor) {
+        initialisePolicy(ei, engine);
+        chooseAlternative(engine, assertor);
+        initialiseInterceptors(ei, isServer, engine);  
+    }
+   
+    public Policy getPolicy() {
+        return policy;        
+    }
+    
+    public List<Assertion> getChosenAlternative() {
+        return chosenAlternative;
+    }
+    
+    public List<Interceptor> getInInterceptors() {
+        return inInterceptors;
+    }
+    
+    public List<Interceptor> getInFaultInterceptors() {
+        return inFaultInterceptors;
+    }
+      
+    void initialisePolicy(EndpointInfo ei, PolicyEngine engine) {
+        policy = engine.getAggregatedServicePolicy(ei.getService());
+        policy = policy.merge(engine.getAggregatedEndpointPolicy(ei));
+        policy = (Policy)policy.normalize(true);
+    }
+
+    void chooseAlternative(PolicyEngine engine, Assertor assertor) {
+        Iterator alternatives = policy.getAlternatives();
+        while (alternatives.hasNext()) {
+            List<Assertion> alternative = CastUtils.cast((List)alternatives.next(), Assertion.class);
+            if (engine.supportsAlternative(alternative, assertor)) {
+                setChosenAlternative(alternative);
+                return;
+            }
+        }
+        throw new PolicyException(new Message("NO_ALTERNATIVE_EXC", BUNDLE));
+    }
+
+    void initialiseInterceptors(EndpointInfo ei, boolean isServer, PolicyEngine engine) {
+        PolicyInterceptorProviderRegistry reg 
+            = engine.getBus().getExtension(PolicyInterceptorProviderRegistry.class);
+        inInterceptors = new ArrayList<Interceptor>();
+        inFaultInterceptors = new ArrayList<Interceptor>();
+        
+        // the minimal set of interceptors required to satisfy the effective policy for
+        // any inbound message 
+        for (Assertion a : getChosenAlternative()) {
+            if (a.isOptional()) {
+                continue;
+            }
+            QName qn = a.getName();
+            PolicyInterceptorProvider pp = reg.get(qn);
+            if (null != pp) {
+                inInterceptors.addAll(pp.getInInterceptors());
+                inFaultInterceptors.addAll(pp.getInInterceptors());
+            }
+        }
+        
+        // add the interceptors that may be needed to support the additional assertions
+        // for specific inbound (in case of a server endpoint) or outbound (in case of a client endpoint)
+        // messages
+        
+        Set<QName> vocabulary = null;
+  
+        for (BindingOperationInfo boi : ei.getBinding().getOperations()) {
+            Policy p = engine.getAggregatedOperationPolicy(boi);
+            Set<QName> v = engine.getVocabulary(p, false);
+            if (null == vocabulary) {
+                vocabulary = v;
+            } else {
+                vocabulary.addAll(v); 
+            }
+            if (isServer) {
+                p = engine.getAggregatedMessagePolicy(boi.getInput());
+                vocabulary.addAll(engine.getVocabulary(p, false));
+            } else if (null != boi.getOutput()) {
+                for (BindingFaultInfo bfi : boi.getFaults()) {
+                    p = engine.getAggregatedFaultPolicy(bfi);
+                    vocabulary.addAll(engine.getVocabulary(p, false)); 
+                }
+            }
+        }
+        
+        Set<QName> clientVocabulary = isServer ? null : new HashSet<QName>();
+        if (!isServer) {
+            clientVocabulary.addAll(vocabulary);
+            for (BindingOperationInfo boi : ei.getBinding().getOperations()) {
+                if (null != boi.getOutput()) {
+                    Policy p = engine.getAggregatedMessagePolicy(boi.getOutput());
+                    clientVocabulary.addAll(engine.getVocabulary(p, false)); 
+                }
+            }
+        }
+
+        for (QName qn : vocabulary) {
+            PolicyInterceptorProvider pp = reg.get(qn);
+            if (null != pp) {
+                if (isServer) {
+                    inInterceptors.addAll(pp.getInInterceptors());
+                } else {
+                    inFaultInterceptors.addAll(pp.getInFaultInterceptors());
+                }
+            }
+        }
+        if (!isServer) {
+            for (QName qn : clientVocabulary) {
+                PolicyInterceptorProvider pp = reg.get(qn);
+                if (null != pp) {
+                    inInterceptors.addAll(pp.getInInterceptors());
+                }
+            }
+        }
+    }
+    
+    // for test
+    
+    void setPolicy(Policy ep) {
+        policy = ep;
+    }
+    
+    void setChosenAlternative(List<Assertion> c) {
+        chosenAlternative = c;
+    }
+    
+    void setInInterceptors(List<Interceptor> in) {
+        inInterceptors = in;
+    }
+    
+    void setInFaultInterceptors(List<Interceptor> inFault) {
+        inFaultInterceptors = inFault;
+    }
+    
+    
+}

Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyInfo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/Messages.properties?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/Messages.properties (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/Messages.properties Thu Feb 15 01:36:42 2007
@@ -22,6 +22,6 @@
 NO_ASSERTIONBUILDER_EXC = No assertion builder for type {0} registered.
 NOT_A_POLICY_ELEMENT_EXC = Specified element is not a Policy element.
 NOT_A_POLICYREF_ELEMENT_EXC = Specified element is not a PolicyReference element.
-CLIENT_OUT_NO_ALTERNATIVE_EXC = None of the policy alternatives can be satisfied.
+NO_ALTERNATIVE_EXC = None of the policy alternatives can be satisfied.
 REMOTE_POLICY_RESOLUTION_NOT_SUPPORTED_EXC = Resolution of remote policy references is not supported.
 UNRESOLVED_POLICY_REEFERENCE_EXC = Policy reference {0} could not be resolved.

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java Thu Feb 15 01:36:42 2007
@@ -19,15 +19,21 @@
 
 package org.apache.cxf.ws.policy;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
 import javax.annotation.PostConstruct;
+import javax.xml.namespace.QName;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.extension.BusExtension;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.service.model.BindingFaultInfo;
 import org.apache.cxf.service.model.BindingMessageInfo;
@@ -35,9 +41,14 @@
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.Destination;
 import org.apache.cxf.ws.policy.attachment.wsdl11.Wsdl11AttachmentPolicyProvider;
 import org.apache.neethi.Assertion;
+import org.apache.neethi.Constants;
 import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyComponent;
+import org.apache.neethi.PolicyOperator;
+import org.apache.neethi.PolicyReference;
 import org.apache.neethi.PolicyRegistry;
 
 /**
@@ -48,9 +59,14 @@
     private Bus bus;
     private PolicyRegistry registry;
     private List<PolicyProvider> policyProviders;
+    private boolean registerInterceptors;
 
-    private Map<BindingOperationInfo, ClientPolicyInfo> clientInfo 
-        = new ConcurrentHashMap<BindingOperationInfo, ClientPolicyInfo>();
+    private Map<BindingOperationInfo, ClientRequestPolicyInfo> clientRequestInfo 
+        = new ConcurrentHashMap<BindingOperationInfo, ClientRequestPolicyInfo>();
+    private Map<EndpointInfo, EndpointPolicyInfo> endpointInfo 
+        = new ConcurrentHashMap<EndpointInfo, EndpointPolicyInfo>();
+    private Map<BindingOperationInfo, ServerResponsePolicyInfo> serverResponseInfo 
+        = new ConcurrentHashMap<BindingOperationInfo, ServerResponsePolicyInfo>();
 
     public Class getRegistrationType() {
         return PolicyEngine.class;
@@ -79,7 +95,15 @@
     public PolicyRegistry getRegistry() {
         return registry;
     }
-        
+      
+    public boolean getRegisterInterceptors() {
+        return registerInterceptors;
+    }
+
+    public void setRegisterInterceptors(boolean ri) {
+        registerInterceptors = ri;
+    }
+
     @PostConstruct
     void init() {
         if (null == registry) {
@@ -99,7 +123,7 @@
     
     @PostConstruct
     void addBusInterceptors() {
-        if (null == bus) {
+        if (null == bus || !registerInterceptors) {
             return;
         }
 
@@ -113,22 +137,44 @@
         clientInFault.setBus(bus);
         bus.getInFaultInterceptors().add(clientInFault);
         
-        // TODO: server side
+        ServerPolicyInInterceptor serverIn = new ServerPolicyInInterceptor();
+        serverIn.setBus(bus);
+        bus.getInInterceptors().add(serverIn);
+        ServerPolicyOutInterceptor serverOut = new ServerPolicyOutInterceptor();
+        serverOut.setBus(bus);
+        bus.getOutInterceptors().add(serverOut);
+        ServerPolicyOutFaultInterceptor serverOutFault = new ServerPolicyOutFaultInterceptor();
+        serverOutFault.setBus(bus);
+        bus.getOutFaultInterceptors().add(serverOutFault);
+        
+        // TODO: policy verification interceptors
     }
 
     public List<Interceptor> getClientOutInterceptors(BindingOperationInfo boi, 
-                                                      EndpointInfo ei, Conduit conduit) {
-        return getClientPolicyInfo(boi, ei, conduit).getOutInterceptors();
+                                                      EndpointInfo ei, Conduit c) {
+        return getClientRequestPolicyInfo(boi, ei, c).getOutInterceptors();
+    }
+    
+    public List<Interceptor> getClientInInterceptors(EndpointInfo ei, Conduit c) {        
+        return getEndpointPolicyInfo(ei, c).getInInterceptors();
+    }
+    
+    public List<Interceptor> getClientInFaultInterceptors(EndpointInfo ei, Conduit c) {
+        return getEndpointPolicyInfo(ei, c).getInFaultInterceptors();
+    }
+    
+    public List<Interceptor> getServerInInterceptors(EndpointInfo ei, Destination d) {
+        return getEndpointPolicyInfo(ei, d).getInInterceptors();
     }
     
-    public List<Interceptor> getClientInInterceptors(BindingOperationInfo boi, 
-                                                     EndpointInfo ei, Conduit conduit) {
-        return getClientPolicyInfo(boi, ei, conduit).getInInterceptors();
+    public List<Interceptor> getServerOutInterceptors(BindingOperationInfo boi, 
+                                                      EndpointInfo ei, Destination d) {
+        return getServerResponsePolicyInfo(boi, ei, d).getOutInterceptors();
     }
     
-    public List<Interceptor> getClientInFaultInterceptors(BindingOperationInfo boi, 
-                                                     EndpointInfo ei, Conduit conduit) {
-        return getClientPolicyInfo(boi, ei, conduit).getInFaultInterceptors();
+    public List<Interceptor> getServerOutFaultInterceptors(BindingOperationInfo boi, 
+                                                      EndpointInfo ei, Destination d) {
+        return getServerResponsePolicyInfo(boi, ei, d).getOutFaultInterceptors();
     }
 
     public Policy getAggregatedServicePolicy(ServiceInfo si) {
@@ -195,36 +241,145 @@
         }
         return aggregated == null ? new Policy() : aggregated;
     }
+    
+    /**
+     * Return a collection of all assertions used in the given policy component,
+     * optionally including optional assertions.
+     * The policy need not be normalised, so any policy references will have to be resolved.
+     * @param pc the policy component
+     * @param includeOptional flag indicating if optional assertions should be included
+     * @return the assertions
+     */
+    public Collection<Assertion> getAssertions(PolicyComponent pc, boolean includeOptional) {
+        
+        if (Constants.TYPE_ASSERTION == pc.getType()) {
+            return Collections.singletonList((Assertion)pc);
+        } 
+        
+        Collection<Assertion> assertions = new ArrayList<Assertion>();
+        addAssertions(pc, includeOptional, assertions);
+        return assertions;
+    }
+    
+    private void addAssertions(PolicyComponent pc, boolean includeOptional, 
+                               Collection<Assertion> assertions) {
+
+        if (Constants.TYPE_ASSERTION == pc.getType()) {
+            Assertion a = (Assertion)pc;
+            if (includeOptional || !a.isOptional()) {
+                assertions.add((Assertion)pc);
+                return;
+            }
+        } 
+        
+        if (Constants.TYPE_POLICY_REF == pc.getType()) {
+            PolicyReference pr = (PolicyReference)pc;
+            pc = pr.normalize(registry, false);
+        }
 
+        assert Constants.TYPE_POLICY == pc.getType() 
+                || Constants.TYPE_POLICY == pc.getType() 
+                || Constants.TYPE_EXACTLYONE == pc.getType();
+
+        PolicyOperator po = (PolicyOperator)pc;
+
+        List<PolicyComponent> pcs = CastUtils.cast(po.getPolicyComponents(), PolicyComponent.class);
+        for (PolicyComponent child : pcs) {
+            addAssertions(child, includeOptional, assertions);
+        }
+    }
+    
     /**
-     * Check if a given list of assertions can be supported by the conduit or
-     * interceptors (which, if necessary, can be added to the interceptor
-     * chain).
+     * Return the vocabulary of a policy component, i.e. the set of QNames of
+     * the assertions used in the componente, duplicates removed.
+     * @param pc the policy component
+     * @param includeOptional flag indicating if optional assertions should be included
+     * @return the vocabulary
+     */
+    public Set<QName> getVocabulary(PolicyComponent pc, boolean includeOptional) {
+        Collection<Assertion> assertions = getAssertions(pc, includeOptional);
+        Set<QName> vocabulary = new HashSet<QName>();
+        for (Assertion a : assertions) {
+            vocabulary.add(a.getName());
+        }
+        return vocabulary;
+    }
+
+
+    /**
+     * Check if a given list of assertions can potentially be supported by
+     * interceptors or by an already installed assertor (a conduit or transport
+     * that implements the Assertor interface).
      * 
      * @param alternative the policy alternative
-     * @param conduit the conduit
+     * @param Assertor the assertor
      * @return true iff the alternative can be supported
      */
-    boolean supportsAlternative(List<Assertion> alternative, Conduit conduit) {
+    boolean supportsAlternative(List<Assertion> alternative, Assertor assertor) {
         PolicyInterceptorProviderRegistry pipr = bus.getExtension(PolicyInterceptorProviderRegistry.class);
         for (Assertion a : alternative) {
             if (!(a.isOptional() 
                 || (null != pipr.get(a.getName())) 
-                || ((conduit instanceof Assertor) && ((Assertor)conduit).asserts(a)))) {
+                || (null != assertor && assertor.asserts(a)))) {
                 return false;
             }
         }
         return true;
     }
     
-    ClientPolicyInfo getClientPolicyInfo(BindingOperationInfo boi, EndpointInfo ei, Conduit conduit) {
-        ClientPolicyInfo cpi = clientInfo.get(boi);
-        if (null == cpi) {
-            cpi = new ClientPolicyInfo();
-            cpi.initialise(boi, ei, conduit, this);
-            clientInfo.put(boi, cpi);
+    ClientRequestPolicyInfo getClientRequestPolicyInfo(BindingOperationInfo boi, EndpointInfo ei, Conduit c) {
+        ClientRequestPolicyInfo crpi = clientRequestInfo.get(boi);
+        if (null == crpi) {
+            crpi = new ClientRequestPolicyInfo();
+            Assertor assertor = null;
+            if (c instanceof Assertor) {
+                assertor = (Assertor)c;
+            }
+            crpi.initialise(boi, ei, this, assertor);
+            clientRequestInfo.put(boi, crpi);
+        }
+        return crpi;
+    }
+    
+    EndpointPolicyInfo getEndpointPolicyInfo(EndpointInfo ei, Conduit conduit) {
+        EndpointPolicyInfo epi = endpointInfo.get(ei);
+        if (null != epi) {
+            return epi;
+        }
+        Assertor assertor = conduit instanceof Assertor ? (Assertor)conduit : null;
+        return createEndpointPolicyInfo(ei, false, assertor);
+    }
+    
+    EndpointPolicyInfo getEndpointPolicyInfo(EndpointInfo ei, Destination destination) {
+        EndpointPolicyInfo epi = endpointInfo.get(ei);
+        if (null != epi) {
+            return epi;
+        }
+        Assertor assertor = destination instanceof Assertor ? (Assertor)destination : null;
+        return createEndpointPolicyInfo(ei, true, assertor);
+    }
+    
+    EndpointPolicyInfo createEndpointPolicyInfo(EndpointInfo ei, boolean isServer, Assertor assertor) {
+        EndpointPolicyInfo epi = new EndpointPolicyInfo();
+        epi.initialise(ei, isServer, this, assertor);
+        endpointInfo.put(ei, epi);
+
+        return epi;
+    }
+    
+    ServerResponsePolicyInfo getServerResponsePolicyInfo(BindingOperationInfo boi, 
+                                                         EndpointInfo ei, Destination d) {
+        ServerResponsePolicyInfo srpi = serverResponseInfo.get(boi);
+        if (null == srpi) {
+            srpi = new ServerResponsePolicyInfo();
+            Assertor assertor = null;
+            if (d instanceof Assertor) {
+                assertor = (Assertor)d;
+            }
+            srpi.initialise(boi, ei, this, assertor);
+            serverResponseInfo.put(boi, srpi);
         }
-        return cpi;
+        return srpi;
     }
 
 

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java Thu Feb 15 01:36:42 2007
@@ -112,4 +112,5 @@
         }
         return "";
     }
+    
 }

Added: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java?view=auto&rev=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java (added)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java Thu Feb 15 01:36:42 2007
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.ws.policy;
+
+import java.util.List;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.Destination;
+
+/**
+ * 
+ */
+public class ServerPolicyInInterceptor extends AbstractPhaseInterceptor<Message> {
+
+    private Bus bus;
+    
+    public ServerPolicyInInterceptor() {
+        setId(PolicyConstants.SERVER_POLICY_IN_INTERCEPTOR_ID);
+        setPhase(Phase.RECEIVE);
+    }
+        
+    public void setBus(Bus b) {
+        bus = b;
+    }
+    
+    public Bus getBus() {
+        return bus;
+    }
+    
+    public void handleMessage(Message msg) {        
+        if (PolicyUtils.isRequestor(msg)) {
+            return;
+        }
+        
+        EndpointInfo ei = msg.get(EndpointInfo.class);
+        if (null == ei) {
+            return;
+        }
+        
+        PolicyEngine pe = bus.getExtension(PolicyEngine.class);
+        if (null == pe) {
+            return;
+        }
+        
+        Destination destination = msg.getDestination();
+        
+        // We do not know the underlying message type yet - so we pre-emptively add interceptors 
+        // that can deal with any requests on the underlying endpoint
+        
+        List<Interceptor> policyInInterceptors = pe.getServerInInterceptors(ei, destination);
+        for (Interceptor poi : policyInInterceptors) {
+            msg.getInterceptorChain().add(poi);
+        }
+    }
+}

Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java?view=auto&rev=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java (added)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java Thu Feb 15 01:36:42 2007
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.ws.policy;
+
+import java.util.List;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.Destination;
+
+/**
+ * 
+ */
+public class ServerPolicyOutFaultInterceptor extends AbstractPhaseInterceptor<Message> {
+
+    private Bus bus;
+    
+    public ServerPolicyOutFaultInterceptor() {
+        setId(PolicyConstants.SERVER_POLICY_OUT_FAULT_INTERCEPTOR_ID);
+        setPhase(Phase.SETUP);
+    }
+        
+    public void setBus(Bus b) {
+        bus = b;
+    }
+    
+    public Bus getBus() {
+        return bus;
+    }
+    
+    public void handleMessage(Message msg) {        
+        if (PolicyUtils.isRequestor(msg)) {
+            return;
+        }
+        
+        BindingOperationInfo boi = msg.get(BindingOperationInfo.class);
+        if (null == boi) {
+            return;
+        }
+        
+        EndpointInfo ei = msg.get(EndpointInfo.class);
+        if (null == ei) {
+            return;
+        }
+        
+        PolicyEngine pe = bus.getExtension(PolicyEngine.class);
+        if (null == pe) {
+            return;
+        }
+        
+        Destination destination = msg.getDestination();
+        
+        List<Interceptor> outInterceptors = pe.getServerOutFaultInterceptors(boi, ei, destination);
+        for (Interceptor oi : outInterceptors) {
+            msg.getInterceptorChain().add(oi);
+        }
+    }
+}

Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java?view=auto&rev=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java (added)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java Thu Feb 15 01:36:42 2007
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.ws.policy;
+
+import java.util.List;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.Destination;
+
+/**
+ * 
+ */
+public class ServerPolicyOutInterceptor extends AbstractPhaseInterceptor<Message> {
+
+    private Bus bus;
+    
+    public ServerPolicyOutInterceptor() {
+        setId(PolicyConstants.SERVER_POLICY_OUT_INTERCEPTOR_ID);
+        setPhase(Phase.SETUP);
+    }
+        
+    public void setBus(Bus b) {
+        bus = b;
+    }
+    
+    public Bus getBus() {
+        return bus;
+    }
+    
+    public void handleMessage(Message msg) {        
+        if (PolicyUtils.isRequestor(msg)) {
+            return;
+        }
+        
+        BindingOperationInfo boi = msg.get(BindingOperationInfo.class);
+        if (null == boi) {
+            return;
+        }
+        
+        EndpointInfo ei = msg.get(EndpointInfo.class);
+        if (null == ei) {
+            return;
+        }
+        
+        PolicyEngine pe = bus.getExtension(PolicyEngine.class);
+        if (null == pe) {
+            return;
+        }
+        
+        Destination destination = msg.getDestination();
+        
+        List<Interceptor> outInterceptors = pe.getServerOutInterceptors(boi, ei, destination);
+        for (Interceptor oi : outInterceptors) {
+            msg.getInterceptorChain().add(oi);
+        }
+    }
+}

Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerResponsePolicyInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerResponsePolicyInfo.java?view=auto&rev=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerResponsePolicyInfo.java (added)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerResponsePolicyInfo.java Thu Feb 15 01:36:42 2007
@@ -0,0 +1,183 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.ws.policy;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.service.model.BindingFaultInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.Destination;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
+
+/**
+ * 
+ */
+public class ServerResponsePolicyInfo {
+    
+    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(ServerResponsePolicyInfo.class);
+    
+    private Policy responsePolicy;     
+    private List<Assertion> chosenAlternative;
+    private List<Interceptor> outInterceptors;
+    private List<Interceptor> outFaultInterceptors;
+    
+       
+    public Policy getRequestPolicy() {
+        return responsePolicy;
+    }
+    
+    public List<Assertion> getChosenAlternative() {
+        return chosenAlternative;
+    }
+    
+    public List<Interceptor> getOutInterceptors() {
+        return outInterceptors;
+    } 
+    
+    public List<Interceptor> getOutFaultInterceptors() {
+        return outFaultInterceptors;
+    }   
+    
+    public void initialise(BindingOperationInfo boi, EndpointInfo ei, 
+                           PolicyEngine engine, Assertor assertor) {
+        initialiseResponsePolicy(boi, ei, engine);
+        chooseAlternative(engine, ei, assertor);
+        initialiseOutInterceptors(boi, engine);
+        initialiseOutFaultInterceptors(boi, ei, engine);
+    }
+    
+    void initialiseResponsePolicy(BindingOperationInfo boi, EndpointInfo ei, PolicyEngine engine) {
+        responsePolicy = engine.getEndpointPolicyInfo(ei, (Destination)null).getPolicy(); 
+        responsePolicy = responsePolicy.merge(engine.getAggregatedOperationPolicy(boi));
+        if (null != boi.getOutput()) {
+            responsePolicy = responsePolicy.merge(engine.getAggregatedMessagePolicy(boi.getOutput()));
+        }
+        responsePolicy = (Policy)responsePolicy.normalize(true);
+    }
+
+    void chooseAlternative(PolicyEngine engine, EndpointInfo ei, Assertor assertor) {
+        EndpointPolicyInfo epi = engine.getEndpointPolicyInfo(ei, (Destination)null);
+        Iterator alternatives = responsePolicy.getAlternatives();
+        while (alternatives.hasNext()) {
+            List<Assertion> alternative = CastUtils.cast((List)alternatives.next(), Assertion.class);
+            if (engine.supportsAlternative(alternative, assertor)
+                && alternative.contains(epi.getChosenAlternative())) {
+                setChosenAlternative(alternative);
+                return;
+            }
+        }
+        throw new PolicyException(new Message("NO_ALTERNATIVE_EXC", BUNDLE));
+    }
+
+    void initialiseOutInterceptors(BindingOperationInfo boi, PolicyEngine engine) {
+        outInterceptors = new ArrayList<Interceptor>();
+        
+        if (null == boi.getOutput()) {
+            return;
+        }     
+        
+        PolicyInterceptorProviderRegistry reg = engine.getBus()
+            .getExtension(PolicyInterceptorProviderRegistry.class);
+
+        for (Assertion a : chosenAlternative) {
+            if (a.isOptional()) {
+                continue;
+            }
+            QName qn = a.getName();
+            PolicyInterceptorProvider pp = reg.get(qn);
+            if (null != pp) {
+                outInterceptors.addAll(pp.getOutInterceptors());
+            }
+        }
+    }
+    
+    void initialiseOutFaultInterceptors(BindingOperationInfo boi, EndpointInfo ei, PolicyEngine engine) {
+        outFaultInterceptors = new ArrayList<Interceptor>();
+        
+        if (null == boi.getOutput()) {
+            return;
+        }     
+        
+        PolicyInterceptorProviderRegistry reg = engine.getBus()
+            .getExtension(PolicyInterceptorProviderRegistry.class);
+
+        // the minimal set of interceptors required to satisfy the effective
+        // policy for
+        // any outbound fault message
+        for (Assertion a : getChosenAlternative()) {
+            if (a.isOptional()) {
+                continue;
+            }
+            QName qn = a.getName();
+            PolicyInterceptorProvider pp = reg.get(qn);
+            if (null != pp) {
+                outFaultInterceptors.addAll(pp.getOutFaultInterceptors());
+            }
+        }
+
+        // add the interceptors that may be needed to support the additional
+        // assertions for specific faults
+
+        
+        Policy p = engine.getAggregatedOperationPolicy(boi);
+        Set<QName> vocabulary = engine.getVocabulary(p, false);
+        for (BindingFaultInfo bfi : boi.getFaults()) {
+            p = engine.getAggregatedFaultPolicy(bfi);
+            vocabulary.addAll(engine.getVocabulary(p, false));
+        }
+        
+        for (QName qn : vocabulary) {
+            PolicyInterceptorProvider pp = reg.get(qn);
+            if (null != pp) {
+                outFaultInterceptors.addAll(pp.getOutFaultInterceptors());
+            }
+        }
+    }
+    
+    // for test
+    
+    void setOutInterceptors(List<Interceptor> out) {
+        outInterceptors = out;
+    }
+    
+    void setOutFaultInterceptors(List<Interceptor> outFault) {
+        outFaultInterceptors = outFault;
+    }
+    
+    void setResponsePolicy(Policy ep) {
+        responsePolicy = ep;
+    }
+    
+    void setChosenAlternative(List<Assertion> c) {
+        chosenAlternative = c;
+    }
+}

Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerResponsePolicyInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerResponsePolicyInfo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java?view=auto&rev=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java (added)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java Thu Feb 15 01:36:42 2007
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.ws.policy.attachment.external;
+
+/**
+ * 
+ */
+public class ExternalAttachmentProvider {
+
+}

Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProvider.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/references/ReferenceResolver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/references/ReferenceResolver.java?view=auto&rev=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/references/ReferenceResolver.java (added)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/references/ReferenceResolver.java Thu Feb 15 01:36:42 2007
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.ws.policy.attachment.references;
+
+/**
+ * 
+ */
+public class ReferenceResolver {
+
+}

Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/references/ReferenceResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/references/ReferenceResolver.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java Thu Feb 15 01:36:42 2007
@@ -172,10 +172,10 @@
         
         for (UnknownExtensibilityElement e : extensions) {
             Policy p = null;
-            if (PolicyConstants.getPolicyElementQName().equals(e.getElementType())) {
+            if (PolicyConstants.POLICY_ELEM_QNAME.equals(e.getElementType())) {
                 p = builder.getPolicy(e.getElement());
 
-            } else if (PolicyConstants.getPolicyReferenceElementQName().equals(e.getElementType())) {
+            } else if (PolicyConstants.POLICYREF_ELEM_QNAME.equals(e.getElementType())) {
                 PolicyReference ref = builder.getPolicyReference(e.getElement());
                 if (null != ref) {
                     p = resolveReference(ref, di);
@@ -230,7 +230,7 @@
         List<UnknownExtensibilityElement> extensions = 
             description.getExtensors(UnknownExtensibilityElement.class);
         for (UnknownExtensibilityElement e : extensions) {
-            if (PolicyConstants.getPolicyElementQName().equals(e.getElementType())) {
+            if (PolicyConstants.POLICY_ELEM_QNAME.equals(e.getElementType())) {
                 Policy p = builder.getPolicy(e.getElement());
                 policyMap.put(p.getId(), p);
                 if (uri.equals(p.getId())) {

Modified: incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/ClientPolicyInfoTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/ClientPolicyInfoTest.java?view=diff&rev=507867&r1=507866&r2=507867
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/ClientPolicyInfoTest.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/ClientPolicyInfoTest.java Thu Feb 15 01:36:42 2007
@@ -30,12 +30,10 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Interceptor;
-import org.apache.cxf.service.model.BindingFaultInfo;
 import org.apache.cxf.service.model.BindingMessageInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.ServiceInfo;
-import org.apache.cxf.transport.Conduit;
 import org.apache.neethi.All;
 import org.apache.neethi.Assertion;
 import org.apache.neethi.ExactlyOne;
@@ -55,17 +53,19 @@
     } 
     
     public void testAccessors() {
-        ClientPolicyInfo cpi = new ClientPolicyInfo();
+        ClientRequestPolicyInfo crpi = new ClientRequestPolicyInfo();
         Policy p = control.createMock(Policy.class);
         Assertion a = control.createMock(Assertion.class);
         List<Assertion> la = Collections.singletonList(a);
+        Interceptor i = control.createMock(Interceptor.class);
+        List<Interceptor> li = Collections.singletonList(i);
         control.replay();
-        cpi.setRequestPolicy(p);
-        assertSame(p, cpi.getRequestPolicy());
-        cpi.setChosenAlternative(la);
-        assertSame(la, cpi.getChosenAlternative());
-        cpi.setResponsePolicy(p);
-        assertSame(p, cpi.getResponsePolicy());
+        crpi.setRequestPolicy(p);
+        assertSame(p, crpi.getRequestPolicy());
+        crpi.setChosenAlternative(la);
+        assertSame(la, crpi.getChosenAlternative());
+        crpi.setOutInterceptors(li);
+        assertSame(li, crpi.getOutInterceptors());
         control.verify();
     }
     
@@ -93,18 +93,18 @@
         EasyMock.expect(merged.normalize(true)).andReturn(merged);
         
         control.replay();
-        ClientPolicyInfo cpi = new ClientPolicyInfo();
+        ClientRequestPolicyInfo cpi = new ClientRequestPolicyInfo();
         cpi.initialiseRequestPolicy(boi, ei, engine);
         assertSame(merged, cpi.getRequestPolicy());
         control.verify();
     }
     
     public void testChooseAlternative() {
-        ClientPolicyInfo cpi = new ClientPolicyInfo();
+        ClientRequestPolicyInfo cpi = new ClientRequestPolicyInfo();
         cpi.setRequestPolicy(new Policy());
         
         PolicyEngine engine = control.createMock(PolicyEngine.class);
-        Conduit conduit = control.createMock(Conduit.class);
+        Assertor assertor = control.createMock(Assertor.class);
                
         Policy policy = new Policy();
         ExactlyOne ea = new ExactlyOne();
@@ -116,10 +116,10 @@
         policy.addPolicyComponent(ea);
         cpi.setRequestPolicy(policy);
         
-        EasyMock.expect(engine.supportsAlternative(firstAlternative, conduit)).andReturn(false);
+        EasyMock.expect(engine.supportsAlternative(firstAlternative, assertor)).andReturn(false);
         control.replay();
         try {
-            cpi.chooseAlternative(conduit, engine);  
+            cpi.chooseAlternative(engine, assertor);  
             fail("Expected PolicyException not thrown.");
         } catch (PolicyException ex) {
             // expected
@@ -127,9 +127,9 @@
         control.verify();
         
         control.reset();        
-        EasyMock.expect(engine.supportsAlternative(firstAlternative, conduit)).andReturn(true);
+        EasyMock.expect(engine.supportsAlternative(firstAlternative, assertor)).andReturn(true);
         control.replay();        
-        cpi.chooseAlternative(conduit, engine); 
+        cpi.chooseAlternative(engine, assertor); 
         
         List<Assertion> chosen = cpi.getChosenAlternative();
         assertSame(1, chosen.size());
@@ -144,10 +144,10 @@
         other.addAssertion(a1);
         ea.addPolicyComponent(other);
         List<Assertion> secondAlternative = CastUtils.cast(other.getPolicyComponents(), Assertion.class);
-        EasyMock.expect(engine.supportsAlternative(firstAlternative, conduit)).andReturn(false);
-        EasyMock.expect(engine.supportsAlternative(secondAlternative, conduit)).andReturn(true);
+        EasyMock.expect(engine.supportsAlternative(firstAlternative, assertor)).andReturn(false);
+        EasyMock.expect(engine.supportsAlternative(secondAlternative, assertor)).andReturn(true);
         control.replay();        
-        cpi.chooseAlternative(conduit, engine); 
+        cpi.chooseAlternative(engine, assertor); 
         chosen = cpi.getChosenAlternative();
         assertSame(1, chosen.size());
         assertSame(chosen.size(), secondAlternative.size());
@@ -156,7 +156,7 @@
     }
     
     public void testInitialiseOutInterceptors() {
-        ClientPolicyInfo cpi = new ClientPolicyInfo();        
+        ClientRequestPolicyInfo cpi = new ClientRequestPolicyInfo();        
         List<Assertion> alternative = new ArrayList<Assertion>();
         cpi.setChosenAlternative(alternative);
         
@@ -165,7 +165,7 @@
         setupPolicyInterceptorProviderRegistry(engine, reg);
         
         control.replay();
-        cpi.initialiseOutInterceptors(engine);
+        cpi.initialiseInterceptors(engine);
         assertEquals(0, cpi.getOutInterceptors().size());
         control.verify();
         
@@ -175,7 +175,7 @@
         alternative.add(a);
         EasyMock.expect(a.isOptional()).andReturn(true);
         control.replay();
-        cpi.initialiseOutInterceptors(engine);
+        cpi.initialiseInterceptors(engine);
         assertEquals(0, cpi.getOutInterceptors().size());
         control.verify();
         
@@ -186,7 +186,7 @@
         EasyMock.expect(a.getName()).andReturn(qn);
         EasyMock.expect(reg.get(qn)).andReturn(null);
         control.replay();
-        cpi.initialiseOutInterceptors(engine);
+        cpi.initialiseInterceptors(engine);
         assertEquals(0, cpi.getOutInterceptors().size());
         control.verify();
         
@@ -199,104 +199,10 @@
         Interceptor pi = control.createMock(Interceptor.class);
         EasyMock.expect(pp.getOutInterceptors()).andReturn(Collections.singletonList(pi));
         control.replay();
-        cpi.initialiseOutInterceptors(engine);
+        cpi.initialiseInterceptors(engine);
         assertEquals(1, cpi.getOutInterceptors().size());
         assertSame(pi, cpi.getOutInterceptors().get(0));
         control.verify();     
-    }
-
- 
-    public void testInitialiseResponsePolicyOn() {
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        PolicyEngine engine = control.createMock(PolicyEngine.class);
-        
-        EasyMock.expect(boi.getOutput()).andReturn(null);
-        control.replay();
-        ClientPolicyInfo cpi = new ClientPolicyInfo();
-        cpi.initialiseResponsePolicy(boi, ei, engine);
-        assertNull(cpi.getResponsePolicy());
-        control.verify();
-        control.reset();
-        
-        
-        ServiceInfo si = control.createMock(ServiceInfo.class);
-        BindingMessageInfo bmi = control.createMock(BindingMessageInfo.class);                     
-        EasyMock.expect(boi.getOutput()).andReturn(bmi);        
-        Policy mp = control.createMock(Policy.class);
-        EasyMock.expect(engine.getAggregatedMessagePolicy(bmi)).andReturn(mp);
-        BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class);
-        EasyMock.expect(boi.getFaults()).andReturn(Collections.singletonList(bfi));
-        Policy fp = control.createMock(Policy.class);
-        EasyMock.expect(engine.getAggregatedFaultPolicy(bfi)).andReturn(fp);
-        Policy merged = control.createMock(Policy.class);
-        EasyMock.expect(mp.merge(fp)).andReturn(merged);        
-        Policy op = control.createMock(Policy.class);
-        EasyMock.expect(engine.getAggregatedOperationPolicy(boi)).andReturn(op);    
-        EasyMock.expect(merged.merge(op)).andReturn(merged);
-        Policy ep = control.createMock(Policy.class);
-        EasyMock.expect(engine.getAggregatedEndpointPolicy(ei)).andReturn(ep);
-        EasyMock.expect(merged.merge(ep)).andReturn(merged);
-        EasyMock.expect(ei.getService()).andReturn(si);
-        Policy sp = control.createMock(Policy.class);
-        EasyMock.expect(engine.getAggregatedServicePolicy(si)).andReturn(sp);
-        EasyMock.expect(merged.merge(sp)).andReturn(merged);
-        EasyMock.expect(merged.normalize(true)).andReturn(merged);
-        
-        control.replay();
-        cpi = new ClientPolicyInfo();
-        cpi.initialiseResponsePolicy(boi, ei, engine);
-        assertSame(merged, cpi.getResponsePolicy());
-        control.verify();
-    }
-    
-    public void testInitialiseInInterceptors() {
-        ClientPolicyInfo cpi = new ClientPolicyInfo();    
-        Policy responsePolicy = new Policy();
-        ExactlyOne ea = new ExactlyOne();
-        All alt1 = new All();  
-        QName qn1 = new QName("http://x.y.z", "a1");
-        TestAssertion a1 = new TestAssertion(qn1);
-        alt1.addAssertion(a1);
-        All alt2 = new All();
-        QName qn2 = new QName("http://x.y.z", "a2");
-        TestAssertion a2 = new TestAssertion(qn2);
-        alt2.addAssertion(a2);
-        ea.addPolicyComponent(alt1);
-        ea.addPolicyComponent(alt2);
-        responsePolicy.addPolicyComponent(ea);        
- 
-        PolicyEngine engine = control.createMock(PolicyEngine.class);
-        PolicyInterceptorProviderRegistry reg = control.createMock(PolicyInterceptorProviderRegistry.class);
-        
-        control.replay();
-        cpi.initialiseInInterceptors(engine);
-        assertTrue(cpi.getInInterceptors().isEmpty());
-        assertTrue(cpi.getInFaultInterceptors().isEmpty());
-        control.verify();
-        
-        control.reset();
-        cpi.setResponsePolicy(responsePolicy);
-        setupPolicyInterceptorProviderRegistry(engine, reg);
-        PolicyInterceptorProvider p1 = control.createMock(PolicyInterceptorProvider.class);
-        EasyMock.expect(reg.get(qn1)).andReturn(p1);
-        PolicyInterceptorProvider p2 = control.createMock(PolicyInterceptorProvider.class);
-        EasyMock.expect(reg.get(qn2)).andReturn(p2);
-        Interceptor i1 = control.createMock(Interceptor.class);
-        EasyMock.expect(p1.getInInterceptors()).andReturn(Collections.singletonList(i1));
-        EasyMock.expect(p1.getInFaultInterceptors())
-            .andReturn(CastUtils.cast(Collections.EMPTY_LIST, Interceptor.class));
-        Interceptor i2 = control.createMock(Interceptor.class);
-        EasyMock.expect(p2.getInInterceptors()).andReturn(Collections.singletonList(i2));
-        Interceptor fi2 = control.createMock(Interceptor.class);
-        EasyMock.expect(p2.getInFaultInterceptors())
-            .andReturn(Collections.singletonList(fi2));
-           
-        control.replay();
-        cpi.initialiseInInterceptors(engine);
-        assertEquals(2, cpi.getInInterceptors().size());
-        assertEquals(1, cpi.getInFaultInterceptors().size());
-        control.verify();
     }
     
     private void setupPolicyInterceptorProviderRegistry(PolicyEngine engine,