Overview
The above figure depicts a simplified model of working:
...
ModelProvider (described in details at ModelProvider) is a core interface in Slice and is used for providing objects (models). Its functionality is very similar to injector's getInstance(); however it is extended by a resource, so that object fields can be mapped using specified resource (or path). A simple use of ModelProvider:
Code Block | ||
---|---|---|
| ||
ModelProvider modelProvider = injector.getInstance(ModelProvider.class); TextModel model = modelProvider.get(TextModel.class, request.getResource()); |
...
The @SliceResource annotation is used for marking classes which should be mapped from current resource by built-in object-resource Mapper. An example class looks like this:
Code Block | ||
---|---|---|
| ||
@SliceResource public class TextModel { @JcrProperty private String text; public String getText() { return text; } } |
...
The three subsections above described very briefly core mechanisms of Slice. To sum it up, take a look at the image below which put all these things together.