You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Konrad Windszus (JIRA)" <ji...@apache.org> on 2015/09/03 18:02:46 UTC

[jira] [Updated] (SLING-4997) Inconsistency in ModelFactory.isModelClass()

     [ https://issues.apache.org/jira/browse/SLING-4997?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Konrad Windszus updated SLING-4997:
-----------------------------------
    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
{code}
@Model(adaptables = Resource.class)
public class MyModel
{code}

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
{code}
@Model(adapters=MyModel, adaptables = Resource.class)
public class MyModelImpl implements MyModel
{code}
a call of {{ModelFactory.isModelClass(<some SlingHttpServletRequest>, MyModel.class)}} returns {{false}}.

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

The adaptable is 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
{code}
@Model(adaptables = Resource.class)
public class MyModel
{code}

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
{code}
@Model(adapters=MyModel, adaptables = Resource.class)
public class MyModelImpl implements MyModel
{code}
a call of {{ModelFactory.isModelClass(<some SlingHttpServletRequest>, MyModel.class)}} returns {{false}}.


> Inconsistency in ModelFactory.isModelClass()
> --------------------------------------------
>
>                 Key: SLING-4997
>                 URL: https://issues.apache.org/jira/browse/SLING-4997
>             Project: Sling
>          Issue Type: Bug
>          Components: Extensions
>    Affects Versions: Sling Models API 1.2.0
>            Reporter: Konrad Windszus
>
> 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
> {code}
> @Model(adaptables = Resource.class)
> public class MyModel
> {code}
> 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
> {code}
> @Model(adapters=MyModel, adaptables = Resource.class)
> public class MyModelImpl implements MyModel
> {code}
> a call of {{ModelFactory.isModelClass(<some SlingHttpServletRequest>, MyModel.class)}} returns {{false}}.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)