Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: make text more Docbook PDF friendly.

...

Code Block
java
java
package mycompany.com.interceptors;
import org.apache.cxf.ws.policy.AssertionInfoMap;

class MyPolicyAwareInterceptor {
   static final QName assertionType = new QName("http://mycompany.com}", 
       "MyType"});

   public void handleMessage(Message message) {

      // get AssertionInfoMap
       org.apache.cxf.ws.policy.AssertionInfoMap aim = 
           message.get(org.apache.cxf.ws.policy.AssertionInfoMap.class);
       Collection<AssertionInfo ais> = aim.get(assertionType );

       // extract Assertion information
       for (AssertionInfo ai : ais) {
           org.apache.neethi.Assertion a = ai.getAssertion();
           MyAssertionType ma = (MyAssertionType)a;
          // digest ....
       }

       // process message ...
            // express support

       for (AssertionInfo ai : ais) {
           ai.setAsserted(...);
       }          }
}

...

Code Block
xml
xml

<bean name="MyPolicyAwareInterceptor" 
      "class="mycompany.com.interceptors.MyPolicyAwareInterceptor"/>

<bean class="org.apache.cxf.ws.policy.PolicyInterceptorProviderImpl">
        <constructor-arg>
            <!-- the list of assertion types supported by this 
                 PolicyInterceptorProvider -->
            <list>
                <bean class="javax.xml.namespace.QName">
                    <constructor-arg value="http://mycompany.com}"/>
                    <constructor-arg value="MyType"/>
                </bean>
            </list>
        </constructor-arg>
        <property name="inInterceptors">
            <list>
                <ref bean="MyPolicyAwareInterceptor"/>
            </list>
        </property>
        <property name="inFaultInterceptors">
            <list>
                <ref bean="MyPolicyAwareInterceptor"/>
            </list>
        </property>
        <property name="outInterceptors">
            <list>
                <ref bean="MyPolicyAwareInterceptor"/>
            </list>
        </property>
        <property name="outFaultInterceptors">
            <list>
                <ref bean="MyPolicyAwareInterceptor"/>
            </list>
        </property>
    </bean>

...

Code Block
java
java
class MyPolicyAwareConduit {
    static final QName assertionType = new QName("http://mycompany.com}", 
        "MyType"});
    ...

    void init() {
        PolicyEngine engine = bus.getExtenation(PolicyEngine.class);
        if (null != engine && engine.isEnabled()) {
        EffectiveEndpointPolicy ep = engine.getEndpointPolicy(endpoint, this);
        Collection<Assertion> as = ep.getChosenAlternative();
        for (Assertion a : as) {
            if (assertType.equals(a.getName()) {
                // do something with it ...
            }
       }
       ... 
    }
}

...

Code Block
java
java
class MyPolicyAwareConduit implements Assertor {
    static final QName MYTYPE = new QName("http://mycompany.com}", 
        "MyType"});

    public boolean canAssert(QName name) {
        return MTYPE.equals(name);
    }

    public void assertMessage(Mesage message) {
        AssertionInfoMap = message.get(AssertioninfoMap.class);
        ...
    }
}