Hi Konrad,
Thanks for the feedback.

>From a client perspective (i.e. a JSP), they are just using the
adapter framework. The fact that that adaption is annotation driven
isn't important to the client (or visible for that matter). I'll try
to make that more obvious.

Defaults are a good idea.

Justin

On Thu, Dec 19, 2013 at 12:21 PM, Konrad Windszus <konra...@gmx.de> wrote:
> HI Justin,
> thank a lot for that. I am assuming a lot of developers were waiting for just 
> that. Could you extend the wiki page with an example on how the model bean 
> should then be used from within the view (i.e. the JSP) and also some words 
> about the scope of one instance?
> One very good addition to the annotations would probably be a default value 
> in case there is nothing reasonable to be injected (very useful for resource 
> values which are not yet set).
> Thanks,
> Konrad
>
> Am 19.12.2013 um 18:07 schrieb Justin Edelson <jus...@justinedelson.com>:
>
>> Hi,
>> I've published a page to the wiki about a concept I've been working on
>> to consolidate the various appproaches I have seen in the wild to
>> model object creation. I'm calling this YAMF for now, although ideally
>> we'll just call it Sling Models :)
>>
>> Without repeating the whole contents of the wiki page, at a high
>> level, this is a purely annotation driven approach supporting both
>> classes and interfaces. Your model class simply needs to declare from
>> which other classes it can be adapted:
>>
>> @Model(adaptables=Resource.class)
>>
>> And then annotate the fields (for classes) and methods (for
>> interfaces) which need injection:
>>
>> @Inject
>> private String propertyName;
>>
>> You can inject properties, OSGi services, request attributes, and
>> entries from SlingBindings.
>>
>> New injector types can be created through an SPI.
>>
>> Additional annotations are supported for special cases:
>>
>> @Optional - mark a field/method as optional.
>> @Filter - provide a filter (i.e. for OSGi services)
>> @Named - specify a name (other than the default field/method name) to
>> use for the inejction lookup.
>>
>> More detail can be found here:
>> https://cwiki.apache.org/confluence/display/SLING/YAMF+-+Yet+Another+Model+Factory
>>
>> The working code is up in my whiteboard:
>> https://svn.apache.org/repos/asf/sling/whiteboard/justin/yamf/
>>
>> Look forward to your feedback.
>>
>> Regards,
>> Justin
>

Reply via email to