[ 
https://issues.apache.org/jira/browse/SLING-6655?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15929029#comment-15929029
 ] 

Justin Edelson commented on SLING-6655:
---------------------------------------

bq. The difference is that its not obvious to understand what the purpose of a 
certain piece of the implementation is. 

The fact that these methods were designed for scripting was in the original 
JIRA. It can certainly be added to the JavaDoc if you think it would be helpful.

bq. Anyway, would you be so kind and point us to the right place where those 
methods are used for Handlebars?

Unfortunately no, the implementation isn't open source.

bq.  I guess there is a JSR-223 compliant implementation somehow exposing 
adaptTo() or the ModelFactory to the scripts themself. IMHO that one is 
responsible for finding the right adapterType instead of enforcing 1:1 
resourceType to adapterType.

Not exactly. The ScriptEngine invokes modelFactory.getModelFromResource() and 
then modelFactory.getModelFromRequest() (it might be the other way around; I 
don't have the code in front of me) and then makes the result available as a 
context object in the Handlebars script. It is important to not have any 
reference to ModelFactory or adaptTo() (or any other Java-ism) in the 
Handlebars script itself since otherwise isomorphic rendering wouldn't work. I 
imagine the same thing would be true if you were doing isomorphic rendering 
with a React-based ScriptEngine.

> Remove untyped getModelFrom* methods from ModelFactory
> ------------------------------------------------------
>
>                 Key: SLING-6655
>                 URL: https://issues.apache.org/jira/browse/SLING-6655
>             Project: Sling
>          Issue Type: Wish
>    Affects Versions: Sling Models Impl 1.3.0
>            Reporter: Dirk Rudolph
>
> As far as I understood the the whole story behind Sling Models API is/was 
> that it can be used to adapt ordinary objects to typed objects. With adding 
> {{Object getModelFromResource(...)}} and {{getModelFromRequest(...)}} this 
> paradigm has been broken. Just looking at the API, what is the purpose of 
> that methods? I agree that it makes much sense to have a binding between the 
> resourceType of {{Resource}} and maybe even {{SlingHttpServletRequest}} and a 
> model, but this resulting into an ordinary object from API perspective makes 
> it kind of pointless. 
> I propose:
> * mark them as deprecated as already done in SLING-6652
> * let them throw {{UnsupportedOperationException}} to prevent them being used
> * remove them in the next major API release
> * move the logic of "finding the nearest implementation by resourceType* to 
> {{ResourceTypeBasedResourcePicker}}
> and for the exporter:
> * if a {{@Model}} has an {{@Exporter}} implicitly registered it with the 
> {{implType}} as {{adapterType}}, if not already done
> * use the {{implType}} in the {{ExporterServlet}} to adapt from request or 
> {{Resource}} to the model object



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to