On Wed, Apr 2, 2008 at 9:47 AM, Bertrand Delacretaz
<[EMAIL PROTECTED]> wrote:
> On Tue, Apr 1, 2008 at 9:23 PM, Felix Meschberger <[EMAIL PROTECTED]> wrote:
>
> > ...maybe an API
>
> > call such as
> >
> > boolean canHandle(SlingHttpServletRequest)
> >
> > in an interface, which a servlet may implement. If a servlet would be
> > selected which implements the method and returns false, the servlet
> > would be ignored for the resolution and the resolution process would
> > continue as if the servlet would not exist.....
I was thinking about introducing a SlingRequestHandlerServlet
interface, with a method accepts(HtttpServletRequest), and then
modifying SlingServletResolver along these lines:
private Servlet getServlet(ResourceResolver resolver,
Iterator<String> paths, String
baseName, HttpServletRequest request) {
while (paths.hasNext()) {
String location = paths.next();
try {
Servlet result = getServletAt(resolver, location, baseName);
+ if (result != null) {
+ boolean servletAcceptsRequest = !(result
instanceof SlingRequestHandlerServlet)
+ || ((SlingRequestHandlerServlet)
result).accepts(request);
+ if (servletAcceptsRequest) {
return result;
+ }
> Maybe providing extension points for the ServletResolver would be
> cleaner, and allow for easier control of the priority of servlet
> resolution?
>
> We could use additional ServletResolver services, that the main
> ServletResolver would call in (configurable) priority order, and stop
> as soon as one returns a Servlet.
>
> A class can be both a Servlet and ServletResolver service, so this
> could be used in a similar way than what you suggest, but in addition
> allow more sophisticated resolving algorithms.
>
> WDYT?
Your solution sounds a lot more flexible, though, and we could
definitely need some kind of servlet priority logic. However, I'm not
sure I'm up to the task of coding it, not knowing the details of
Sling's request handling logic. But I can create a JIRA issue for it,
if that's any help :)
--
Vidar S. Ramdal <[EMAIL PROTECTED]> - http://www.idium.no
Akersgata 16, N-0158 Oslo, Norway