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

dan mcweeney commented on SLING-6183:
-------------------------------------

So can you explain what happens when one model points at another model? For 
example, I have an Order Model what uses:

{code}
@Exporter(name = 'jackson', extension = 'json')
{code}

which has a method:

{code}
@JsonProperty(“items”)
public List<Resource> getItems();
{code}

The resources returned by the getItems method have a resourceType which is 
serviced by a Sling Model. When the Order model gets exported what is in that 
list?
If it's an array of Exported Models what named exporter does it use, the one 
defined with the Order or the one defined with the "Item"?

Another slight variation what if it returns a List<Item> where Item is an 
object type managed by Sling Models, which also has an @Exporter annotation?

Also I wonder if it would be better to support a Media type instead of just an 
extension. I realize content negotiation isn't really fully baked into Sling 
but I can see where you might want to be able to support a plain 
application/json export and also a application/vnd.org.sling.models.item+json.


> Sling Models - Provide a mechanism to export model objects via servlets
> -----------------------------------------------------------------------
>
>                 Key: SLING-6183
>                 URL: https://issues.apache.org/jira/browse/SLING-6183
>             Project: Sling
>          Issue Type: New Feature
>          Components: Extensions
>            Reporter: Justin Edelson
>             Fix For: Sling Models API 1.3.0, Sling Models Impl 1.3.0
>
>         Attachments: SLING-6183.patch
>
>
> I would like to introduce a new feature to Sling Models named Exporters.
> Exporters allow for a model class to be exported into a specific Java object 
> type in a automated fashion. The simplest example is to support String 
> serialization, although different Exporters may support whatever target 
> classes they see fit.
> Exporters are implemented through an SPI. This initial contribution includes 
> an exporter using the Jackson library which supports both {{String}} and 
> {{Map}} exports.
> Interfacing with the registered Exporters is done through three new methods 
> on the {{ModelFactory}} interface:
> * {{exportMode}}
> * {{exportModelForResource}}
> * {{exportModelForRequest}}
> In addition, using these functionality, model objects can have 
> automatically-registered servlets which export the model (from either the 
> request or the request's resource) as a {{String}} and then serve that 
> {{String}} to the client.
> Registering these servlets is done through a new annotation named 
> {{@Exporter}}
> For example, you might add this annotation to a Model class
> {{@Exporter(name = 'jackson', extension = 'json')}}
> This will register a servlet for the model's resource type with the extension 
> `json` and a selector of `model` (by default, the {{@Exporter}} annotation 
> can also define a different selector).



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

Reply via email to