[jira] [Updated] (SLING-6785) Add support for scoped lifecycle of sling models
[ https://issues.apache.org/jira/browse/SLING-6785?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Christophe Jelger updated SLING-6785: - Description: 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")}} 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}}. was: 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"}} 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 resources within the same HTTP request. We could possibly have the same scopes than the JEE beans scope: {{request}}, {{session}}, and {{application}}. > 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")}} > 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)
[jira] [Updated] (SLING-6785) Add support for scoped lifecycle of sling models
[ https://issues.apache.org/jira/browse/SLING-6785?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Christophe Jelger updated SLING-6785: - Description: 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}}. was: 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")}} 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}}. > 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)
[jira] [Updated] (SLING-6785) Add support for scoped lifecycle of sling models
[ https://issues.apache.org/jira/browse/SLING-6785?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Justin Edelson updated SLING-6785: -- Attachment: SLING-6785.diff Here's a diff of how this would look implemented in the AdapterManager (which is where I think this belongs). I don't love needing to bump the package version for {{org.apache.sling.api}} but we need to do that if we want these constants to be there. > 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 > Attachments: SLING-6785.diff > > > 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)
[jira] [Updated] (SLING-6785) Add support for scoped lifecycle of sling models
[ https://issues.apache.org/jira/browse/SLING-6785?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Justin Edelson updated SLING-6785: -- Attachment: SLING-6785.diff Thinking about this some more and based on [~kwin]'s comment, I think I fell for some overengineering. There's no real need to generalize this in the AdapterManager (although it might be worth looking at whether or not {{SlingHttpServletRequest.adaptTo()}} should work like {{Resource.adaptTo()}}). This can just be localized to the {{ModelAdapterFactory}} and be simplified. Updated diff attached. > 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 > Attachments: SLING-6785.diff, SLING-6785.diff > > > 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)
[jira] [Updated] (SLING-6785) Add support for scoped lifecycle of sling models
[ https://issues.apache.org/jira/browse/SLING-6785?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Justin Edelson updated SLING-6785: -- Fix Version/s: Sling Models Impl 1.3.10 Sling Models API 1.3.4 > 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 >Assignee: Justin Edelson >Priority: Minor > Fix For: Sling Models API 1.3.4, Sling Models Impl 1.3.10 > > Attachments: SLING-6785.diff, SLING-6785.diff > > > 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)