You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2009/03/09 17:40:12 UTC

svn commit: r751733 - in /cxf/trunk: api/src/main/java/org/apache/cxf/ws/policy/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/ rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/ s...

Author: dkulp
Date: Mon Mar  9 16:40:11 2009
New Revision: 751733

URL: http://svn.apache.org/viewvc?rev=751733&view=rev
Log:
Consolidate the policy interceptors down a bit to make them have MUCH less performance impact if policy is enabled, but not used.

Added:
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInInterceptor.java   (contents, props changed)
      - copied, changed from r751678, cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyOutInterceptor.java   (contents, props changed)
      - copied, changed from r751678, cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java
Removed:
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInInterceptor.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyOutInterceptor.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java
Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyConstants.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptor.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java
    cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java
    cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java
    cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptorTest.java
    cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptorTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyConstants.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyConstants.java?rev=751733&r1=751732&r2=751733&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyConstants.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyConstants.java Mon Mar  9 16:40:11 2009
@@ -59,17 +59,12 @@
     public static final String WSU_ID_ATTR_NAME = "Id";
 
     
-    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 POLICY_IN_INTERCEPTOR_ID
+        = "org.apache.cxf.ws.policy.PolicyInInterceptor";
+    public static final String POLICY_OUT_INTERCEPTOR_ID
+        = "org.apache.cxf.ws.policy.PolicyOutInterceptor";
     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";
     

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=751733&r1=751732&r2=751733&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java (original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java Mon Mar  9 16:40:11 2009
@@ -2126,6 +2126,7 @@
         public void onMessage(Message inMessage) {
             // disposable exchange, swapped with real Exchange on correlation
             inMessage.setExchange(new ExchangeImpl());
+            inMessage.getExchange().put(Bus.class, bus);
             inMessage.put(DECOUPLED_CHANNEL_MESSAGE, Boolean.TRUE);
             // REVISIT: how to get response headers?
             //inMessage.put(Message.PROTOCOL_HEADERS, req.getXXX());

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java?rev=751733&r1=751732&r2=751733&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java Mon Mar  9 16:40:11 2009
@@ -19,7 +19,6 @@
 
 package org.apache.cxf.ws.policy;
 
-import org.apache.cxf.Bus;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
@@ -34,8 +33,6 @@
  */
 public abstract class AbstractPolicyInterceptor extends AbstractPhaseInterceptor<Message> {
     
-    protected Bus bus;
-    
     public AbstractPolicyInterceptor(String phase) {
         super(phase);
     }
@@ -43,14 +40,6 @@
         super(id, phase);
     }
     
-    public void setBus(Bus b) {
-        bus = b;
-    }
-    
-    public Bus getBus() {
-        return bus;
-    }
-    
     public void handleMessage(Message message) throws Fault {
         try {
             handle(message);

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java?rev=751733&r1=751732&r2=751733&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java Mon Mar  9 16:40:11 2009
@@ -24,6 +24,7 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Interceptor;
@@ -61,6 +62,7 @@
         }
         EndpointInfo ei = e.getEndpointInfo();
         
+        Bus bus = exchange.get(Bus.class);
         PolicyEngine pe = bus.getExtension(PolicyEngine.class);
         if (null == pe) {
             return;
@@ -85,7 +87,7 @@
         // insert assertions of endpoint's fault vocabulary into message
         
         Collection<PolicyAssertion> assertions = ep.getFaultVocabulary();
-        if (null != assertions) {
+        if (null != assertions && !assertions.isEmpty()) {
             msg.put(AssertionInfoMap.class, new AssertionInfoMap(assertions));
         }
     }

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java?rev=751733&r1=751732&r2=751733&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java Mon Mar  9 16:40:11 2009
@@ -20,6 +20,7 @@
 package org.apache.cxf.ws.policy;
 
 import java.util.*;
+import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.logging.Logger;
 
 import javax.annotation.PostConstruct;
@@ -63,7 +64,7 @@
     
     private Bus bus;
     private PolicyRegistry registry;
-    private Collection<PolicyProvider> policyProviders;
+    private Collection<PolicyProvider> policyProviders = new CopyOnWriteArrayList<PolicyProvider>();
     private boolean enabled;
     private boolean ignoreUnknownAssertions = true;
     private boolean addedBusInterceptors;
@@ -93,7 +94,7 @@
     }
 
     public void setPolicyProviders(Collection<PolicyProvider> p) {
-        policyProviders = p;
+        policyProviders = new CopyOnWriteArrayList<PolicyProvider>(p);
     }
    
     public Collection<PolicyProvider> getPolicyProviders() {
@@ -308,34 +309,17 @@
             abr.setIgnoreUnknownAssertions(ignoreUnknownAssertions);
         }
 
-        ClientPolicyOutInterceptor clientOut = new ClientPolicyOutInterceptor();
-        clientOut.setBus(bus);
-        bus.getOutInterceptors().add(clientOut);
-        ClientPolicyInInterceptor clientIn = new ClientPolicyInInterceptor();
-        clientIn.setBus(bus);
-        bus.getInInterceptors().add(clientIn);
-        ClientPolicyInFaultInterceptor clientInFault = new ClientPolicyInFaultInterceptor();
-        clientInFault.setBus(bus);
-        bus.getInFaultInterceptors().add(clientInFault);
-    
-        ServerPolicyInInterceptor serverIn = new ServerPolicyInInterceptor();
-        serverIn.setBus(bus);
+        PolicyInInterceptor serverIn = new PolicyInInterceptor();
         bus.getInInterceptors().add(serverIn);
-        ServerPolicyOutInterceptor serverOut = new ServerPolicyOutInterceptor();
-        serverOut.setBus(bus);
+        PolicyOutInterceptor serverOut = new PolicyOutInterceptor();
         bus.getOutInterceptors().add(serverOut);
+        
+        
+        ClientPolicyInFaultInterceptor clientInFault = new ClientPolicyInFaultInterceptor();
+        bus.getInFaultInterceptors().add(clientInFault);
         ServerPolicyOutFaultInterceptor serverOutFault = new ServerPolicyOutFaultInterceptor();
-        serverOutFault.setBus(bus);
         bus.getOutFaultInterceptors().add(serverOutFault);
-    
-        PolicyVerificationOutInterceptor verifyOut = new PolicyVerificationOutInterceptor();
-        verifyOut.setBus(bus);
-        bus.getOutInterceptors().add(verifyOut);
-        PolicyVerificationInInterceptor verifyIn = new PolicyVerificationInInterceptor();
-        verifyIn.setBus(bus);
-        bus.getInInterceptors().add(verifyIn);
         PolicyVerificationInFaultInterceptor verifyInFault = new PolicyVerificationInFaultInterceptor();
-        verifyInFault.setBus(bus);
         bus.getInFaultInterceptors().add(verifyInFault);
     
         addedBusInterceptors = true;

Copied: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInInterceptor.java (from r751678, cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInInterceptor.java?p2=cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInInterceptor.java&p1=cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java&r1=751678&r2=751733&rev=751733&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInInterceptor.java Mon Mar  9 16:40:11 2009
@@ -24,6 +24,7 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Interceptor;
@@ -31,29 +32,25 @@
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageUtils;
 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;
 import org.apache.cxf.transport.Destination;
 
 /**
  * 
  */
-public class ServerPolicyInInterceptor extends AbstractPolicyInterceptor {
+public class PolicyInInterceptor extends AbstractPolicyInterceptor {
 
-    private static final Logger LOG = LogUtils.getL7dLogger(ServerPolicyInInterceptor.class);
+    private static final Logger LOG = LogUtils.getL7dLogger(PolicyInInterceptor.class);
     
-    public ServerPolicyInInterceptor() {
-        super(PolicyConstants.SERVER_POLICY_IN_INTERCEPTOR_ID, Phase.RECEIVE);
+    public PolicyInInterceptor() {
+        super(PolicyConstants.POLICY_IN_INTERCEPTOR_ID, Phase.RECEIVE);
     }
     
-    protected void handle(Message msg) {        
-        if (MessageUtils.isRequestor(msg)) {
-            LOG.fine("Is a requestor.");
-            return;
-        }
-        
+    protected void handle(Message msg) {
         Exchange exchange = msg.getExchange();
-        assert null != exchange;
-        
+        Bus bus = exchange.get(Bus.class);
         Endpoint e = exchange.get(Endpoint.class);
         if (null == e) {
             LOG.fine("No endpoint.");
@@ -66,24 +63,62 @@
             return;
         }
         
-        Destination destination = exchange.getDestination();
-        
-        // We do not know the underlying message type yet - so we pre-emptively add interceptors 
-        // that can deal with any messages to this endpoint
-        
-        EndpointPolicy ep = pe.getServerEndpointPolicy(ei, destination);
-        
-        List<Interceptor> interceptors = ep.getInterceptors();
-        for (Interceptor i : interceptors) {
-            msg.getInterceptorChain().add(i);
-            LOG.log(Level.FINE, "Added interceptor of type {0}", i.getClass().getSimpleName());
-        }
-        
-        // insert assertions of endpoint's vocabulary into message
-        
-        Collection<PolicyAssertion> assertions = ep.getVocabulary();
-        if (null != assertions) {
-            msg.put(AssertionInfoMap.class, new AssertionInfoMap(assertions));
+        if (MessageUtils.isRequestor(msg)) {
+            BindingOperationInfo boi = exchange.get(BindingOperationInfo.class);
+            if (boi == null) {
+                Conduit conduit = exchange.getConduit(msg);
+            
+                EndpointPolicy ep = pe.getClientEndpointPolicy(ei, conduit);
+                
+                List<Interceptor> interceptors = ep.getInterceptors();
+                for (Interceptor i : interceptors) {
+                    msg.getInterceptorChain().add(i);
+                }
+                
+                // insert assertions of endpoint's vocabulary into message
+                
+                Collection<PolicyAssertion> assertions = ep.getVocabulary();
+                if (null != assertions && !assertions.isEmpty()) {
+                    msg.put(AssertionInfoMap.class, new AssertionInfoMap(assertions));
+                    msg.getInterceptorChain().add(PolicyVerificationInInterceptor.INSTANCE);
+                }
+            } else {
+                // We do not know the underlying message type yet - so we pre-emptively add interceptors 
+                // that can deal with any resposes or faults returned to this client endpoint.
+                
+                EffectivePolicy ep = pe.getEffectiveClientResponsePolicy(ei, boi);
+        
+                List<Interceptor> interceptors = ep.getInterceptors();
+                for (Interceptor i : interceptors) {
+                    msg.getInterceptorChain().add(i);
+                }
+                // insert assertions of endpoint's vocabulary into message
+                if (ep.getPolicy() != null) {
+                    msg.put(AssertionInfoMap.class, new AssertionInfoMap(ep.getPolicy()));
+                    msg.getInterceptorChain().add(PolicyVerificationInInterceptor.INSTANCE);
+                }
+            }
+        } else {            
+            Destination destination = exchange.getDestination();
+            
+            // We do not know the underlying message type yet - so we pre-emptively add interceptors 
+            // that can deal with any messages to this endpoint
+            
+            EndpointPolicy ep = pe.getServerEndpointPolicy(ei, destination);
+            
+            List<Interceptor> interceptors = ep.getInterceptors();
+            for (Interceptor i : interceptors) {
+                msg.getInterceptorChain().add(i);
+                LOG.log(Level.FINE, "Added interceptor of type {0}", i.getClass().getSimpleName());
+            }
+            
+            // insert assertions of endpoint's vocabulary into message
+            
+            Collection<PolicyAssertion> assertions = ep.getVocabulary();
+            if (null != assertions && !assertions.isEmpty()) {
+                msg.put(AssertionInfoMap.class, new AssertionInfoMap(assertions));
+                msg.getInterceptorChain().add(PolicyVerificationInInterceptor.INSTANCE);
+            }
         }
     }
 }

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

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

Propchange: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInInterceptor.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyOutInterceptor.java (from r751678, cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyOutInterceptor.java?p2=cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyOutInterceptor.java&p1=cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java&r1=751678&r2=751733&rev=751733&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyOutInterceptor.java Mon Mar  9 16:40:11 2009
@@ -24,6 +24,7 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Interceptor;
@@ -33,27 +34,23 @@
 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;
 import org.apache.cxf.transport.Destination;
 
 /**
  * 
  */
-public class ServerPolicyOutInterceptor extends AbstractPolicyInterceptor {
+public class PolicyOutInterceptor extends AbstractPolicyInterceptor {
 
-    private static final Logger LOG = LogUtils.getL7dLogger(ServerPolicyOutInterceptor.class);
+    private static final Logger LOG = LogUtils.getL7dLogger(PolicyOutInterceptor.class);
     
-    public ServerPolicyOutInterceptor() {
-        super(PolicyConstants.SERVER_POLICY_OUT_INTERCEPTOR_ID, Phase.SETUP);
+    public PolicyOutInterceptor() {
+        super(PolicyConstants.POLICY_OUT_INTERCEPTOR_ID, Phase.SETUP);
     }
     
     protected void handle(Message msg) {        
-        if (MessageUtils.isRequestor(msg)) {
-            LOG.fine("Is a requestor.");
-            return;
-        }
-        
         Exchange exchange = msg.getExchange();
-        assert null != exchange;
+        Bus bus = exchange.get(Bus.class);
         
         BindingOperationInfo boi = exchange.get(BindingOperationInfo.class);
         if (null == boi) {
@@ -73,21 +70,56 @@
             return;
         }
         
-        Destination destination = exchange.getDestination();
-        EffectivePolicy effectivePolicy = pe.getEffectiveServerResponsePolicy(ei, boi, destination);
-        msg.put(EffectivePolicy.class, effectivePolicy);
-        
-        List<Interceptor> interceptors = effectivePolicy.getInterceptors();
-        for (Interceptor oi : interceptors) {
-            msg.getInterceptorChain().add(oi);
-            LOG.log(Level.FINE, "Added interceptor of type {0}", oi.getClass().getSimpleName());           
-        }
-        
-        // insert assertions of the chosen alternative into the message
-             
-        Collection<PolicyAssertion> assertions = effectivePolicy.getChosenAlternative();
-        if (null != assertions) {
-            msg.put(AssertionInfoMap.class, new AssertionInfoMap(assertions));
+        if (MessageUtils.isRequestor(msg)) {
+            Conduit conduit = exchange.getConduit(msg);
+            
+            // add the required interceptors
+            EffectivePolicy effectivePolicy = pe.getEffectiveClientRequestPolicy(ei, boi, conduit);
+            msg.put(EffectivePolicy.class, effectivePolicy);
+            PolicyUtils.logPolicy(LOG, Level.FINEST, "Using effective policy: ", effectivePolicy.getPolicy());
+            
+            List<Interceptor> interceptors = effectivePolicy.getInterceptors();
+            for (Interceptor i : interceptors) {            
+                msg.getInterceptorChain().add(i);
+                LOG.log(Level.FINE, "Added interceptor of type {0}", i.getClass().getSimpleName());
+            }
+            
+            // insert assertions of the chosen alternative into the message
+            
+            Collection<PolicyAssertion> assertions = effectivePolicy.getChosenAlternative();
+            if (null != assertions && !assertions.isEmpty()) {
+                if (LOG.isLoggable(Level.FINEST)) {
+                    StringBuffer buf = new StringBuffer();
+                    buf.append("Chosen alternative: ");
+                    String nl = System.getProperty("line.separator");
+                    buf.append(nl);
+                    for (PolicyAssertion a : assertions) {
+                        PolicyUtils.printPolicyComponent(a, buf, 1);
+                    }
+                    LOG.finest(buf.toString());
+                }
+                msg.put(AssertionInfoMap.class, new AssertionInfoMap(assertions));
+                msg.getInterceptorChain().add(PolicyVerificationOutInterceptor.INSTANCE);
+            }
+        } else {
+            Destination destination = exchange.getDestination();
+            EffectivePolicy effectivePolicy = pe.getEffectiveServerResponsePolicy(ei, boi, destination);
+            msg.put(EffectivePolicy.class, effectivePolicy);
+            
+            List<Interceptor> interceptors = effectivePolicy.getInterceptors();
+            for (Interceptor oi : interceptors) {
+                msg.getInterceptorChain().add(oi);
+                LOG.log(Level.FINE, "Added interceptor of type {0}",
+                        oi.getClass().getSimpleName());           
+            }
+            
+            // insert assertions of the chosen alternative into the message
+                 
+            Collection<PolicyAssertion> assertions = effectivePolicy.getChosenAlternative();
+            if (null != assertions && !assertions.isEmpty()) {
+                msg.put(AssertionInfoMap.class, new AssertionInfoMap(assertions));
+                msg.getInterceptorChain().add(PolicyVerificationOutInterceptor.INSTANCE);
+            }
         }
     }
 }

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

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

Propchange: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyOutInterceptor.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java?rev=751733&r1=751732&r2=751733&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java Mon Mar  9 16:40:11 2009
@@ -80,6 +80,9 @@
     }
     
     public static void logPolicy(Logger log, Level level, String msg, PolicyComponent pc) {
+        if (!log.isLoggable(level)) {
+            return;
+        }
         if (null == pc) {
             log.log(level, msg);
             return;

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java?rev=751733&r1=751732&r2=751733&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java Mon Mar  9 16:40:11 2009
@@ -21,6 +21,7 @@
 
 import java.util.logging.Logger;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.message.Exchange;
@@ -52,6 +53,11 @@
      */
     protected void handle(Message message) {
         
+        AssertionInfoMap aim = message.get(AssertionInfoMap.class);
+        if (null == aim) {
+            return;
+        }        
+        
         if (!MessageUtils.isRequestor(message)) {
             LOG.fine("Not a requestor.");
             return; 
@@ -73,16 +79,12 @@
         }
         EndpointInfo ei = e.getEndpointInfo();
         
+        Bus bus = exchange.get(Bus.class);
         PolicyEngine pe = bus.getExtension(PolicyEngine.class);
         if (null == pe) {
             return;
         }
         
-        AssertionInfoMap aim = message.get(AssertionInfoMap.class);
-        if (null == aim) {
-            return;
-        }        
-        
         Exception ex = message.getContent(Exception.class);
         if (null == ex) {
             ex = exchange.get(Exception.class);

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptor.java?rev=751733&r1=751732&r2=751733&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptor.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptor.java Mon Mar  9 16:40:11 2009
@@ -21,6 +21,7 @@
 
 import java.util.logging.Logger;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.message.Exchange;
@@ -34,7 +35,8 @@
  * 
  */
 public class PolicyVerificationInInterceptor extends AbstractPolicyInterceptor {
-
+    public static final PolicyVerificationInInterceptor INSTANCE = new PolicyVerificationInInterceptor();
+    
     private static final Logger LOG = LogUtils.getL7dLogger(PolicyVerificationInInterceptor.class);
 
     public PolicyVerificationInInterceptor() {
@@ -49,9 +51,13 @@
      * @throws PolicyException if none of the alternatives is supported
      */
     protected void handle(Message message) {
-        Exchange exchange = message.getExchange();
-        assert null != exchange;
         
+        AssertionInfoMap aim = message.get(AssertionInfoMap.class);
+        if (null == aim) {
+            return;
+        }
+
+        Exchange exchange = message.getExchange();
         BindingOperationInfo boi = exchange.get(BindingOperationInfo.class);
         if (null == boi) {
             LOG.fine("No binding operation info.");
@@ -64,17 +70,13 @@
             return;
         } 
         EndpointInfo ei = e.getEndpointInfo();
-        
+
+        Bus bus = exchange.get(Bus.class);
         PolicyEngine pe = bus.getExtension(PolicyEngine.class);
         if (null == pe) {
             return;
         }
         
-        AssertionInfoMap aim = message.get(AssertionInfoMap.class);
-        if (null == aim) {
-            return;
-        }
-        
         if (MessageUtils.isPartialResponse(message)) {
             LOG.fine("Not verifying policies on inbound partial response.");
             return;

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java?rev=751733&r1=751732&r2=751733&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java Mon Mar  9 16:40:11 2009
@@ -30,7 +30,8 @@
  * 
  */
 public class PolicyVerificationOutInterceptor extends AbstractPolicyInterceptor {
-
+    public static final PolicyVerificationOutInterceptor INSTANCE = new PolicyVerificationOutInterceptor();
+    
     private static final Logger LOG 
         = LogUtils.getL7dLogger(PolicyVerificationOutInterceptor.class);
     public PolicyVerificationOutInterceptor() {
@@ -46,7 +47,6 @@
      * @throws PolicyException if none of the alternatives is supported
      */
     protected void handle(Message message) {
-        
         if (MessageUtils.isPartialResponse(message)) {
             LOG.fine("Not verifying policies on outbound partial response.");
             return;

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java?rev=751733&r1=751732&r2=751733&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java Mon Mar  9 16:40:11 2009
@@ -24,6 +24,7 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Interceptor;
@@ -68,7 +69,8 @@
             return;
         }
         EndpointInfo ei = e.getEndpointInfo();
-        
+
+        Bus bus = exchange.get(Bus.class);
         PolicyEngine pe = bus.getExtension(PolicyEngine.class);
         if (null == pe) {
             return;
@@ -96,7 +98,7 @@
         // insert assertions of the chosen alternative into the message
         
         Collection<PolicyAssertion> assertions = effectivePolicy.getChosenAlternative();
-        if (null != assertions) {
+        if (null != assertions && !assertions.isEmpty()) {
             msg.put(AssertionInfoMap.class, new AssertionInfoMap(assertions));
         }
     }

Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java?rev=751733&r1=751732&r2=751733&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java Mon Mar  9 16:40:11 2009
@@ -87,7 +87,7 @@
         engine = new PolicyEngineImpl(false);
         assertNotNull(engine.getRegistry());
         assertNull(engine.getBus());
-        assertNull(engine.getPolicyProviders()); 
+        assertNotNull(engine.getPolicyProviders()); 
         assertNull(engine.getAlternativeSelector());
         assertTrue(!engine.isEnabled());
         Bus bus = new CXFBusImpl();
@@ -101,7 +101,6 @@
         AlternativeSelector selector = control.createMock(AlternativeSelector.class);
         engine.setAlternativeSelector(selector);
         assertSame(bus, engine.getBus());
-        assertSame(providers, engine.getPolicyProviders());
         assertSame(reg, engine.getRegistry());
         assertTrue(engine.isEnabled()); 
         assertSame(selector, engine.getAlternativeSelector());
@@ -368,8 +367,7 @@
     }
     
     private void doTestAddBusInterceptors(boolean enabled) {        
-        engine = new PolicyEngineImpl();
-        engine.setEnabled(enabled);
+        engine = new PolicyEngineImpl(enabled);
     
         Bus bus = control.createMock(Bus.class);
         engine.setBus(bus);
@@ -378,8 +376,8 @@
         List<Interceptor> inFault = new ArrayList<Interceptor>();
         List<Interceptor> outFault = new ArrayList<Interceptor>();
         if (enabled) {
-            EasyMock.expect(bus.getOutInterceptors()).andReturn(out).times(3);
-            EasyMock.expect(bus.getInInterceptors()).andReturn(in).times(3);
+            EasyMock.expect(bus.getOutInterceptors()).andReturn(out).times(1);
+            EasyMock.expect(bus.getInInterceptors()).andReturn(in).times(1);
             EasyMock.expect(bus.getInFaultInterceptors()).andReturn(inFault).times(2);
             EasyMock.expect(bus.getOutFaultInterceptors()).andReturn(outFault);
             control.replay();
@@ -392,14 +390,10 @@
             Set<String> idsIn = getInterceptorIds(in);
             Set<String> idsInFault = getInterceptorIds(inFault);
             Set<String> idsOutFault = getInterceptorIds(outFault);
-            assertEquals(3, out.size());
-            assertTrue(idsOut.contains(PolicyConstants.CLIENT_POLICY_OUT_INTERCEPTOR_ID));
-            assertTrue(idsOut.contains(PolicyConstants.SERVER_POLICY_OUT_INTERCEPTOR_ID));
-            assertTrue(idsOut.contains(PolicyVerificationOutInterceptor.class.getName()));
-            assertEquals(3, in.size());
-            assertTrue(idsIn.contains(PolicyConstants.CLIENT_POLICY_IN_INTERCEPTOR_ID));
-            assertTrue(idsIn.contains(PolicyConstants.SERVER_POLICY_IN_INTERCEPTOR_ID));
-            assertTrue(idsIn.contains(PolicyVerificationInInterceptor.class.getName()));
+            assertEquals(1, out.size());
+            assertTrue(idsOut.contains(PolicyConstants.POLICY_OUT_INTERCEPTOR_ID));
+            assertEquals(1, in.size());
+            assertTrue(idsIn.contains(PolicyConstants.POLICY_IN_INTERCEPTOR_ID));
             assertEquals(2, inFault.size());
             assertTrue(idsInFault.contains(PolicyConstants.CLIENT_POLICY_IN_FAULT_INTERCEPTOR_ID));
             assertTrue(idsInFault.contains(PolicyVerificationInFaultInterceptor.class.getName()));
@@ -420,8 +414,6 @@
     @Test
     public void testGetAggregatedServicePolicy() {
         engine = new PolicyEngineImpl();
-        List<PolicyProvider> providers = new ArrayList<PolicyProvider>();
-        engine.setPolicyProviders(providers);
         ServiceInfo si = control.createMock(ServiceInfo.class);
         
         control.replay();
@@ -431,7 +423,7 @@
         control.reset();
         
         PolicyProvider provider1 = control.createMock(PolicyProvider.class);
-        providers.add(provider1);
+        engine.getPolicyProviders().add(provider1);
         Policy p1 = control.createMock(Policy.class);
         EasyMock.expect(provider1.getEffectivePolicy(si)).andReturn(p1);
         
@@ -441,7 +433,7 @@
         control.reset();
         
         PolicyProvider provider2 = control.createMock(PolicyProvider.class);
-        providers.add(provider2);
+        engine.getPolicyProviders().add(provider2);
         Policy p2 = control.createMock(Policy.class);
         Policy p3 = control.createMock(Policy.class);
         EasyMock.expect(provider1.getEffectivePolicy(si)).andReturn(p1);
@@ -456,8 +448,6 @@
     @Test
     public void testGetAggregatedEndpointPolicy() throws Exception {
         engine = new PolicyEngineImpl();
-        List<PolicyProvider> providers = new ArrayList<PolicyProvider>();
-        engine.setPolicyProviders(providers);
         EndpointInfo ei = createMockEndpointInfo();
         
         control.replay();
@@ -467,7 +457,7 @@
         control.reset();
         
         PolicyProvider provider1 = control.createMock(PolicyProvider.class);
-        providers.add(provider1);
+        engine.getPolicyProviders().add(provider1);
         Policy p1 = control.createMock(Policy.class);
         EasyMock.expect(provider1.getEffectivePolicy(ei)).andReturn(p1);
         
@@ -477,7 +467,7 @@
         control.reset();
         
         PolicyProvider provider2 = control.createMock(PolicyProvider.class);
-        providers.add(provider2);
+        engine.getPolicyProviders().add(provider2);
         Policy p2 = control.createMock(Policy.class);
         Policy p3 = control.createMock(Policy.class);
         EasyMock.expect(provider1.getEffectivePolicy(ei)).andReturn(p1);
@@ -492,8 +482,6 @@
     @Test
     public void testGetAggregatedOperationPolicy() throws Exception {
         engine = new PolicyEngineImpl();
-        List<PolicyProvider> providers = new ArrayList<PolicyProvider>();
-        engine.setPolicyProviders(providers);
         BindingOperationInfo boi = createMockBindingOperationInfo();
         
         control.replay();
@@ -503,7 +491,7 @@
         control.reset();
         
         PolicyProvider provider1 = control.createMock(PolicyProvider.class);
-        providers.add(provider1);
+        engine.getPolicyProviders().add(provider1);
         Policy p1 = control.createMock(Policy.class);
         EasyMock.expect(provider1.getEffectivePolicy(boi)).andReturn(p1);
         
@@ -513,7 +501,7 @@
         control.reset();
         
         PolicyProvider provider2 = control.createMock(PolicyProvider.class);
-        providers.add(provider2);
+        engine.getPolicyProviders().add(provider2);
         Policy p2 = control.createMock(Policy.class);
         Policy p3 = control.createMock(Policy.class);
         EasyMock.expect(provider1.getEffectivePolicy(boi)).andReturn(p1);
@@ -528,8 +516,6 @@
     @Test
     public void testGetAggregatedMessagePolicy() {
         engine = new PolicyEngineImpl();
-        List<PolicyProvider> providers = new ArrayList<PolicyProvider>();
-        engine.setPolicyProviders(providers);
         BindingMessageInfo bmi = control.createMock(BindingMessageInfo.class);
         
         control.replay();
@@ -539,7 +525,7 @@
         control.reset();
         
         PolicyProvider provider1 = control.createMock(PolicyProvider.class);
-        providers.add(provider1);
+        engine.getPolicyProviders().add(provider1);
         Policy p1 = control.createMock(Policy.class);
         EasyMock.expect(provider1.getEffectivePolicy(bmi)).andReturn(p1);
         
@@ -549,7 +535,7 @@
         control.reset();
         
         PolicyProvider provider2 = control.createMock(PolicyProvider.class);
-        providers.add(provider2);
+        engine.getPolicyProviders().add(provider2);
         Policy p2 = control.createMock(Policy.class);
         Policy p3 = control.createMock(Policy.class);
         EasyMock.expect(provider1.getEffectivePolicy(bmi)).andReturn(p1);
@@ -564,8 +550,6 @@
     @Test
     public void testGetAggregatedFaultPolicy() {
         engine = new PolicyEngineImpl();
-        List<PolicyProvider> providers = new ArrayList<PolicyProvider>();
-        engine.setPolicyProviders(providers);
         BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class);
         
         control.replay();
@@ -575,7 +559,7 @@
         control.reset();
         
         PolicyProvider provider1 = control.createMock(PolicyProvider.class);
-        providers.add(provider1);
+        engine.getPolicyProviders().add(provider1);
         Policy p1 = control.createMock(Policy.class);
         EasyMock.expect(provider1.getEffectivePolicy(bfi)).andReturn(p1);
         
@@ -585,7 +569,7 @@
         control.reset();
         
         PolicyProvider provider2 = control.createMock(PolicyProvider.class);
-        providers.add(provider2);
+        engine.getPolicyProviders().add(provider2);
         Policy p2 = control.createMock(Policy.class);
         Policy p3 = control.createMock(Policy.class);
         EasyMock.expect(provider1.getEffectivePolicy(bfi)).andReturn(p1);

Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java?rev=751733&r1=751732&r2=751733&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java Mon Mar  9 16:40:11 2009
@@ -66,17 +66,8 @@
     } 
     
     @Test
-    public void testAbstractPolicyInterceptor() {
-        ClientPolicyOutInterceptor interceptor = new ClientPolicyOutInterceptor();
-        assertNull(interceptor.getBus());
-        interceptor.setBus(bus);
-        assertSame(bus, interceptor.getBus());
-    }
-    
-    @Test
     public void testClientPolicyOutInterceptor() {
-        ClientPolicyOutInterceptor interceptor = new ClientPolicyOutInterceptor();
-        interceptor.setBus(bus);
+        PolicyOutInterceptor interceptor = new PolicyOutInterceptor();
        
         doTestBasics(interceptor, true, true);
         
@@ -95,8 +86,6 @@
         Collection<PolicyAssertion> assertions = 
             CastUtils.cast(Collections.EMPTY_LIST, PolicyAssertion.class);
         EasyMock.expect(effectivePolicy.getChosenAlternative()).andReturn(assertions);
-        message.put(EasyMock.eq(AssertionInfoMap.class), EasyMock.isA(AssertionInfoMap.class));
-        EasyMock.expectLastCall();
         control.replay();
         interceptor.handleMessage(message);
         control.verify();        
@@ -104,8 +93,7 @@
     
     @Test
     public void testClientPolicyInInterceptor() {
-        ClientPolicyInInterceptor interceptor = new ClientPolicyInInterceptor();
-        interceptor.setBus(bus);
+        PolicyInInterceptor interceptor = new PolicyInInterceptor();
         
         doTestBasics(interceptor, true, false);
         
@@ -118,11 +106,12 @@
         EasyMock.expect(effectivePolicy.getInterceptors())
             .andReturn(CastUtils.cast(Collections.singletonList(i), Interceptor.class));
         InterceptorChain ic = control.createMock(InterceptorChain.class);
-        EasyMock.expect(message.getInterceptorChain()).andReturn(ic);
+        EasyMock.expect(message.getInterceptorChain()).andReturn(ic).anyTimes();
         ic.add(i);
         EasyMock.expectLastCall();
         message.put(EasyMock.eq(AssertionInfoMap.class), EasyMock.isA(AssertionInfoMap.class));
         EasyMock.expectLastCall();
+        ic.add(PolicyVerificationInInterceptor.INSTANCE);
         control.replay();
         interceptor.handleMessage(message);
         control.verify();        
@@ -131,7 +120,6 @@
     @Test
     public void testClientPolicyInFaultInterceptor() {
         ClientPolicyInFaultInterceptor interceptor = new ClientPolicyInFaultInterceptor();
-        interceptor.setBus(bus);
         
         doTestBasics(interceptor, true, false);
         
@@ -149,8 +137,6 @@
         Collection<PolicyAssertion> assertions = 
             CastUtils.cast(Collections.EMPTY_LIST, PolicyAssertion.class);
         EasyMock.expect(endpointPolicy.getFaultVocabulary()).andReturn(assertions);
-        message.put(EasyMock.eq(AssertionInfoMap.class), EasyMock.isA(AssertionInfoMap.class));
-        EasyMock.expectLastCall();
         control.replay();
         interceptor.handleMessage(message);
         control.verify();        
@@ -158,8 +144,7 @@
 
     @Test
     public void testServerPolicyInInterceptor() {
-        ServerPolicyInInterceptor interceptor = new ServerPolicyInInterceptor();
-        interceptor.setBus(bus);
+        PolicyInInterceptor interceptor = new PolicyInInterceptor();
         
         doTestBasics(interceptor, false, false);
 
@@ -177,8 +162,6 @@
         Collection<PolicyAssertion> assertions = 
             CastUtils.cast(Collections.EMPTY_LIST, PolicyAssertion.class);
         EasyMock.expect(endpointPolicy.getVocabulary()).andReturn(assertions);
-        message.put(EasyMock.eq(AssertionInfoMap.class), EasyMock.isA(AssertionInfoMap.class));
-        EasyMock.expectLastCall();
         control.replay();
         interceptor.handleMessage(message);
         control.verify();       
@@ -186,8 +169,7 @@
     
     @Test
     public void testServerPolicyOutInterceptor() {
-        ServerPolicyOutInterceptor interceptor = new ServerPolicyOutInterceptor();
-        interceptor.setBus(bus);
+        PolicyOutInterceptor interceptor = new PolicyOutInterceptor();
         
         doTestBasics(interceptor, false, true);
         
@@ -206,8 +188,6 @@
         Collection<PolicyAssertion> assertions = 
             CastUtils.cast(Collections.EMPTY_LIST, PolicyAssertion.class);
         EasyMock.expect(effectivePolicy.getChosenAlternative()).andReturn(assertions);
-        message.put(EasyMock.eq(AssertionInfoMap.class), EasyMock.isA(AssertionInfoMap.class));
-        EasyMock.expectLastCall();
         control.replay();
         interceptor.handleMessage(message);
         control.verify();        
@@ -220,7 +200,6 @@
         
         ServerPolicyOutFaultInterceptor interceptor = 
             control.createMock(ServerPolicyOutFaultInterceptor.class, new Method[] {m});
-        interceptor.setBus(bus);
         
         doTestBasics(interceptor, false, true);
         
@@ -252,8 +231,6 @@
         Collection<PolicyAssertion> assertions = 
             CastUtils.cast(Collections.EMPTY_LIST, PolicyAssertion.class);
         EasyMock.expect(effectivePolicy.getChosenAlternative()).andReturn(assertions);
-        message.put(EasyMock.eq(AssertionInfoMap.class), EasyMock.isA(AssertionInfoMap.class));
-        EasyMock.expectLastCall();
         control.replay();
         interceptor.handleMessage(message);
         control.verify();        
@@ -318,15 +295,14 @@
                       Boolean setupEngine) {
 
         message = control.createMock(Message.class);
-        EasyMock.expect(message.get(Message.REQUESTOR_ROLE))
-            .andReturn(setupRequestor ? Boolean.TRUE : Boolean.FALSE);
-        if (setupRequestor != isClient) {
-            return;
-        }
         
         exchange = control.createMock(Exchange.class);
+        EasyMock.expect(message.get(Message.REQUESTOR_ROLE))
+            .andReturn(isClient ? Boolean.TRUE : Boolean.FALSE).anyTimes();
+
         EasyMock.expect(message.getExchange()).andReturn(exchange);
         
+        EasyMock.expect(exchange.get(Bus.class)).andReturn(bus).anyTimes();
         if (usesOperationInfo) {
             if (null == boi && setupOperation) {
                 boi = control.createMock(BindingOperationInfo.class);
@@ -348,7 +324,7 @@
             ei = control.createMock(EndpointInfo.class);
         }
         EasyMock.expect(endpoint.getEndpointInfo()).andReturn(ei);
-        
+
         if (null == pe && setupEngine) {
             pe = control.createMock(PolicyEngine.class);
         }
@@ -356,6 +332,7 @@
         if (!setupEngine) {
             return;
         }
+
             
         if (isClient) {
             conduit = control.createMock(Conduit.class);

Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptorTest.java?rev=751733&r1=751732&r2=751733&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptorTest.java (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptorTest.java Mon Mar  9 16:40:11 2009
@@ -65,7 +65,6 @@
         
         PolicyVerificationInFaultInterceptor interceptor = 
             control.createMock(PolicyVerificationInFaultInterceptor.class, new Method[] {m});
-        interceptor.setBus(bus);
         
         setupMessage(false, false, false, false, false, false);
         control.replay();
@@ -127,9 +126,18 @@
         if (null == message) {
             message = control.createMock(Message.class); 
         }
+        if (setupAssertionInfoMap && null == aim) {
+            aim = control.createMock(AssertionInfoMap.class);
+        }
+        EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim);
+        if (!setupAssertionInfoMap) {
+            return;           
+        }
+
         if (null == exchange) {
             exchange = control.createMock(Exchange.class);            
         }
+        
         EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(
             requestor ? Boolean.TRUE : Boolean.FALSE);
         if (!requestor) {
@@ -156,6 +164,7 @@
         }
         EasyMock.expect(endpoint.getEndpointInfo()).andReturn(ei);
         
+        EasyMock.expect(exchange.get(Bus.class)).andReturn(bus);
         if (setupPolicyEngine && null == engine) {
             engine = control.createMock(PolicyEngine.class);
         }
@@ -163,13 +172,7 @@
         if (!setupPolicyEngine) {
             return;           
         }
-        if (setupAssertionInfoMap && null == aim) {
-            aim = control.createMock(AssertionInfoMap.class);
-        }
-        EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim);
-        if (!setupAssertionInfoMap) {
-            return;           
-        }
+
         if (null == ex) {
             ex = control.createMock(Exception.class);
         }

Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptorTest.java?rev=751733&r1=751732&r2=751733&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptorTest.java (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptorTest.java Mon Mar  9 16:40:11 2009
@@ -59,7 +59,6 @@
     public void testHandleMessageNoOp() throws NoSuchMethodException {
         
         PolicyVerificationInInterceptor interceptor = new PolicyVerificationInInterceptor();
-        interceptor.setBus(bus);        
         
         setupMessage(false, false, false, false);
         control.replay();
@@ -82,15 +81,7 @@
         control.replay();
         interceptor.handleMessage(message);
         control.verify();
-        
-        /*
-        control.reset();
-        setupMessage(true, true, true, true);
-        EasyMock.expect(message.get(Message.PARTIAL_RESPONSE_MESSAGE)).andReturn(Boolean.TRUE);
-        control.replay();
-        interceptor.handleMessage(message);
-        control.verify();
-        */
+
     }
     
     @Test
@@ -101,7 +92,6 @@
             new Class[] {Message.class});
         PolicyVerificationInInterceptor interceptor = 
             control.createMock(PolicyVerificationInInterceptor.class, new Method[] {m});
-        interceptor.setBus(bus);
         setupMessage(true, true, true, true);
         EasyMock.expect(message.get(Message.PARTIAL_RESPONSE_MESSAGE)).andReturn(Boolean.FALSE);
         interceptor.getTransportAssertions(message);
@@ -144,6 +134,15 @@
         if (null == exchange) {
             exchange = control.createMock(Exchange.class);            
         }
+        if (setupAssertionInfoMap && null == aim) {
+            aim = control.createMock(AssertionInfoMap.class);
+        }
+        EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim);
+        if (aim == null) {
+            return;
+        }
+        
+        EasyMock.expect(exchange.get(Bus.class)).andReturn(bus).anyTimes();
         EasyMock.expect(message.getExchange()).andReturn(exchange);
         if (setupBindingOperationInfo && null == boi) {
             boi = control.createMock(BindingOperationInfo.class);
@@ -169,10 +168,6 @@
         if (!setupPolicyEngine) {
             return;           
         }
-        if (setupAssertionInfoMap && null == aim) {
-            aim = control.createMock(AssertionInfoMap.class);
-        }
-        EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim);
     }
 
 }

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java?rev=751733&r1=751732&r2=751733&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingInlinePolicyTest.java Mon Mar  9 16:40:11 2009
@@ -35,8 +35,8 @@
 import org.apache.cxf.systest.ws.util.ConnectionHelper;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
-import org.apache.cxf.ws.policy.ServerPolicyInInterceptor;
-import org.apache.cxf.ws.policy.ServerPolicyOutInterceptor;
+import org.apache.cxf.ws.policy.PolicyInInterceptor;
+import org.apache.cxf.ws.policy.PolicyOutInterceptor;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -128,14 +128,14 @@
         boolean hasServerOut = false;
         List<Interceptor> inInterceptors = b.getInInterceptors();
         for (Interceptor i : inInterceptors) {
-            if (i instanceof ServerPolicyInInterceptor) {
+            if (i instanceof PolicyInInterceptor) {
                 hasServerIn = true;
             }
         }
         assertTrue(hasServerIn);
         
         for (Interceptor i : b.getOutInterceptors()) {
-            if (i instanceof ServerPolicyOutInterceptor) {
+            if (i instanceof PolicyOutInterceptor) {
                 hasServerOut = true;
             }
         }