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

Sling Models: support adapters for models different from the implementation class

    XMLWordPrintableJSON

Details

    Description

      currently, as adapter (adaption target) only the implementation class itself that is annotated with the @Model annotation is supported (which can be either an interface or a class).

      if the model is not just a simple model but a class with more complex business logic the following scenario is required:

      • a "service" interface is defined
      • this service interface ist not directly mapped to injected values, but provides higher-level method
      • an implementation class with @Model annotation is implemented which gets the required values injectd internally, but implements the interface for outside access

      this is currently not possible with sling models.

      the attached patch extends the following features:

      • extends the @Model annotation with an optional "adapters" attribute
      • if defined, only the listed adapters are registered for the adapter factory, not the implementation class itself (unless it is listed the "adapters" attribute as well)
      • in the adapters attribute only the implementation class itself or interfaces that it implements or superclasses can be defined
      • with this the scenario above is perfectly possible
      • unit tests included which simulate the bundle add/remove usecases which is required to do the indirect implementation class mapping

      Attachments

        1. 140829_SLING-3886_adapters_support.patch
          130 kB
          Stefan Seifert
        2. 140829_SLING-3886_adapters_support_v2.patch
          137 kB
          Stefan Seifert
        3. 140827_SLING-3886_adapters_support.patch
          49 kB
          Stefan Seifert

        Activity

          People

            justinedelson Justin Edelson
            sseifert Stefan Seifert
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: