I've tried setting the pattern property, and I can't get it to work. I believe that there's a conflict between pax web, which I have to use for other reasons, and felix's http bundles. Pax web scans any filters for the urlPatterns property and tries to apply that, throwing an exception if it's not found. This seems to prevent felix from picking it up. I thought I could just use pax web to register my filter, but it seems that they have a requirement that all filters must filter existing servlets or paths, and it looks like sling hides a lot of that from the http service as a whole. I'm not sure how to find the SlingMainServlet in the webconsole to find its servlet-name and bind onto that, and after looking at the source, the servlet-name for the servlet seems to be computed at runtime, so I don't have a good way to bind to it via scr.

But this problem is mostly unrelated to sling, so I'll just have to sit on it for a bit and see if anybody has any ideas about how to work around it with my filter remaining an internal sling filter.

-Jason

On Mar 10, 2010, at 10:52 AM, Justin Edelson wrote:

Nah. You should be able to do it with SCR. Just be sure to set the pattern
property. See
http://felix.apache.org/site/apache-felix-http-service.html#ApacheFelixHTTPService-UsingtheWhiteboard

Justin

On Wed, Mar 10, 2010 at 12:47 PM, Jason Rose <[email protected]> wrote:

I'll try this. I was looking into it yesterday shortly before I opened the issue, but I hadn't found an easy way to do it with just SCR annotations. All the examples that I've found involve using the service registry to pull
up the HttpService and registering it with that.

Thank you


On Mar 10, 2010, at 10:36 AM, Justin Edelson wrote:

Jason-
I haven't had a chance to look at the details of your issue, but have you thought about registering your Filter *outside* of Sling (i.e. with
the HttpService)?

Justin

On 3/10/10 12:32 PM, Jason Rose wrote:

Hello all,

I have opened a jira case, SLING-1432, about an issue I'm currently
having with forwarding in a filter. I currently use a filter to force a deeper node structure and present the illusion of it being very flat to work around serious performance problems in jackrabbit while hiding that
from my application's front end.

My filter itself is very simple. It looks at the request's pathinfo, and if it matches a regex I forward the request to a deeper path. This applies to both GET and POST. This seems to work fine for all nodes that I use the provided output formatting servlets to retrieve, like json, xml, txt, etc, but this doesn't work for static resources that I just want stored, such as images, docs, etc. Trying to access those
resources leads to a 404 from sling, although I can verify that I
forward to the correct node.

Looking at the log output, it looks like the JcrResourceResolver runs before executing any filters I provide, and does not run again after
being forwarded from my filter.  I think that some state in the
SlingHttpServletRequest object isn't being cleaned up in the case of a forward from a filter registered with Sling. I'm still not sure though.

Does anybody have any idea why this strategy doesn't work for simple
content but does for anything being loaded and serialized by sling
itself?

-Jason





Reply via email to