Hello everybody!
I am trying to get the client-side interceptor working within Spring
Here are the details worth mentioning:

*1)* There is no access to the web.xml configuration file from my
module.Until recently, i have successfully used the
RestClientProxyFactoryBean registered within spring context as follows:

*<bean id="client"
    p:serviceInterface="someInterface" p:baseUri="http://some.uri"; />*

2) But recently, for the internal purposes i have added a client-side
public class Interceptor implements

    public void write(MessageBodyWriterContext context) throws IOException,
WebApplicationException {

    public ClientResponse execute(ClientExecutionContext ctx) throws
Exception {
        return ctx.proceed();

    public boolean accept(Class declaring, Method method) {
        return true;

*3) *As i have already said there is now way for me to register a provider
in the web.xml. For that reason there came a Spring BeanPostProcessor where
i get the already initialized ResteasyProviderFactory, register my
MessageBodyWriterInterceptor and return it to the context:

*public class RestClientPostProcessor implements BeanPostProcessor {
    public Object postProcessBeforeInitialization(Object bean, String
beanName) throws BeansException {
        return bean;

    public Object postProcessAfterInitialization(Object bean, String
beanName) throws BeansException {
        if(bean.getClass()==RestClientProxyFactoryBean.class &&
            RestClientProxyFactoryBean restClient =
            ResteasyProviderFactory providerFactory =

            //Need i do here something in addition, namely somehow alter the
already initialized client proxy or something

        return bean;

*4) *After that the interceptor gets sucessfully registered and appears in
the providers factory list. But, as it appeared to be after debugging the
client proxy methods do not have the newly registered interceptor, *but only
those that where registered during the default initialization*.

*5)* Continuing debugging i found out that while invoking the client proxy
method and post processing the request the method
ClientRequest#writeRequestBody being invoked which in turn refer to
getWriterInterceptors() which in turn return only the default
GZIPEncodingInterceptor because ClientInterceptorRepositoryImpl doesn't
contain my sucessfully registered interceptor.

*After all, *How do i get the interceptor which was successfully registered
programmatically within the currently initialized ResteasyProviderFactory be
invoked after each client proxy method call?

EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
Resteasy-users mailing list

Reply via email to