[
https://issues.apache.org/jira/browse/SLING-6165?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15599224#comment-15599224
]
Oliver Lietz commented on SLING-6165:
-------------------------------------
The switch in Scripting Thymeleaf to Scripting ResourceResolvers was
successful, but I see two major issues with the current implementation:
* the {{ScriptingResourceResolver}} should be removed from {{ThreadLocal}} on
{{SlingRequestEvent.EventType.EVENT_DESTROY}} (is this event reliable or do we
perhaps leak her?)
* not every request requires an {{ScriptingResourceResolver}}, so instantiation
should be on demand and not on {{SlingRequestEvent.EventType.EVENT_INIT}}
I do not see why the change for {{javax.script}} was required, so let me check
this. And there a some minor issues which should be improved also.
There is nothing special here regarding *Scripting* with this new
{{ScriptingResourceResolverFactory}} (it is using the service/system user
configured for {{org.apache.sling.scripting.core}}) and this pattern will be
useful for other modules (e.g. Validation, reading validation models) –
therefore I think we should make implementation more general (removing
_Scripting_ from names and logging) and move it closer to Sling core.
> Expose a service for Sling Scripting that provides request-scoped Resource
> Resolvers for scripting dependencies
> ---------------------------------------------------------------------------------------------------------------
>
> Key: SLING-6165
> URL: https://issues.apache.org/jira/browse/SLING-6165
> Project: Sling
> Issue Type: New Feature
> Components: Scripting
> Reporter: Radu Cotescu
> Assignee: Radu Cotescu
> Fix For: Scripting Core 2.0.42, Scripting API 2.1.10
>
>
> A new Sling Scripting service ({{ScriptingResourceResolverFactory}}) should
> be implemented in order to provide access to request-based
> {{ResourceResolvers}} for solving script dependencies.
> The following two methods should be available:
> {noformat}
> /**
> * Provides a request-scoped {@link ResourceResolver} with only read access
> to the search paths. This resolver should be used for script
> * resolution in the context of the same request rendering process. The
> {@code ResourceResolver} should not be closed by consumers (calling
> * {@link ResourceResolver#close} doesn't do anything), since this service
> will handle the closing operation automatically. The
> * {@code ResourceResolver} will be shared between scripting dependencies
> that render parts of the response for the same request.
> */
> ResourceResolver getRequestScopedResourceResolver()
> /**
> * Provides a {@link ResourceResolver} with only read access to the search
> paths. Once you're done processing {@link Resource}s with this
> * {@code ResourceResolver} make sure to close it.
> */
> ResourceResolver getResourceResolver()
> {noformat}
> [sling-dev email
> thread|https://lists.apache.org/thread.html/db2a78249baf2d6234a4549a5aff8b5474256add9829f86ac78d1c56@%3Cdev.sling.apache.org%3E]
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)