There is one important difference: The Java Use Provider uses 
adaptTo(...)(https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/a0f0e77a30ecf3091cfa69d21ff46e0994e4e19f/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/use/JavaUseProvider.java#L160
 
<https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/a0f0e77a30ecf3091cfa69d21ff46e0994e4e19f/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/use/JavaUseProvider.java#L160>)
 while the Models Use Provider uses  ModelsFactory.createModel(...) 
(https://github.com/apache/sling-org-apache-sling-scripting-sightly-models-provider/blob/6ef6d531fc15d23744a6a60f798e36c2d368c3ab/src/main/java/org/apache/sling/scripting/sightly/models/impl/SlingModelsUseProvider.java#L126
 
<https://github.com/apache/sling-org-apache-sling-scripting-sightly-models-provider/blob/6ef6d531fc15d23744a6a60f798e36c2d368c3ab/src/main/java/org/apache/sling/scripting/sightly/models/impl/SlingModelsUseProvider.java#L126>).
 The latter does not not catch any exceptions, so debugging issues is a lot 
easier than relying on adaptTo which only emits some log with level WARN (or 
even below) in case model instantiation fails (compare with [1] and [2]).

Konrad

[1] - 
https://sling.apache.org/documentation/bundles/models.html#modelfactory-since-120
 
<https://sling.apache.org/documentation/bundles/models.html#modelfactory-since-120>
[2] - https://issues.apache.org/jira/browse/SLING-3709 
<https://issues.apache.org/jira/browse/SLING-3709>

> On 15. Apr 2020, at 14:55, Radu Cotescu <r...@apache.org> wrote:
> 
> Hi,
> 
> In the context of SLING-9320 and SLING-9207 (the bigger picture) I was 
> wondering if we couldn’t deprecate the 
> org.apache.sling.scripting.sightly.models.provider module completely. The 
> JavaUseProvider from org.apache.sling.scripting.sightly seems to handle Sling 
> Models just fine through the adapter factories that get generated 
> automatically for each model and it also tries the adaptions in the same 
> order.
> 
> The IT we have for the Use-API passed just fine on a setup that doesn’t 
> provide the org.apache.sling.scripting.sightly.models.provider module.
> 
> Konrad, do you have something against this? IIRC you contributed the 
> SlingModelsUseProvider through [2].
> 
> Thanks,
> Radu
> 
> [0] - https://issues.apache.org/jira/browse/SLING-9320 
> <https://issues.apache.org/jira/browse/SLING-9320>
> [1] - https://issues.apache.org/jira/browse/SLING-9207 
> <https://issues.apache.org/jira/browse/SLING-9207>
> [2] - 
> http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/sightly/models-use-provider/src/main/java/org/apache/sling/scripting/sightly/models/impl/ModelFactoryUseProvider.java?revision=1677000&view=markup&pathrev=1677000
>  
> <http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/sightly/models-use-provider/src/main/java/org/apache/sling/scripting/sightly/models/impl/ModelFactoryUseProvider.java?revision=1677000&view=markup&pathrev=1677000>
> 

Reply via email to