Taming Jcr With Sling
Upcoming SlideShare
Loading in...5
×
 

Taming Jcr With Sling

on

  • 7,967 views

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

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

Statistics

Views

Total Views
7,967
Views on SlideShare
7,595
Embed Views
372

Actions

Likes
3
Downloads
98
Comments
0

6 Embeds 372

http://dev.day.com 254
http://grep.codeconsult.ch 111
http://www.slideshare.net 3
http://alm.handysoft.co.kr 2
http://www.techgig.com 1
http://cmc.l50sw.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Taming Jcr With Sling Taming Jcr With Sling Presentation Transcript

  • 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
  • Taming Content Repositories Web Development The Web vs. JCR - Intro Blog in 15 minutes silve r So what? mercredi, 24 septembre 2008 2
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • Sling blog demo mercredi, 24 septembre 2008 19
  • 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
  • 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
  • Thumbnails bundle demo mercredi, 24 septembre 2008 22
  • 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