Srom

381 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
381
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Srom

  1. 1. SlingResource - ObjectMapper<br />
  2. 2. Agenda<br />Why?<br />How?<br />
  3. 3. Why?<br />Because the old existing mapper ...<br />Requires writing a lot of code to access a single resource (dto, model, presenter)<br />Requires writing a lot of code to get another resource, e.g. configuration, child, referenced node<br />Is very slow – fields, annotations<br />Not extensible<br />
  4. 4. How to use?<br />POJO with annotations<br />@Dto(resourceType=„/.../ArticleTeaser”)<br />Class ArticleTeaser {<br />@Property <br />private String name;<br />@ValueReference <br /> private Article fullArticle;<br />@AbsoluteReference(path=„/configuration/commons”) <br />private Article[] similarArticles;<br />@ChildReference<br />private Box[] boxes;<br /> // getters / setters<br />}<br />
  5. 5. How to use?<br />No dto/model distinction needed<br />Default values<br />Logic<br />Validation<br />No presenter needed<br />Just a JSP tag<br />
  6. 6. How to use?<br />Access by DAO<br />Article article = dao.getModel(„/xyz/abc”, Article.class);<br />
  7. 7. Integration<br />DAO is OSGI component<br />Accessible using DI<br />Accessible using getSling().getService(...)<br />Adaptable<br />Article article = resource.adaptTo(Article.class);<br />
  8. 8. How to use?<br />Simplest<br />Not so simple<br />Validation<br /><cog:model var=„model”/><br /><cog:model var=„model” clazz=„Article” /><br /><cog:model var=„model” ><br /> <h1>${model.title}</h1><br /></cog:model><br />
  9. 9. Extensible<br />Custom mappers<br />@Image<br />@Property<br />private String logo;<br />
  10. 10. Performance<br />Mapper configuration on application start<br />Field/annotation caching<br />15x performance gain compared to current mapper<br />Lazy loading<br />Referenced models loaded on demand<br />Session cache<br />
  11. 11. Performance test<br />
  12. 12. Thank you<br />

×