Rapid JCR applications development with Sling

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    3 Favorites & 1 Group

    Rapid JCR applications development with Sling - Presentation Transcript

    1. Rapid JCR applications development with Apache Sling Bertrand Delacrétaz Senior R&D Developer, Day Software, www.day.com Member and Director, ASF bdelacretaz@apache.org blog at http:/ /grep.codeconsult.ch twitter: @bdelacretaz Slides revision: 2009-03- 20 Slides theme design: David Nuescheler Wednesday, March 25, 2009
    2. Rapid JCR applications development with Apache Sling Bertrand Delacrétaz Senior R&D Developer, Day Software, www.day.com Member and Director, ASF bdelacretaz@apache.org blog at http:/ /grep.codeconsult.ch twitter: @bdelacretaz Slides revision: 2009-03- 20 Slides theme design: David Nuescheler is thi busy s slide enou gh? Wednesday, March 25, 2009
    3. Intro to JCR JCR = Java Content Repository API JSR-170 / JSR283 - Everything Is Content - and JCR manages it as trees of Nodes and Properties, using rich data types. Wednesday, March 25, 2009
    4. 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. Wednesday, March 25, 2009
    5. What’s JCR? JSR-170 Content Repository for JavaTM technology API Spec-Lead: Day Software Status: Final Release 17-jun-2005 Expert Group: Wednesday, March 25, 2009
    6. What’s JCR? JSR-170 JSR-283 Content Repository for JavaTM technology API v2.0 Spec-Lead: Day Software Status: Public Review Closed sep-2007 Expert Group: Wednesday, March 25, 2009
    7. Wednesday, March 25, 2009
    8. What’s JCR? Wednesday, March 25, 2009
    9. 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.” Wednesday, March 25, 2009
    10. 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.” ? Wednesday, March 25, 2009
    11. 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.” ? Wednesday, March 25, 2009
    12. Best of both worlds. data base file s ys t e m hier- archi integ rity re es structu read streams tx write access query locking control multi- value ning obser- versio un-structured “full-text” sort vation order content repo sit or y Wednesday, March 25, 2009
    13. Best of both worlds. data base file s ys t e m hier- archi integ rity re es structu read streams tx write access query locking control multi- value ning obser- versio un-structured “full-text” sort vation order content repo sit or y Wednesday, March 25, 2009
    14. Known compliant Repositories Wednesday, March 25, 2009
    15. Known compliant Repositories * using third party connector * * Apache Exo Microsoft OpenText Jackrabbit Oracle XML DB ECMS Platform Sharepoint Livelink * Xythos Day CRX IBM FileNet P8 Repository Alfresco ECM Vignette V7 * * any ors ow mvendd? H S e +hun dre DBMou ne R do y Interwoven EMC TCKsds of regis Repository IBM CM Documentum tered Wednesday, March 25, 2009
    16. Some known JCR Applications Wednesday, March 25, 2009
    17. Some known JCR Applications Fast Enterprise BEA Portal Sun Oracle Portal Interface 21Search OpenPortal JBoss Portal Day Spring Communique Framework DAM Day magnolia WCMS Apache Sling Communique Alfresco ECMS Mindquarry ApacheCollab Collaboration Tapestry QSLabs Day Apache Compliance Communiqué IBM FileNet Cocoon WCMS Artifactory medic-2-medic WebSiteManage r Apache James Maven Proxy mapofmedicine Exo GX ECMS Platform TYPO3 WebManager v5.0 WCM InfoQ Liferay Online Hippo Enterprise Nuxeo ECM Community CMS Portal Jahia Sakai Percussion Framework E-learning Rhythmix QuickWCM Sourcemix WCMS Lutece Sourcemix Portal Wednesday, March 25, 2009
    18. Some known JCR Applications Fast Enterprise BEA Portal Sun Oracle Portal Interface 21Search OpenPortal JBoss Portal Day Spring Communique Framework DAM Day magnolia WCMS Apache Sling Communique Alfresco ECMS Mindquarry ApacheCollab Collaboration Tapestry QSLabs Day Apache Compliance Communiqué IBM FileNet Cocoon WCMS Artifactory medic-2-medic WebSiteManage r Apache James Maven Proxy mapofmedicine Exo GX ECMS Platform TYPO3 WebManager v5.0 WCM InfoQ Liferay Online Hippo Enterprise Nuxeo ECM Community CMS Portal Jahia Sakai Percussion Framework E-learning Rhythmix QuickWCM Sourcemix WCMS Lutece Sourcemix Portal Wednesday, March 25, 2009
    19. JCR code excerpt Repository repository = new TransientRepository(); Session session = repository.login(...); / Create content / Node root = session.getRootNode(); Node hello = root.addNode(\"hello\"); Node world = hello.addNode(\"world\"); world.setProperty(\"message\", \"Hello, World!\"); session.save(); / Retrieve content / Node node = root.getNode(\"hello/world\"); print(node.getPath()); print(node.getProperty(\"message\").getString()); Wednesday, March 25, 2009
    20. On to Sling Wednesday, March 25, 2009
    21. 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 Wednesday, March 25, 2009
    22. 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 join t he fun! Wednesday, March 25, 2009
    23. Sling == REST over JCR Wednesday, March 25, 2009
    24. Sling == 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 Wednesday, March 25, 2009
    25. Reclaiming the web. Sling URL decomposition. /cars/audi/s4.details.html Wednesday, March 25, 2009
    26. Reclaiming the web. Sling URL decomposition. /cars/audi/s4.details.html Repository Wednesday, March 25, 2009
    27. Reclaiming the web. Sling URL decomposition. /cars/audi/s4.details.html Content Repository epository Path R Wednesday, March 25, 2009
    28. Reclaiming the web. Sling URL decomposition. /cars/audi/s4.details.html Content Repository epository Path R Wednesday, March 25, 2009
    29. Reclaiming the web. Sling URL decomposition. /cars/audi/s4.details.html Content ...selects a Repository epository Path R particular scrip t Wednesday, March 25, 2009
    30. 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 Wednesday, March 25, 2009
    31. Sling architecture HTTP sling.js debugger filesystem browser utilit y POST, V json GE T WebDA access 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 ESP de se r ver-si t ip JSR-170 API javascr JCR repository Wednesday, March 25, 2009
    32. A minimalone .esp script blog Consisting of Sling cat /Volumes/localhost/apps/blog/blog.esp | wc -l 54 Wednesday, March 25, 2009
    33. from e code : ge t th ay.com dev.d url.com/ /tiny 6 ht tp:/ gblog4 slin A minimalone .esp script blog Consisting of Sling cat /Volumes/localhost/apps/blog/blog.esp | wc -l 54 Wednesday, March 25, 2009
    34. Sling POST servlet # POST to Sling curl -F title=hello http://localhost:8888/foo -> 200 OK # GET created node in json format curl http:/ /localhost:8888/foo.tidy.json { \"jcr:primaryType\": \"nt:unstructured\", \"title\": \"hello\" } Wednesday, March 25, 2009
    35. Sling POST servlet # POST to Sling curl -F title=hello http://localhost:8888/foo -> 200 OK POST se t e ters s # GET created node in json format param opertie curl http:/ /localhost:8888/foo.tidy.json node pr { \"jcr:primaryType\": \"nt:unstructured\", \"title\": \"hello\" } Wednesday, March 25, 2009
    36. blog step 1: create content ! <form method=\"POST\"> ! Title: ! <input type=\"text\" name=\"title\" style=\"width:100%\"/> ! ! Text: ! <textarea style=\"width:100%\" name=\"text\"></textarea> ! ! <input type=\"submit\" value=\"save\"/> ! ! <input type=\"hidden\" name=\":redirect\" value=\"*\"/> ! </form> Wednesday, March 25, 2009
    37. blog step 1: create content ! <form method=\"POST\"> ! Title: ! <input type=\"text\" name=\"title\" style=\"width:100%\"/> ! ! Text: ! <textarea style=\"width:100%\" name=\"text\"></textarea> ! ! <input type=\"submit\" value=\"save\"/> ! ! <input type=\"hidden\" name=\":redirect\" value=\"*\"/> ! </form> dri ve fields t Form onten the c el mod Wednesday, March 25, 2009
    38. blog step 2: retrieve content <script src=\"/system/sling.js\"></script>! <form method=\"POST\"> ... </form> <!-- initialize form fields from current node values --> <script>Sling.wizard();</script> Wednesday, March 25, 2009
    39. blog step 2: retrieve content <script src=\"/system/sling.js\"></script>! <form method=\"POST\"> ... </form> <!-- initialize form fields from current node values --> <script>Sling.wizard();</script> U(D) Inst ant CR Wednesday, March 25, 2009
    40. blog step 3: navigation <ul> <li> <a href=\"/content/blog/*\"> [Create new post]</a> </li> ! <script> ! var posts = Sling.getContent(\"/content/blog\", 2); ! for(var post in posts) { ! ! document.write( \"<li><a href=’” + post + \"'>\" + posts[post].title + \"</a></li>\"); ! } ! </script> </ul> Wednesday, March 25, 2009
    41. we got a blog! html form + Sling.wizard() + Sling.getContent() Wednesday, March 25, 2009
    42. The ESP blog sample ESP scripting + java + javascript OSGi bundle, initial content, WebDAV, observation, RAD Wednesday, March 25, 2009
    43. The ESP blog sample ESP scripting + java + javascript OSGi bundle, initial content, WebDAV, observation, RAD mples ng/sa / der sli rl.com de un inyu Co ht tp:/ t logesp / slingb Wednesday, March 25, 2009
    44. ESP blog in action create retrieve thumbnails update Wednesday, March 25, 2009
    45. ESPblog demo Wednesday, March 25, 2009
    46. ESP blog source files admin.esp pom.xml edit.esp ThumbnailGeneratorService.java html.esp ThumbnailGeneratorServiceImpl.java list.esp espblog.css menu.esp sling-logo.png xml.esp (RSS feed) constants.esp header.esp Wednesday, March 25, 2009
    47. ESP blog source files admin.esp pom.xml edit.esp ThumbnailGeneratorService.java html.esp ThumbnailGeneratorServiceImpl.java list.esp espblog.css menu.esp sling-logo.png xml.esp (RSS feed) constants.esp source log re s to espb oint header.esp t ype p ripts those sc Wednesday, March 25, 2009
    48. ESP blog content structure JSON dump WebDAV view Wednesday, March 25, 2009
    49. <% ESP blog edit script pageTitle = currentNode.title; load(\"header.esp\"); %> <body> <form method=\"POST\" action=\"<%= currentNode %>\"> <p><label>Title</label> <input name=\"title\" type=\"text\" value=\"<%= currentNode.title %>\"></p> ... <input type=\"hidden\" name=\"created\"/> <input name=\":redirect\" type=\"hidden\" value=\"/content/espblog/posts.admin.html\"/> <input type=\"submit\" value=\"Post\" class=\"button\"> </form> ... Wednesday, March 25, 2009
    50. ESP blog thumbnails: OSGi service /** * Observe the espblog content for changes, and generate * thumbnails when images are added. * * maven-scr-plugin uses annotations to generate the OSGi * Declarative Services XML configuration files * @scr.service * @scr.component immediate=\"true\" * */ public class ThumbnailGeneratorServiceImpl implements ThumbnailGeneratorService, EventListener { Wednesday, March 25, 2009
    51. ESP blog thumbnails: observation /** @scr.reference (framework injects it automatically) */ private SlingRepository repository; /** called by framework when service is activated */ protected void activate(ComponentContext context) { Session s = repository.loginAdministrative(null); / Listen for nt:file NODE_ADDED repository events / ObservationManager m = s.getWorkspace().getObservationManager(); ! String[] types = { \"nt:file\" }; ! m.addEventListener( this, Event.NODE_ADDED, contentPath, ...); Wednesday, March 25, 2009
    52. ESP blog thumbnails: NODE_ADDED /** Called by JCR Observation manager for events that this * EventListener registered for */ public void onEvent(EventIterator it) { while (it.hasNext()) { Event event = it.nextEvent(); if (event.getType() == Event.NODE_ADDED && !(event.getPath().contains(\"thumbnails\"))) { String p = event.getPath(); Node n = session.getRootNode().getNode(p); createThumbnails(addedNode); } } ... Wednesday, March 25, 2009
    53. We got a typical Sling application! JCR features: WebDAV, observation, nt:unstructured. Sling goodies: simple script mappings (BYOL), POST servlet, RESTful interface. OSGi bundle, code + initial content, Maven plugins. Wednesday, March 25, 2009
    54. We got a typical Sling application! JCR features: WebDAV, observation, nt:unstructured. Sling goodies: simple script mappings (BYOL), POST servlet, RESTful interface. ource blog s under ESP found es ode is ampl OSGi bundle, code + initial c sling/s content, Maven plugins. Wednesday, March 25, 2009
    55. Where is Sling going? Wednesday, March 25, 2009
    56. Where is Sling going? (aka conclusion) First web framework designed for JCR. Embrace the web, act like a very clever web server! Intelligent HTTP/JSON storage? OSGi, organic app growth. Growing community, graduate in 2009? http://incubator.apache.org/sling http://dev.day.com http://contentcentric.org/ Wednesday, March 25, 2009
    57. Where is Sling going? (aka conclusion) First web framework designed for JCR. Embrace the web, act like a very clever web server! Intelligent HTTP/JSON storage? not a web OSGi, organic app growth. “Sling is s ation a applic k, it’s fram e wor Growing community, graduate ame work” in 2009? w eb f r http://incubator.apache.org/sling http://dev.day.com join t hehttp://contentcentric.org/ fun! Wednesday, March 25, 2009

    + bdelacretazbdelacretaz, 8 months ago

    custom

    2447 views, 3 favs, 5 embeds more stats

    Slides of my "Rapid JCR applications development wi more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 2447
      • 2299 on SlideShare
      • 148 from embeds
    • Comments 0
    • Favorites 3
    • Downloads 57
    Most viewed embeds
    • 142 views on http://dev.day.com
    • 3 views on http://wiki.vantage.com
    • 1 views on http://feeds.feedburner.com
    • 1 views on http://localhost:4502
    • 1 views on http://72.14.221.132

    more

    All embeds
    • 142 views on http://dev.day.com
    • 3 views on http://wiki.vantage.com
    • 1 views on http://feeds.feedburner.com
    • 1 views on http://localhost:4502
    • 1 views on http://72.14.221.132

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Groups / Events