Skip to main content Skip to complementary content

Interaction with the Framework

About this task

Components interact with the policy framework mainly in order to:

Procedure

  1. retrieve the assertions pertaining to the underlying message (at least the ones known to the component) so the component can operate on the message accordingly
  2. confirm that the assertions pertaining to the underlying message are indeed supported.

Results

Like most other CXF features, the policy framework is itself largely interceptor based. Thus, most interaction with the framework is indirect through the Message object: Policy interceptors make AssertionInfo objects (stateful representations of assertions) available to subsequently executing, policy-aware interceptors by inserting them into the Message object. Extracting the AssertionInfo objects from the Message allows interceptors to perform steps 1. and 2. above:

import org.apache.neethi.Assertion;

public class AssertionInfo {
   ...
   public boolean isAsserted() {...}
   public void setAsserted(boolean asserted) {...}
   public Assertion getAssertion() {...}
}

The WS-Addressing and WS-RM interceptors are examples for this style of intercation.

Somtimes, Conduits and destinations also want to assert their capabilities. But they cannot normally wait for Assertion information being made available to them via the Message object: Conduits may exhibit message specific behaviour (for example, apply message specific receive timeouts), but decisions made during the initialization phase may limit their capability to do so. And Destinations cannot normally exhibit message or operation specific behaviour at all. But both may still be able to support assertions in the effective endpoint's policy.

Their interaction with the policy framework therefore typically involves the PolicyEngine through which they obtain the effective policy for the underlying endpoint (for step 1.):

public interface PolicyEngine {
   ...
   EndpointPolicy getClientEndpointPolicy(EndpointInfo ei, 
      Conduit conduit);    
   EndpointPolicy getServerEndpointPolicy(EndpointInfo ei, 
      Destination destination); 
}

public interface EndpointPolicy {
   ...
   Policy getPolicy(); 
   Collection<Assertion> getChosenAlternative();
}

To perform step 2. they implement the Assertor interface (namely its assertMessage method):

public class Assertor {
   ...
   public boolean canAssert(QName name);
   public void assertMessage(Message message);
}

An example for policy aware conduits and destinations in CXF are the HTTP conduit and destination. They do support assertions of element type HTTPClientPolicy and HTTPServerPolicy respectively.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!