Taming Jcr With Sling

6,058
-1

Published on

Slides of our talk at http://www.openexpo.ch, September 2008

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
6,058
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
99
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Taming Jcr With Sling

  1. 1. Taming content repositories with Apache Sling Bertrand Delacrétaz, Senior R&D Developer Michael Marth, Technology Evangelist Day Software, www.day.com OpenExpo 2008, Winterthur, September 25th Slides revision: 2008-09-24 Slides design: David Nuescheler Technology Presentation 1 mercredi, 24 septembre 2008 1
  2. 2. Taming Content Repositories Web Development The Web vs. JCR - Intro Blog in 15 minutes silve r So what? mercredi, 24 septembre 2008 2
  3. 3. Intro to JCR JCR = Java Content Repository API JSR-170 / JSR283 - silve r Everything Is Content - and JCR manages it as trees of Nodes and Properties, using rich data types. mercredi, 24 septembre 2008 3
  4. 4. What’s JCR? gpoJNTM `çåíÉåí=oÉéçëáíçêó=Ñçê= g~î~qj=íÉÅÜåçäçÖó=^mf péÉÅJiÉ~ÇW a~ó=pçÑíï~êÉ pí~íìëW= cáå~ä=oÉäÉ~ëÉ=NTJàìåJOMMR bñéÉêí=dêçìéW mercredi, 24 septembre 2008 4
  5. 5. What’s JCR? gpoJNTM gpoJOUP `çåíÉåí=oÉéçëáíçêó=Ñçê= g~î~qj=íÉÅÜåçäçÖó=^mf=îOKM péÉÅJiÉ~ÇW a~ó=pçÑíï~êÉ pí~íìëW= mìÄäáÅ=oÉîáÉï=`äçëÉÇ=ëÉéJOMMT bñéÉêí=dêçìéW mercredi, 24 septembre 2008 5
  6. 6. What’s JCR? “The API should be a standard, implementation independent, way to access content bi-directionally on a granular level to a content repository.” ? mercredi, 24 septembre 2008 6
  7. 7. Best of both worlds. data base file s ys t e m hier- integ archi rity structu re es read streams tx write access query locking control multi- value un-structured obser- versioning “full-text” sort vation order content repo sit or y mercredi, 24 septembre 2008 7
  8. 8. Known compliant Repositories * using third party connector * * Exo Microsoft Apache Jackrabbit Oracle XML DB ECMS Platform Sharepoint OpenText Livelink * Day CRX IBM FileNet P8 Xythos Repository Alfresco ECM Vignette V7 * * any ors ow mvendd? H S e Interwoven +hund DBMou ne R do y r s Repository IBM CM EMC Documentum regiede of TCKs st red mercredi, 24 septembre 2008 8
  9. 9. Some known JCR Applications Fast BEA Portal Sun Oracle Portal Enterprise Search JBoss Portal Interface 21 OpenPortal Day Communique Spring Framework magnolia WCMS DAM Apache Sling Day Communique Alfresco ECMS Mindquarry Collab Collaboration Apache Tapestry QSLabs Apache Compliance Day Communiqué Cocoon WCMS IBM FileNet Artifactory medic-2-medic WebSiteManager Apache James Maven Proxy mapofmedicine Exo ECMS Platform TYPO3 GX WebManager v5.0 WCM InfoQ Hippo Liferay Nuxeo ECM Online Community CMS Enterprise Portal Jahia Sakai Percussion Framework E-learning Rhythmix QuickWCM Sourcemix WCMS Lutece Sourcemix mercredi, 24 septembre 2008 Portal 9
  10. 10. JCR code excerpt Repository repository = new TransientRepository(); Session session = repository.login(...); / Create content / Node root = session.getRootNode(); Node hello = root.addNode(quot;helloquot;); Node world = hello.addNode(quot;worldquot;); world.setProperty(quot;messagequot;, quot;Hello, World!quot;); session.save(); / Retrieve content / Node node = root.getNode(quot;hello/worldquot;); print(node.getPath()); print(node.getProperty(quot;messagequot;).getString()); mercredi, 24 septembre 2008 10
  11. 11. Sling builds on top of JCR Scriptable applications layer on top of JCR OSGi-based industrial-strength framework Simple, powerful, JCR inside Runs on Apache Jackrabbit by default http:/ /incubator.apache.org/sling mercredi, 24 septembre 2008 11
  12. 12. REST over JCR REST -> Roy T. Fielding scheler JCR: David Nue 2005 rele a 1.0 r v ele ased sed y 162 p 2k +300 pages ages mercredi, 24 septembre 2008 12
  13. 13. Reclaiming the web. Sling URL decomposition. /cars/audi/s4.details.html Content ...selects a Repository epository Path R particular scrip t mercredi, 24 septembre 2008 13
  14. 14. Sling architecture HTTP debugger filesystem browser standard custom servlets WebDAV Sling OSGi servlets and components server console javascript resource servlet/script OSGi bundles JSR 223 JSP Ruby resolution resolution scripting OSGi framework Velocity etc.. (Apache Felix) OSGi webapp JSR-170 API JCR repository mercredi, 24 septembre 2008 14
  15. 15. A Sling-based blog 282 lines of code 100% scripted, no tools required besides Sling Simple, modular code structure Promotes RESTful thinking mercredi, 24 septembre 2008 15
  16. 16. Sling blog scripts admin.esp 56 lines - admin page (.admin.html) header.esp 7 lines - <head> generation (sling.include) html.esp 75 lines - html rendering of a post (.html) list.esp 60 lines - list of posts (.list.html) menu.esp 18 lines - home/admin/new (sling.include) post.esp 39 lines - “new post” page (.post.html) xml.esp 27 lines - RSS feed (.xml) TOTAL 282 lines (including whitespace/comments) mercredi, 24 septembre 2008 16
  17. 17. Creating content (post.esp) <form method=quot;POSTquot; action=quot;/content/myblog/posts/*quot;> <p><label>Title</label> <input name=quot;titlequot; type=quot;textquot;/></p> <p><p><label>Body</label> <textarea name=quot;posttextquot; cols=quot;40quot; rows=quot;5quot;> <input name=quot;:redirectquot; type=quot;hiddenquot; value=quot;/content/myblog/posts.admin.htmlquot;/> <input type=quot;submitquot; value=quot;Postquot;> </form> mercredi, 24 septembre 2008 17
  18. 18. Rendering content (html.esp) <html> <% sling.include(quot;/content/myblog.header.htmlquot;) %> <body> <h2> <%=currentNode.title %> </h2> <% var a = currentNode.getNode(quot;attachmentsquot;).getNodes() ; for(i in a) { var attachmentNode = a[i]; ... %> } </body> </html> mercredi, 24 septembre 2008 18
  19. 19. Sling blog demo mercredi, 24 septembre 2008 19
  20. 20. Can I have fries with that? How do we add functionality that is not easily scriptable? Example: thumbnails generated in Java code, by observing the repository for new files. mercredi, 24 septembre 2008 20
  21. 21. JCR observation String[] nodeTypes = { quot;nt:filequot; }; boolean isDeep = true; observationManager.addEventListener( this, Event.NODE_ADDED | Event.NODE_REMOVED, quot;/content/myblog/postsquot;, isDeep, ...types); ... public void onEvent( EventIterator eventIterator) { ... } mercredi, 24 septembre 2008 21
  22. 22. Thumbnails bundle demo mercredi, 24 septembre 2008 22
  23. 23. Conclusions JCR rocks - and everything is content! Sling makes JCR easy and fun. A good JCR content model is key. Join the fun at incubator.apache.org/sling! mercredi, 24 septembre 2008 23
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×