[ 
https://issues.apache.org/jira/browse/SLING-1603?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12889156#action_12889156
 ] 

Bertrand Delacretaz commented on SLING-1603:
--------------------------------------------

With this patch the background test servlet of revision 964790 works (start 
with http://localhost:8080/system/bgservlets/test?sling:bg=true and watch 
http://localhost:8080/system/console/bgservlets), but I had to do the following 
in the code that uses the SlingServlet service:


                // In a normal request the ResourceResolver is added to the 
request attributes
                // by the authentication service, need to do the same here as 
we can't reuse the
                // original one which is closed once main request is done
                final AuthenticationInfo aa = 
(AuthenticationInfo)request.getAttribute(AuthenticationInfo.class.getName());
                if(aa == null) {
                        throw new IllegalArgumentException("Missing 
AuthenticationInfo attribute");
                }
                final ResourceResolver rr = rrf.getResourceResolver(aa);
                
this.request.setAttribute(SlingAuthenticator.REQUEST_ATTRIBUTE_RESOLVER, rr);

As the SlingMainServlet needs the ResourceResolver as a request attribute.

Maybe we should add an AuthenticationInfo parameter to the 
SlingServlet.processRequest method, to make this more explicit?

> SlingServlet service
> --------------------
>
>                 Key: SLING-1603
>                 URL: https://issues.apache.org/jira/browse/SLING-1603
>             Project: Sling
>          Issue Type: Improvement
>          Components: Engine
>    Affects Versions: Engine 2.0.6
>            Reporter: Bertrand Delacretaz
>            Assignee: Bertrand Delacretaz
>            Priority: Minor
>         Attachments: SLING-1603.patch
>
>
> For SLING-550 I need to call the SlingMainServlet outside of the web 
> container's request/response cycle.
> I'll attach a patch that introduces a new SlingServlet interface that 
> SlingMainServlet implements.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to