Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-6785

Add support for scoped lifecycle of sling models

    XMLWordPrintableJSON

Details

    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.

      Attachments

        1. SLING-6785.diff
          18 kB
          Justin Edelson
        2. SLING-6785.diff
          18 kB
          Justin Edelson

        Issue Links

          Activity

            People

              justinedelson Justin Edelson
              jelger Christophe Jelger
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: