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

Inconsistency in ModelFactory.isModelClass()

    XMLWordPrintableJSON

Details

    Description

      With the changes in SLING-4056 there was a change on a method in the ModelFactory:
      public boolean isModelClass(Class<?> modelClass) became
      public boolean isModelClass(Object adaptable, Class<?> type)

      The adaptable parameter was necessary because of the alternate adapter classes defined in https://sling.apache.org/documentation/bundles/models.html#specifying-an-alternate-adapter-class-since-sling-models-110.

      If you now have a Model defined like this

      @Model(adaptables = Resource.class)
      public class MyModel
      

      a call of ModelFactory.isModelClass(<some SlingHttpServletRequest>, MyModel.class) returns true, although the model class is only defined on the adaptable Resource.

      On the other hand if you define a model like this

      @Model(adapters=MyModel, adaptables = Resource.class)
      public class MyModelImpl implements MyModel
      

      a call of ModelFactory.isModelClass(<some SlingHttpServletRequest>, MyModel.class) returns false.

      Attachments

        Issue Links

          Activity

            People

              kwin Konrad Windszus
              kwin Konrad Windszus
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: