On 26 Oct 2007, at 12:05, Felix Meschberger wrote:

* ResourceResolver
The ResourceResolver is added and provides the functionality to access
Resources and list children, which was formerly provided by the
SlingRequest interface. A new ResourceManager interface extending the
ResourceResolver is added, which may be implemented to provide seemless
content mapping. The ResourceManager extends ResourceResolver and
servlets may cast to get the functionality.


I would like to open the discussion now on this .... Any comments are
welcome. Thanks in advance.

Some suggestions:

1. I still feel that the mechanism to resolve a servlet is a bit too hard coded. I'd suggest adding a ServletResolver interface, which would work similar to the ResourceResolver. The selectSlingServlet() method would then resolve a Servlet using the configured ServletResolver(s). The body of the current selectSlingServlet() method could form a DefaultSlingServletResolver to maintain current functionality.

public interface ServletResolver {

    /**
        Find the Servlet that request must process for
        the loaded Resource.
     */
Servlet getServlet(HttpServletRequest request, Resource resource) throws SlingException;
}

Example usage: I need to use a different servlet for export. I'd then configure a ServletResolver that looks for an ?export=true request parameter and returns the export servlet. Another example is if I need to print debug information while coding. I'd then configure a ServletResolver that looks for ?Debug=true parameters and returns the debug servlet.


2. Generalise the "Servlet" into a sort of "View" component. The best analogy is probably Struts' ActionForward class. Wouldn't it be appropriate to use a JSP as a view component for a Resource? I feel that having the SlingMainServlet resolve to view components is duplicating functionality available in the servlet container. A SlingForward could either be initialised with a resource type, requesting handling by the appropriate SlingServlet for the resource type, by a normal path parameter to forward to a JSP decided by the servlet container, or some other constant to request handling by a script execution servlet. The above interface would then contain the method

SlingForward getSlingForward() (HttpServletRequest request, Resource resource) throws SlingException;


3. Extend the MicroslingRequestContext implementation to resolve a number of ResourceResolver and ServletResolver from the service locator. They should be orderly configured, and each one tried until one actually resolves a Resource / Servlet. This would be needed for the suggested ServletResolver setup to be easily extended as suggested above.

--
Torgeir Veimo
[EMAIL PROTECTED]



Reply via email to