Question

Registering filters with whiteboard.

Hi,

I'm trying to use a Servlet filter with a servlet. I'm using Pax-Web 3.0, Declarative services and whiteboard. I have to declarative service components (one for the servlet and one for the filter), and it seems to work fine.

Looking at the documentation I see the following sentence:

For URL Patterns, the pattern registered must be already mapped, either as Resource or a Servlet alias - e.g there should already be a Resource or aServlet registered to the path /foo. For Servlet names, the names used should have been the name that has been explicitly given to the Servlet (as servlet-name), when registering.

How can I guarantee that in a whiteboard setting? I have no idea when the servlet actually gets registered. I guess I can list the servlet as a dependency of the filter, but that makes it tricky to use the filter for multiple servlets.

Is there a better way?

regards, Frank

Was it helpful?

Solution

It seems highly unlikely that this is an issue. I expect that the sentence from the documentation indicates that your filter just never get called when there is no destination for the path. I.e. the filter is only called when there is a valid destination (a resource or servlet). A basic aspect of the whiteboard is that you should not care about these issues. It is the responsibility for the whiteboard to handle the http service, the filters, and the servlets in any possible registration order. If not ... it needs a serious issue raised.

I have not looked at the code but I am a heavy user of the whiteboard + filter + servlet + DS and never have seen an issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top