Marcin Erbel
Marcin Erbel

Reputation: 1643

Cxf Failure Interceptor for one service bean in multi-bean service

I've a declaration in spring two services which are deployed on the same address. I would like to declare failure interceptor for only one of them, but is there a easy way to do that without changing address for two services? I would like to have them on the same address.

   <jaxrs:server id="service" address="http://0.0.0.0:${service.port:7070}/">
        <jaxrs:serviceBeans>
            <ref bean="firstService"/>
            <ref bean="secondService"/>
        </jaxrs:serviceBeans>

        <jaxrs:outInterceptors>
            <ref bean="failureInterceptor" />
        </jaxrs:outInterceptors>

        <jaxrs:features>
            <cxf:logging/>
            <ref bean="commonValidationFeature"/>
        </jaxrs:features>
        <jaxrs:providers>
            <ref bean="jsonProvider"/>
        </jaxrs:providers>
    </jaxrs:server>

Upvotes: 0

Views: 72

Answers (1)

pedrofb
pedrofb

Reputation: 39271

You can declare two jax-rs server, each one with its own interceptor if you could adapt slightly the relative path of the services

For example, you can use both equivalently

<jaxrs:server id="ServiceAImpl" address="/test/a">
<jaxrs:server id="ServiceBImpl" address="/test/b">

<jaxrs:server id="serviceImpl" address="/test">
    <jaxrs:serviceBeans>
        <ref bean="serviceABean"/>  <!--  /test/a service -->
        <ref bean="serviceBBean"/>   <!--  /test/b service -->

but it is not allowed

<jaxrs:server id="ServiceAImpl" address="/test">
<jaxrs:server id="ServiceBImpl" address="/test">

If it is not possible for you, you could determine at interceptor which is the source service bean ( analysing method name or uri) and fire the especific interceptor manager

Upvotes: 1

Related Questions