0
votes

I would like to ask about if there is a way to call a Filter (javax.servlet.Filter) inside an Apache Camel processor.

Scenario
Inside an Apache Camel Processor (org.apache.camel.Processor), I need to make use of some existing Filter class to perform some logics on the request.

import org.apache.camel.Exchange;
import org.apache.camel.Processor;

public class TestProcessor implements Processor {
    @Override
    public void process(Exchange exchange) throws Exception {
    RequestParameters parameters = exchange.getIn().getBody(RequestParameters.class);
    ...
    ......

    // Can we call an existing Filter class here?
    // e.g. addInfoFilter.doFilter(request, response, filterChain)

    ...
    ......

    exchange.getIn().setBody(requestParams);
}

I'm not sure how this could be achieved. Please let me know if you have any insights, thanks.

1
I would not imagine you could do that at this point, or at least not as easy. I think the filters are applied on incoming and outgoing request/responses - eg before and after Camel - not in between. What is your use-case for doing this? - Claus Ibsen
I agree with Claus' comment, you want to put these filters in your web.xml, not have them called within the camel route. - vikingsteve

1 Answers

0
votes

It seems it is not possible to call a filter inside a Camel processor. Probably the best (or only way) is to intercept the request with the filter, using configuration in web.xml.