[
https://issues.apache.org/jira/browse/SLING-6785?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15978814#comment-15978814
]
Christophe Jelger edited comment on SLING-6785 at 4/21/17 2:26 PM:
-------------------------------------------------------------------
Just to make sure this is clear, I do not mean that {{scope="request"}} means
that the adaptable is a request, here "request" is in the sense of an HTTP
request "lifecycle", but the adaptable could also be a resource. So I mean
{{scope}} in the sense of a lifecycle or duration, like in JEE.
[~justinedelson] Regarding your proposal, do you foresee that the scope could
be something else than an adaptable?
PS: regarding {{session}} and {{application}} I knew that this would be
controversial but decided to leave this anyway in the issue. ;-)
was (Author: jelger):
Just to make sure this is clear, I do not mean that {{scope="request"}} means
that the adaptable is a request, here "request" is in the sense of an HTTP
request "lifecycle", but the adaptable could also be a resource. So I mean
{{scope}} in the sense of a lifecycle or duration, like in JEE.
Regarding your proposal, do you foresee that the scope could be something else
than an adaptable?
PS: regarding {{session}} and {{application}} I knew that this would be
controversial but decided to leave this anyway in the issue. ;-)
> Add support for scoped lifecycle of sling models
> ------------------------------------------------
>
> Key: SLING-6785
> URL: https://issues.apache.org/jira/browse/SLING-6785
> Project: Sling
> Issue Type: New Feature
> Components: Extensions
> Reporter: Christophe Jelger
> Priority: Minor
>
> Similar to the scopes of JEE beans
> (http://docs.oracle.com/javaee/6/tutorial/doc/gjbbk.html), it would be nice
> to have the possibility to set a scope for sling models.
> For example, a sling model instance could be reused for all the components
> within the same HTTP request, thus avoiding that multiple instances of the
> "same" model are created.
> This could be an attribute of the {{@model}} annotation, for example
> something like:
> {{@model(scope="request")}}
> The {{request}} scope sounds straightforward for a sling model adapted from a
> request.
> For models adapted from a resource, there are scenarios where the resource
> itself is not relevant once the model has been instantiated, so it would
> still be useful to be able to obtain the same model instance for different
> components and resources within the same HTTP request.
> We could possibly have the same scopes than the JEE beans scope: {{request}},
> {{session}}, and {{application}}.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)