SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
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

Contenu connexe

En vedette

En vedette (6)

Open Innovation means Open Source
Open Innovation means Open SourceOpen Innovation means Open Source
Open Innovation means Open Source
 
It's just a Web server - a plea for simplicity
It's just a Web server - a plea for simplicityIt's just a Web server - a plea for simplicity
It's just a Web server - a plea for simplicity
 
Life in Open Source Communities, ApacheCon US 2009
Life in Open Source Communities, ApacheCon US 2009Life in Open Source Communities, ApacheCon US 2009
Life in Open Source Communities, ApacheCon US 2009
 
Tales from the OSGi trenches
Tales from the OSGi trenchesTales from the OSGi trenches
Tales from the OSGi trenches
 
Open Source Tools Are Good For You!
Open Source Tools Are Good For You!Open Source Tools Are Good For You!
Open Source Tools Are Good For You!
 
Open-Source Collaboration Tools are Good for You - 2009 edition
Open-Source Collaboration Tools are Good for You - 2009 editionOpen-Source Collaboration Tools are Good for You - 2009 edition
Open-Source Collaboration Tools are Good for You - 2009 edition
 

Similaire à Taming Jcr With Sling

Crypto With OpenSSL
Crypto With OpenSSLCrypto With OpenSSL
Crypto With OpenSSL
Zhi Guan
 
Millions quotes per second in pure java
Millions quotes per second in pure javaMillions quotes per second in pure java
Millions quotes per second in pure java
Roman Elizarov
 
Upgrading to System Verilog for FPGA Designs, Srinivasan Venkataramanan, CVC
Upgrading to System Verilog for FPGA Designs, Srinivasan Venkataramanan, CVCUpgrading to System Verilog for FPGA Designs, Srinivasan Venkataramanan, CVC
Upgrading to System Verilog for FPGA Designs, Srinivasan Venkataramanan, CVC
FPGA Central
 

Similaire à Taming Jcr With Sling (20)

µjax in 30 minutes (for Stockholm)
µjax in 30 minutes (for Stockholm)µjax in 30 minutes (for Stockholm)
µjax in 30 minutes (for Stockholm)
 
µjax in 30 minutes (for Stockholm)
µjax in 30 minutes (for Stockholm)µjax in 30 minutes (for Stockholm)
µjax in 30 minutes (for Stockholm)
 
µjax in 30 minutes
µjax in 30 minutesµjax in 30 minutes
µjax in 30 minutes
 
Open stack in sina
Open stack in sinaOpen stack in sina
Open stack in sina
 
Crypto With OpenSSL
Crypto With OpenSSLCrypto With OpenSSL
Crypto With OpenSSL
 
Millions quotes per second in pure java
Millions quotes per second in pure javaMillions quotes per second in pure java
Millions quotes per second in pure java
 
Web Content Management And Agile
Web Content Management And AgileWeb Content Management And Agile
Web Content Management And Agile
 
Valtech Days 2009 Paris Presentation: WCM in 2010 and an intro to CQ5
Valtech Days 2009 Paris Presentation: WCM in 2010 and an intro to CQ5Valtech Days 2009 Paris Presentation: WCM in 2010 and an intro to CQ5
Valtech Days 2009 Paris Presentation: WCM in 2010 and an intro to CQ5
 
ElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech Talks
ElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech TalksElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech Talks
ElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech Talks
 
Agile Edge Valtech
Agile Edge ValtechAgile Edge Valtech
Agile Edge Valtech
 
Bangalore cloudstack user group
Bangalore cloudstack user groupBangalore cloudstack user group
Bangalore cloudstack user group
 
Upgrading to System Verilog for FPGA Designs, Srinivasan Venkataramanan, CVC
Upgrading to System Verilog for FPGA Designs, Srinivasan Venkataramanan, CVCUpgrading to System Verilog for FPGA Designs, Srinivasan Venkataramanan, CVC
Upgrading to System Verilog for FPGA Designs, Srinivasan Venkataramanan, CVC
 
Eb07 Day Communiqué Web Content Management En
Eb07 Day Communiqué Web Content Management EnEb07 Day Communiqué Web Content Management En
Eb07 Day Communiqué Web Content Management En
 
Intro to Cloudstack
Intro to CloudstackIntro to Cloudstack
Intro to Cloudstack
 
Developing and Deploying Java applications on the Amazon Elastic Compute Clou...
Developing and Deploying Java applications on the Amazon Elastic Compute Clou...Developing and Deploying Java applications on the Amazon Elastic Compute Clou...
Developing and Deploying Java applications on the Amazon Elastic Compute Clou...
 
Introducing CQ 5.1
Introducing CQ 5.1Introducing CQ 5.1
Introducing CQ 5.1
 
Windows Azure Interoperability
Windows Azure InteroperabilityWindows Azure Interoperability
Windows Azure Interoperability
 
Apache CloudStack AlpesJUG
Apache CloudStack AlpesJUGApache CloudStack AlpesJUG
Apache CloudStack AlpesJUG
 
Building FOSS clouds
Building FOSS cloudsBuilding FOSS clouds
Building FOSS clouds
 
CloudStack for Java User Group
CloudStack for Java User GroupCloudStack for Java User Group
CloudStack for Java User Group
 

Plus de Bertrand Delacretaz

Plus de Bertrand Delacretaz (20)

VanillaJS & the Web Platform, a match made in heaven?
VanillaJS & the Web Platform, a match made in heaven?VanillaJS & the Web Platform, a match made in heaven?
VanillaJS & the Web Platform, a match made in heaven?
 
Surviving large online communities with conciseness and clarity
Surviving large online communities with conciseness and clarity Surviving large online communities with conciseness and clarity
Surviving large online communities with conciseness and clarity
 
Repoinit: a mini-language for content repository initialization
Repoinit: a mini-language for content repository initializationRepoinit: a mini-language for content repository initialization
Repoinit: a mini-language for content repository initialization
 
The Moving House Model, adhocracy and remote collaboration
The Moving House Model, adhocracy and remote collaborationThe Moving House Model, adhocracy and remote collaboration
The Moving House Model, adhocracy and remote collaboration
 
GraphQL in Apache Sling - but isn't it the opposite of REST?
GraphQL in Apache Sling - but isn't it the opposite of REST?GraphQL in Apache Sling - but isn't it the opposite of REST?
GraphQL in Apache Sling - but isn't it the opposite of REST?
 
Open Source Changes the World!
Open Source Changes the World!Open Source Changes the World!
Open Source Changes the World!
 
How to convince your left brain (or manager) to follow the Open Source path t...
How to convince your left brain (or manager) to follow the Open Source path t...How to convince your left brain (or manager) to follow the Open Source path t...
How to convince your left brain (or manager) to follow the Open Source path t...
 
L'Open Source change le Monde - BlendWebMix 2019
L'Open Source change le Monde - BlendWebMix 2019L'Open Source change le Monde - BlendWebMix 2019
L'Open Source change le Monde - BlendWebMix 2019
 
Shared Neurons - the Secret Sauce of Open Source communities?
Shared Neurons - the Secret Sauce of Open Source communities?Shared Neurons - the Secret Sauce of Open Source communities?
Shared Neurons - the Secret Sauce of Open Source communities?
 
Sling and Serverless, Best Friends Forever?
Sling and Serverless, Best Friends Forever?Sling and Serverless, Best Friends Forever?
Sling and Serverless, Best Friends Forever?
 
Serverless - introduction et perspectives concrètes
Serverless - introduction et perspectives concrètesServerless - introduction et perspectives concrètes
Serverless - introduction et perspectives concrètes
 
State of the Feather - ApacheCon North America 2018
State of the Feather - ApacheCon North America 2018State of the Feather - ApacheCon North America 2018
State of the Feather - ApacheCon North America 2018
 
Karate, the black belt of HTTP API testing?
Karate, the black belt of HTTP API testing?Karate, the black belt of HTTP API testing?
Karate, the black belt of HTTP API testing?
 
Open Source at Scale: the Apache Software Foundation (2018)
Open Source at Scale: the Apache Software Foundation (2018)Open Source at Scale: the Apache Software Foundation (2018)
Open Source at Scale: the Apache Software Foundation (2018)
 
They don't understand me! Tales from the multi-cultural trenches
They don't understand me! Tales from the multi-cultural trenchesThey don't understand me! Tales from the multi-cultural trenches
They don't understand me! Tales from the multi-cultural trenches
 
Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)
Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)
Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)
 
Project and Community Services the Apache Way
Project and Community Services the Apache WayProject and Community Services the Apache Way
Project and Community Services the Apache Way
 
La Fondation Apache - keynote au Paris Open Source Summit 2017
La Fondation Apache - keynote au Paris Open Source Summit 2017La Fondation Apache - keynote au Paris Open Source Summit 2017
La Fondation Apache - keynote au Paris Open Source Summit 2017
 
Asynchronous Decision Making - FOSS Backstage 2017
Asynchronous Decision Making - FOSS Backstage 2017Asynchronous Decision Making - FOSS Backstage 2017
Asynchronous Decision Making - FOSS Backstage 2017
 
Building an Apache Sling Rendering Farm
Building an Apache Sling Rendering FarmBuilding an Apache Sling Rendering Farm
Building an Apache Sling Rendering Farm
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Dernier (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Taming Jcr With Sling

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