Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


 

 

 

 

...

Span
stylefont-size:2em;font-weight:bold
JAX-RS Filters

...

 

...

 

 

Table of Contents

Filters

...

The implementations can be registered like any other type of providers :

Code Block
xml
xml
<beans>
    <jaxrs:server id="customerService" address="/">
        <jaxrs:serviceBeans>
            <bean class="org.CustomerService" />
        </jaxrs:serviceBeans>

        <jaxrs:providers>
            <ref bean="authorizationFilter" />
        </jaxrs:providers>
        <bean id="authorizationFilter" class="com.bar.providers.AuthorizationContainerRequestFilter">
            <!-- authorization bean properties -->
        </bean>
    </jaxrs:server>
</beans>

Difference between JAXRS filters and CXF interceptors

...

Sometimes you may want to use CXF interceptors rather than writing JAXRS filters. For example, suppose you combine JAXWS and JAXRS and you need to log only inbound or outbound messages. You can reuse the existing CXF interceptors :

Code Block
xml
xml
<beans>
    <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
    <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>

    <jaxrs:server> 
        <jaxrs:inInterceptors>
            <ref bean="logInbound"/>
        </jaxrs:inInterceptors>
        <jaxrs:outInterceptors>
            <ref bean="logOutbound"/>
        </jaxrs:outInterceptors>
    </jaxrs:server>

    <jaxws:endpoint>
        <jaxws:inInterceptors>
            <ref bean="logInbound"/>
        </jaxws:inInterceptors>
        <jaxws:outInterceptors>
            <ref bean="logOutbound"/>
        </jaxws:outInterceptors>
    </jaxws:endpoint>

</beans>

...

Custom invokers can be registered like this :

Code Block
xml
xml
<beans>

    <jaxrs:server address="/"> 
        <jaxrs:invoker>
            <bean class="org.apache.cxf.systest.jaxrs.CustomJAXRSInvoker"/>
        </jaxrs:invoker>
    </jaxrs:server>

</beans>