You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ju...@apache.org on 2016/11/03 04:44:12 UTC

svn commit: r1767819 - /sling/site/trunk/content/documentation/bundles/models.mdtext

Author: justin
Date: Thu Nov  3 04:44:12 2016
New Revision: 1767819

URL: http://svn.apache.org/viewvc?rev=1767819&view=rev
Log:
Sling Models Exporter stuff

Modified:
    sling/site/trunk/content/documentation/bundles/models.mdtext

Modified: sling/site/trunk/content/documentation/bundles/models.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/bundles/models.mdtext?rev=1767819&r1=1767818&r2=1767819&view=diff
==============================================================================
--- sling/site/trunk/content/documentation/bundles/models.mdtext (original)
+++ sling/site/trunk/content/documentation/bundles/models.mdtext Thu Nov  3 04:44:12 2016
@@ -453,3 +453,23 @@ The resource type is also used as part o
 
 # Exporter Framework (Since Sling Models 1.3.0)
 
+Sling Models objects can be exported to arbitrary Java objects through the Sling Models Exporter framework. Model objects can be
+programatically exported by calling the `ModelFactory` method `exportModel()`. This method takes as its arguments:
+
+* the model object
+* an exporter name
+* a target class
+* a map of options
+
+The exact semantics of the exporting will be determined by an implementation of the `ModelExporter` service interface. Sling Models 
+currently includes a single exporter, using the Jackson framework, which is capable of serializing models as JSON or transforming them to `java.util.Map` objects.
+
+In addition, model objects can have servlets automatically registered for their resource type (if it is set) using the `@Exporter` annotation. For example, a model class with the annotation
+
+    ::java
+    @Model(adaptable = Resource.class, resourceType = "myco/components/foo")
+    @Exporter(name = "jackson", extensions = "json")
+
+results in the registration of a servlet with the resource type and extension specified and a selector of 'model' (overridable 
+through the `@Exporter` annotation's `selector` attribute). When this servlet is invoked, the `Resource` will be adapted to the 
+model, exported as a `java.lang.String` (via the named Exporter) and then returned to the client.
\ No newline at end of file