SlideShare una empresa de Scribd logo
1 de 51
Descargar para leer sin conexión
Carsten Ziegeler | Day Management AG


JCR – Java Content
Repositories
cziegeler@apache.org
About
• Member of the ASF
     – Sling, Felix, Cocoon, Portals, Sanselan,
       Excalibur, Incubator
     – PMC: Felix, Portals, Sling, Incubator,
       Excalibur (Chair)
• RnD Team at Day Software
• Article/Book Author, Technical
  Reviewer
• JSR 286 Spec Group (Portlet API 2.0)

 2
Motivation
• Tried and trusted NOSQL solution
• Standard Java API
     – First spec released in May 2005
     – Various implementations
     – Several products and solutions
• Open Source Implementation
     – 1.0 Release in April 2006
• Think about your data storage use
  cases
     – JCR might help
 3
Agenda
•   JCR and Apache Jackrabbit
•   Basic Content Modeling
•   References and Search
•   Advanced Features
•   Summary and Questions




    4
(Nearly) Everthing is Content
• Application Domain Specific Content
• Presentation Support (HTML, CSS,
    JavaScript, Images)
• Documentation, Translations
• ...




 5
Content Silos without JCR
• Structured content
     – Usually schema based
• Unstructured content
• Large data (images, movies etc.)
• Different storages for each use case




 6
Content Repository I
• Features of an RDBMS
     – Structure, integrity
     – Query, transactions
• Features of a filesystem
     – Hierarchy, binaries
     – Locking, access control
• All the other good stuff
     – Observation, versioning
     – Unstructured
     – Multi values, sort order, full text
• Single repository for all content!
 7
Content Repository II
• Hierarchical content
     – Nodes and properties
• Structured
     – Nodetypes and typed properties
• And/or unstructured
• Fine and coarse-grained
• Single repository for all content!



 8
Sample Application: Slingshot
• Digital Asset Management
     –   Hierarchical storage of pictures
     –   Upload
     –   Tagging
                                     Poor man's flickr...
     –   Searching
     –   Automatic thumbnail generation




 9
Slingshot Content Structure


                      Travel              Family


                 Europe                            Weddings


     Amsterdam            Basel                         2008


     2007                      City                 Photo      Photo


      Photo                           Photo



10
Facts About Slingshot
• Java web application
• Uses Apache Sling as web framework
• Content repository managed by
    Apache Jackrabbit
• Interaction through the JCR API




11
JSR 170: Content Repository
     for JavaTM technology API
• (Java) Standard – Version 1.0
     – Supported by many vendors
     – Used by many products and projects
     – Several open source solutions
• How do you connect to a CR?
• How do you interact with a CR?



12
JSR 283 : JCR 2.0 is final
• New features
• Improved specification
     – Cleaned up API (deprecation)
     – Revised specification document
• Binary compatible
     – JSR 170 apps run without modification




13
The Repository Model
•    Repository: one (or more) workspaces
•    Workspace contains a tree of items
•    Item: Node or property
•    Nodes provide the content structure
         – May have children
• Actual data is stored as values of
  properties
• Types and namespaces!


    14
Nodes and Properties
                                                 Root


                         Travel                   Family


                    Europe        “Images from
                                  Europe“
                                                           Weddings


     Amsterdam               Basel                              2008


     2007                           City                    Photo      Photo


      Photo                                 Photo

              „Once
              upon a
              time..“



                             Properties
                                  Implementation of JCR


15
Connecting to the Repository
• JCR 2.0 provides RepositoryFactory
• Uses Service Provider Mechanism
     – META-INF/services/javax.jcr.RepositoryFactory
• Just use
     – RepositoryFactory.getRepository(null)
• Or specify connection parameters
     – RepositoryFactory.getRepository(Map)




16
Working with the Repository
• Interaction is session based
     – Assemble credentials
     – Login into workspace
Credentials myCredentials =
        new SimpleCredentials("USERID",
                             "PASSWORD".toCharArray());
Session mySession =
        repository.login(myCredentials, "WORKSPACE");




17
Traversing the Content
• Traverse the repository
      – From the root or any node

Node rootNode = mySession.getRootNode();
Node albumNode = rootNode.getNode("slingshot/albums/travel");
Node europeNode = albumNode.getNode("Europe");




 18
Retrieve a Property
• Various ways to get a property
      – Different methods for each type
      – Type conversion if possible
Property prop = albumNode.getProperty("slingshot:description");
Value value = prop.getValue();
String desc = value.getString();

value.getBoolean();
value.getStream();
value.getLong();
value.getDate();
value.getDouble();




 19
Changing Content
• Change everything you want
     –   Add/Remove nodes
     –   Add/Remove/Change properties
     –   Transient space
     –   Then save
// change
albumNode.addNode("newAlbum");
europeNode.setProperty("slingshot:description", "something");
// save...
mySession.save();

// ... or revert all changes
mySession.refresh(false);


20
Interaction Summary
• Get the repository
• Login to a workspace
     – Provides a session
• Use the session to
     – Access nodes and their properties
     – Change and save them




21
CR : Combines Advantages
                                          Single storage for
• Features of an RDBMS                    all content!
     – Structure, integrity
     – Query, transactions
• Features of a filesystem
     – Hierarchy, binaries
     – Locking, access control
• All the other good stuff
     –   Observation, versioning
     –   Unstructured
     –   Multi values, sort order, full text
     –   Import/Export (XML)
22
Apache Jackrabbit                                                               23


•    JSR 170 and 283 reference implementation
•    Apache TLP since 2006
•    Releases
          – 1.6 (JSR 170 based)
          – 2.0 Beta 2 is out
          – 2.0 Final (end of 2009)
•    Components
          – Commons, API
          – RMI, WebDAV, WebApp, JCA
          – OCM
          – And more...


                                                http://jackrabbit.apache.org/




    23
Words of Advice
• Read (or browse) the JCR spec
     – jcr-1.0.jar/jcr-2.0.jar included
• Getting started with Jackrabbit
     –   jackrabbit-webapp: Drop-in deployment
     –   First Hops: Embedded repository
     –   Take your time
     –   Think about your use cases
• Have a look at Apache Sling


24
Agenda
•    JCR and Apache Jackrabbit
•    Basic Content Modeling
•    References and Search
•    Advanced Features
•    Demo: Sample Application
•    Summary and Questions




    25
Leverage the standard node types
      • Type hierarchy             • Content
                                     hierarchy
      nt:hierarchyNode

                     nt:folder

                         nt:file

                   nt:linkedFile

      nt:unstructured




 26
Bottom-up modeling: Node types
slingshot:album > nt:folder        slingshot:tag
- slingshot:description (string)   - slingshot:description (string)
- slingshot:date (date)



slingshot:photo > nt:file
- slingshot:description (string)
- slingshot:location (string)
- slingshot:tags (string[])




27
Top-down modeling: Hierarchy


                      Travel              Family


                 Europe                            Weddings


     Amsterdam            Basel                         2008


     2007                      City                 Photo      Photo


      Photo                           Photo



28
Namespaces
• Namespaces can be used for
         – Node types
         – Node and property names
•    Single namespace per company or app
•    Reasonably unique namespace prefix
•    Prefixed names for structured content
•    Default namespace for unstructured
       content


    29
Content Modeling Advice I
• Use an application root node
     – Examples: my:content or slingshot
     – Good for searching, backup, and migration
• Avoid flat hierarchies
     – User interface complexity
• Content-driven design
     – Design your content before your appl




30
Content Modeling Advice II
• Look at existing node types (JSR 2.0)
• Make use of mixin node types
• Checkout Apache Jackrabbit wiki and
  mailing lists
     – "Davids Model"




31
David‘s Model
• Rule #1: Data First, Structure Later.
  Maybe
• Rule #2: Drive the content hierarchy,
  don‘t let it happen
• Rule #6: Files are Files are Files
• Look at
  http://wiki.apache.org/jackrabbit/Dav
  idsModel


32
Agenda
•    JCR and Apache Jackrabbit
•    Basic Content Modeling
•    References and Search
•    Advanced Features
•    Summary and Questions




    33
References with JCR



        Tags                      Album                       Favorites


 Bird          Tree          Photo                       Top 10          Picks


                                     Photo           link         link           link


                      API:
                      Node.getReferences():PropertyIterator
                      Property.getNode():Node
                      Node.setProperty(String name, Node)

34
Alternative References I
• Reference by name


     slingshot:photo > nt:file
     - slingshot:description (string)   slingshot:tag
     - slingshot:location (string)      - slingshot:description (string)
     - slingshot:tags (string[])




35
Alternative References II
• Reference by path
                                                      /

     slingshot:photo > nt:file
     - slingshot:description (string)
                                                     Tags
     - slingshot:location (string)
     - slingshot:tags (string[])
                                        /Tags/bird
                                                      bird




36
Searching
• Query API
        – Java Query Object Model
        – SQL queries
• Examples
        – SELECT * FROM slingshot:photo
             WHERE jcr:path LIKE ‘/slingshot/%’
        – ..AND slingshot:description CONTAINS
            'munich'
     API:
     Session.getWorkspace().getQueryManager():QueryManager
     QueryManager.createQuery(String stmt, String
     language):Query;
     Query.execute():QueryResult
37
Agenda
•    JCR and Apache Jackrabbit
•    Basic Content Modeling
•    References and Search
•    Advanced Features
•    Summary and Questions




    38
Observation
• Enables applications to register
  interest in events
• Monitor changes
• Act on changes

        API:
        ObservationManager:
        addEventListener(EventListener listener,
          int eventTypes,
          java.lang.String absPath, boolean isDeep,
          java.lang.String[] uuid,
          java.lang.String[] nodeTypeName, boolean noLocal)



39
Observation Events
• Describe changes to a workspace
     – Dispatched on persistent change
• Provide the path of the item
• Provide the user ID
• Only provided to sessions with
  sufficient access privileges
• Events may not be complete!
     – Example: removal of a tree of nodes


40
Event Types
• Five different types
     –   Node added
     –   Node removed
     –   Property added
     –   Property removed
     –   Property changed




41
Event Listeners
• Registered with a workspace
• Registration with optional filters
     – Like node types, paths
• Receive events for every change



             API:
             public void onEvent(EventIterator events);




42
Events Advice
• Events occur after a save
     – Modification based on events is a new
        operation
     – Such events can be filtered
• Events may not tell the complete story
     – Tree removal, copy, move
• Most common pattern
     – Node added, removed, changed



43
Staged Publishing: Versioning

                  Version store




        Staging                   Live




44
Advanced Development
• Apache Sling
     – REST based web framework
     – Powered by OSGi
        – Scripting Inside
• Apache Jackrabbit OCM
       – Map content to Java objects and vice
          versa
       – Similar to database ORMs



45
JCR 2.0 Features
• Abstract Query Model
         – Java Query Object Model / SQL
• ACL and Access Control Policies
         – Plus Retention Policies and Hold
•    Nodetype Registry
•    New Property Types and Nodetypes
•    Shareable Nodes (Graph)
•    Journalling Observation

    46
Agenda
•    JCR and Apache Jackrabbit
•    Basic Content Modeling
•    References and Search
•    Advanced Features
•    Summary and Questions




    47
And remember...
• (Nearly) everything is content
     – Application Domain Specific Content
     – Presentation Support (HTML, CSS,
        JavaScript, Images)
     – Documentation, Translations
     –…
• With observation, versioning, search...




48
Conclusion
• Content Repositories
     – Combine advantages from FS and DB
     – Add important features
     – Structure/Access your data the way
        your domain requires it
     – Single repository for all your content!
• JCR – The Java API
• Apache Jackrabbit – Implementation


49
Famous Last Words
• Read the specification
• JCR in your application?
• Join the Jackrabbit community!
• Seriously consider Apache Sling for
  web applications
• Check for additional stuff like OCM




    50
Thanks for your attention!



                Q&A




51

Más contenido relacionado

La actualidad más candente

Content Management With Apache Jackrabbit
Content Management With Apache JackrabbitContent Management With Apache Jackrabbit
Content Management With Apache Jackrabbit
Jukka Zitting
 
Rest and Sling Resolution
Rest and Sling ResolutionRest and Sling Resolution
Rest and Sling Resolution
DEEPAK KHETAWAT
 
Sling models by Justin Edelson
Sling models by Justin Edelson Sling models by Justin Edelson
Sling models by Justin Edelson
AEM HUB
 
Alfresco Share - Recycle Bin Ideas
Alfresco Share - Recycle Bin IdeasAlfresco Share - Recycle Bin Ideas
Alfresco Share - Recycle Bin Ideas
AlfrescoUE
 

La actualidad más candente (20)

Content Management With Apache Jackrabbit
Content Management With Apache JackrabbitContent Management With Apache Jackrabbit
Content Management With Apache Jackrabbit
 
elasticsearch_적용 및 활용_정리
elasticsearch_적용 및 활용_정리elasticsearch_적용 및 활용_정리
elasticsearch_적용 및 활용_정리
 
Rest and Sling Resolution
Rest and Sling ResolutionRest and Sling Resolution
Rest and Sling Resolution
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
AEM + MongoDB: How to Scale and Operate Large Digital Asset Management Systems
AEM + MongoDB: How to Scale and Operate Large Digital Asset Management SystemsAEM + MongoDB: How to Scale and Operate Large Digital Asset Management Systems
AEM + MongoDB: How to Scale and Operate Large Digital Asset Management Systems
 
Sling models by Justin Edelson
Sling models by Justin Edelson Sling models by Justin Edelson
Sling models by Justin Edelson
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
[오픈소스컨설팅] 스카우터 사용자 가이드 2020
[오픈소스컨설팅] 스카우터 사용자 가이드 2020[오픈소스컨설팅] 스카우터 사용자 가이드 2020
[오픈소스컨설팅] 스카우터 사용자 가이드 2020
 
Alfresco Share - Recycle Bin Ideas
Alfresco Share - Recycle Bin IdeasAlfresco Share - Recycle Bin Ideas
Alfresco Share - Recycle Bin Ideas
 
Tomcat Server
Tomcat ServerTomcat Server
Tomcat Server
 
Caching solutions with Redis
Caching solutions   with RedisCaching solutions   with Redis
Caching solutions with Redis
 
Alfresco Certificates
Alfresco Certificates Alfresco Certificates
Alfresco Certificates
 
Ch05 Servlet 進階 API、過濾器與傾聽器
Ch05 Servlet 進階 API、過濾器與傾聽器Ch05 Servlet 進階 API、過濾器與傾聽器
Ch05 Servlet 進階 API、過濾器與傾聽器
 
Ansible
AnsibleAnsible
Ansible
 
검색엔진이 데이터를 다루는 법 김종민
검색엔진이 데이터를 다루는 법 김종민검색엔진이 데이터를 다루는 법 김종민
검색엔진이 데이터를 다루는 법 김종민
 
MongoDB sharded cluster. How to design your topology ?
MongoDB sharded cluster. How to design your topology ?MongoDB sharded cluster. How to design your topology ?
MongoDB sharded cluster. How to design your topology ?
 
[124]네이버에서 사용되는 여러가지 Data Platform, 그리고 MongoDB
[124]네이버에서 사용되는 여러가지 Data Platform, 그리고 MongoDB[124]네이버에서 사용되는 여러가지 Data Platform, 그리고 MongoDB
[124]네이버에서 사용되는 여러가지 Data Platform, 그리고 MongoDB
 
Fluentd - Flexible, Stable, Scalable
Fluentd - Flexible, Stable, ScalableFluentd - Flexible, Stable, Scalable
Fluentd - Flexible, Stable, Scalable
 
Alfresco勉強会#26 Alfresco SDK + Eclipseで開発してみよう
Alfresco勉強会#26 Alfresco SDK + Eclipseで開発してみようAlfresco勉強会#26 Alfresco SDK + Eclipseで開発してみよう
Alfresco勉強会#26 Alfresco SDK + Eclipseで開発してみよう
 
From zero to hero Backing up alfresco
From zero to hero Backing up alfrescoFrom zero to hero Backing up alfresco
From zero to hero Backing up alfresco
 

Destacado

Introduction to JCR and Apache Jackrabbi
Introduction to JCR and Apache JackrabbiIntroduction to JCR and Apache Jackrabbi
Introduction to JCR and Apache Jackrabbi
Jukka Zitting
 
Build Your Own CMS with Apache Sling
Build Your Own CMS with Apache SlingBuild Your Own CMS with Apache Sling
Build Your Own CMS with Apache Sling
Bob Paulin
 
Presentation thomas simlinger
Presentation thomas simlingerPresentation thomas simlinger
Presentation thomas simlinger
connectwebex
 
Hippo get together workshop automatic export
Hippo get together   workshop automatic exportHippo get together   workshop automatic export
Hippo get together workshop automatic export
Hippo
 
The Java Content Repository
The Java Content RepositoryThe Java Content Repository
The Java Content Repository
nobby
 

Destacado (20)

Introduction to JCR
Introduction to JCR Introduction to JCR
Introduction to JCR
 
Introduction to JCR and Apache Jackrabbi
Introduction to JCR and Apache JackrabbiIntroduction to JCR and Apache Jackrabbi
Introduction to JCR and Apache Jackrabbi
 
JCR In 10 Minutes
JCR In 10 MinutesJCR In 10 Minutes
JCR In 10 Minutes
 
Build Your Own CMS with Apache Sling
Build Your Own CMS with Apache SlingBuild Your Own CMS with Apache Sling
Build Your Own CMS with Apache Sling
 
Java Content Repository avec Jackrabbit
Java Content Repository avec JackrabbitJava Content Repository avec Jackrabbit
Java Content Repository avec Jackrabbit
 
Presentation thomas simlinger
Presentation thomas simlingerPresentation thomas simlinger
Presentation thomas simlinger
 
Hippo Presentation Jboye Study tour
Hippo Presentation Jboye Study tourHippo Presentation Jboye Study tour
Hippo Presentation Jboye Study tour
 
Hippo get together workshop automatic export
Hippo get together   workshop automatic exportHippo get together   workshop automatic export
Hippo get together workshop automatic export
 
Hippo CMS at OpenCo Amsterdam 2014
Hippo CMS at OpenCo Amsterdam 2014Hippo CMS at OpenCo Amsterdam 2014
Hippo CMS at OpenCo Amsterdam 2014
 
Web Applications Development
Web Applications DevelopmentWeb Applications Development
Web Applications Development
 
JCR In Action (ApacheCon US 2009)
JCR In Action (ApacheCon US 2009)JCR In Action (ApacheCon US 2009)
JCR In Action (ApacheCon US 2009)
 
What's new in JSR-283?
What's new in JSR-283?What's new in JSR-283?
What's new in JSR-283?
 
2008-12 OJUG JCR Demo
2008-12 OJUG JCR Demo2008-12 OJUG JCR Demo
2008-12 OJUG JCR Demo
 
Introducing Apricot, The Eclipse Content Management Platform
Introducing Apricot, The Eclipse Content Management PlatformIntroducing Apricot, The Eclipse Content Management Platform
Introducing Apricot, The Eclipse Content Management Platform
 
The Java Content Repository
The Java Content RepositoryThe Java Content Repository
The Java Content Repository
 
Effective Web Application Development with Apache Sling
Effective Web Application Development with Apache SlingEffective Web Application Development with Apache Sling
Effective Web Application Development with Apache Sling
 
App and web with Hippo CMS and AngularJS
App and web with Hippo CMS and AngularJS App and web with Hippo CMS and AngularJS
App and web with Hippo CMS and AngularJS
 
JCR and ModeShape
JCR and ModeShapeJCR and ModeShape
JCR and ModeShape
 
Cms integration of apache solr how we did it.
Cms integration of apache solr   how we did it.Cms integration of apache solr   how we did it.
Cms integration of apache solr how we did it.
 
Introducing Hippo CMS 10.2
Introducing Hippo CMS 10.2Introducing Hippo CMS 10.2
Introducing Hippo CMS 10.2
 

Similar a JCR - Java Content Repositories

Rubyonrails 090715105949-phpapp01
Rubyonrails 090715105949-phpapp01Rubyonrails 090715105949-phpapp01
Rubyonrails 090715105949-phpapp01
sagaroceanic11
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Nilesh Panchal
 
Spider进化论
Spider进化论Spider进化论
Spider进化论
cjhacker
 
Django introduction @ UGent
Django introduction @ UGentDjango introduction @ UGent
Django introduction @ UGent
kevinvw
 
Linked Data Publishing with Drupal (SWIB13 workshop)
Linked Data Publishing with Drupal (SWIB13 workshop)Linked Data Publishing with Drupal (SWIB13 workshop)
Linked Data Publishing with Drupal (SWIB13 workshop)
Joachim Neubert
 
Writing DSL's in Scala
Writing DSL's in ScalaWriting DSL's in Scala
Writing DSL's in Scala
Abhijit Sharma
 
Hibernate in XPages
Hibernate in XPagesHibernate in XPages
Hibernate in XPages
Toby Samples
 

Similar a JCR - Java Content Repositories (20)

Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Introduction to CQ5
Introduction to CQ5Introduction to CQ5
Introduction to CQ5
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 
Rubyonrails 090715105949-phpapp01
Rubyonrails 090715105949-phpapp01Rubyonrails 090715105949-phpapp01
Rubyonrails 090715105949-phpapp01
 
Melbourne User Group OAK and MongoDB
Melbourne User Group OAK and MongoDBMelbourne User Group OAK and MongoDB
Melbourne User Group OAK and MongoDB
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
 
Spider进化论
Spider进化论Spider进化论
Spider进化论
 
Scala at Treasure Data
Scala at Treasure DataScala at Treasure Data
Scala at Treasure Data
 
Spark Summit EU talk by Shay Nativ and Dvir Volk
Spark Summit EU talk by Shay Nativ and Dvir VolkSpark Summit EU talk by Shay Nativ and Dvir Volk
Spark Summit EU talk by Shay Nativ and Dvir Volk
 
Drupal 7 - The Top 40 Core Modules and What They Mean for You
Drupal 7 - The Top 40 Core Modules and What They Mean for YouDrupal 7 - The Top 40 Core Modules and What They Mean for You
Drupal 7 - The Top 40 Core Modules and What They Mean for You
 
2010 05-21, object-relational mapping using hibernate v2
2010 05-21, object-relational mapping using hibernate v22010 05-21, object-relational mapping using hibernate v2
2010 05-21, object-relational mapping using hibernate v2
 
The CoFX Data Model
The CoFX Data ModelThe CoFX Data Model
The CoFX Data Model
 
Django introduction @ UGent
Django introduction @ UGentDjango introduction @ UGent
Django introduction @ UGent
 
Advanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojoAdvanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojo
 
Eclipse Enterprise Content Repository (ECR)
Eclipse Enterprise Content Repository (ECR)Eclipse Enterprise Content Repository (ECR)
Eclipse Enterprise Content Repository (ECR)
 
Linked Data Publishing with Drupal (SWIB13 workshop)
Linked Data Publishing with Drupal (SWIB13 workshop)Linked Data Publishing with Drupal (SWIB13 workshop)
Linked Data Publishing with Drupal (SWIB13 workshop)
 
Writing DSL's in Scala
Writing DSL's in ScalaWriting DSL's in Scala
Writing DSL's in Scala
 
Hibernate in XPages
Hibernate in XPagesHibernate in XPages
Hibernate in XPages
 
Eurydike: Schemaless Object Relational SQL Mapper
Eurydike: Schemaless Object Relational SQL MapperEurydike: Schemaless Object Relational SQL Mapper
Eurydike: Schemaless Object Relational SQL Mapper
 
Publishing Linked Data from RDB
Publishing Linked Data from RDBPublishing Linked Data from RDB
Publishing Linked Data from RDB
 

Más de Carsten Ziegeler

Apache Sling : JCR, OSGi, Scripting and REST
Apache Sling : JCR, OSGi, Scripting and RESTApache Sling : JCR, OSGi, Scripting and REST
Apache Sling : JCR, OSGi, Scripting and REST
Carsten Ziegeler
 

Más de Carsten Ziegeler (17)

Service oriented web development with OSGi
Service oriented web development with OSGiService oriented web development with OSGi
Service oriented web development with OSGi
 
Use Case: Building OSGi Enterprise Applications (QCon 14)
Use Case: Building OSGi Enterprise Applications (QCon 14)Use Case: Building OSGi Enterprise Applications (QCon 14)
Use Case: Building OSGi Enterprise Applications (QCon 14)
 
What's cool in the new and updated OSGi Specs
What's cool in the new and updated OSGi SpecsWhat's cool in the new and updated OSGi Specs
What's cool in the new and updated OSGi Specs
 
What's cool in the new and updated OSGi specs
What's cool in the new and updated OSGi specsWhat's cool in the new and updated OSGi specs
What's cool in the new and updated OSGi specs
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web Console
 
Distributed Eventing in OSGi
Distributed Eventing in OSGiDistributed Eventing in OSGi
Distributed Eventing in OSGi
 
Apache Sling - Distributed Eventing, Discovery, and Jobs (adaptTo 2013)
Apache Sling - Distributed Eventing, Discovery, and Jobs (adaptTo 2013)Apache Sling - Distributed Eventing, Discovery, and Jobs (adaptTo 2013)
Apache Sling - Distributed Eventing, Discovery, and Jobs (adaptTo 2013)
 
Adobe AEM - From Eventing to Job Processing
Adobe AEM - From Eventing to Job ProcessingAdobe AEM - From Eventing to Job Processing
Adobe AEM - From Eventing to Job Processing
 
Embrace Change - Embrace OSGi
Embrace Change - Embrace OSGiEmbrace Change - Embrace OSGi
Embrace Change - Embrace OSGi
 
Apache Sling : JCR, OSGi, Scripting and REST
Apache Sling : JCR, OSGi, Scripting and RESTApache Sling : JCR, OSGi, Scripting and REST
Apache Sling : JCR, OSGi, Scripting and REST
 
Embrace OSGi
Embrace OSGiEmbrace OSGi
Embrace OSGi
 
Apache Sanselan (ApacheCon US 2007 FFT)
Apache Sanselan (ApacheCon US 2007 FFT)Apache Sanselan (ApacheCon US 2007 FFT)
Apache Sanselan (ApacheCon US 2007 FFT)
 
Apache iBatis (ApacheCon US 2007)
Apache iBatis (ApacheCon US 2007)Apache iBatis (ApacheCon US 2007)
Apache iBatis (ApacheCon US 2007)
 
JCR In Action (ApacheCon US 2007)
JCR In Action (ApacheCon US 2007)JCR In Action (ApacheCon US 2007)
JCR In Action (ApacheCon US 2007)
 
Apache Portals Panel (ApacheCon US 2007)
Apache Portals Panel (ApacheCon US 2007)Apache Portals Panel (ApacheCon US 2007)
Apache Portals Panel (ApacheCon US 2007)
 
JCR In Action (ApacheCon EU 2008)
JCR In Action (ApacheCon EU 2008)JCR In Action (ApacheCon EU 2008)
JCR In Action (ApacheCon EU 2008)
 
Maven SCR Plugin (ApacheCon EU 2008 - FFT)
Maven SCR Plugin (ApacheCon EU 2008 - FFT)Maven SCR Plugin (ApacheCon EU 2008 - FFT)
Maven SCR Plugin (ApacheCon EU 2008 - FFT)
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony 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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

JCR - Java Content Repositories

  • 1. Carsten Ziegeler | Day Management AG JCR – Java Content Repositories cziegeler@apache.org
  • 2. About • Member of the ASF – Sling, Felix, Cocoon, Portals, Sanselan, Excalibur, Incubator – PMC: Felix, Portals, Sling, Incubator, Excalibur (Chair) • RnD Team at Day Software • Article/Book Author, Technical Reviewer • JSR 286 Spec Group (Portlet API 2.0) 2
  • 3. Motivation • Tried and trusted NOSQL solution • Standard Java API – First spec released in May 2005 – Various implementations – Several products and solutions • Open Source Implementation – 1.0 Release in April 2006 • Think about your data storage use cases – JCR might help 3
  • 4. Agenda • JCR and Apache Jackrabbit • Basic Content Modeling • References and Search • Advanced Features • Summary and Questions 4
  • 5. (Nearly) Everthing is Content • Application Domain Specific Content • Presentation Support (HTML, CSS, JavaScript, Images) • Documentation, Translations • ... 5
  • 6. Content Silos without JCR • Structured content – Usually schema based • Unstructured content • Large data (images, movies etc.) • Different storages for each use case 6
  • 7. Content Repository I • Features of an RDBMS – Structure, integrity – Query, transactions • Features of a filesystem – Hierarchy, binaries – Locking, access control • All the other good stuff – Observation, versioning – Unstructured – Multi values, sort order, full text • Single repository for all content! 7
  • 8. Content Repository II • Hierarchical content – Nodes and properties • Structured – Nodetypes and typed properties • And/or unstructured • Fine and coarse-grained • Single repository for all content! 8
  • 9. Sample Application: Slingshot • Digital Asset Management – Hierarchical storage of pictures – Upload – Tagging Poor man's flickr... – Searching – Automatic thumbnail generation 9
  • 10. Slingshot Content Structure Travel Family Europe Weddings Amsterdam Basel 2008 2007 City Photo Photo Photo Photo 10
  • 11. Facts About Slingshot • Java web application • Uses Apache Sling as web framework • Content repository managed by Apache Jackrabbit • Interaction through the JCR API 11
  • 12. JSR 170: Content Repository for JavaTM technology API • (Java) Standard – Version 1.0 – Supported by many vendors – Used by many products and projects – Several open source solutions • How do you connect to a CR? • How do you interact with a CR? 12
  • 13. JSR 283 : JCR 2.0 is final • New features • Improved specification – Cleaned up API (deprecation) – Revised specification document • Binary compatible – JSR 170 apps run without modification 13
  • 14. The Repository Model • Repository: one (or more) workspaces • Workspace contains a tree of items • Item: Node or property • Nodes provide the content structure – May have children • Actual data is stored as values of properties • Types and namespaces! 14
  • 15. Nodes and Properties Root Travel Family Europe “Images from Europe“ Weddings Amsterdam Basel 2008 2007 City Photo Photo Photo Photo „Once upon a time..“ Properties Implementation of JCR 15
  • 16. Connecting to the Repository • JCR 2.0 provides RepositoryFactory • Uses Service Provider Mechanism – META-INF/services/javax.jcr.RepositoryFactory • Just use – RepositoryFactory.getRepository(null) • Or specify connection parameters – RepositoryFactory.getRepository(Map) 16
  • 17. Working with the Repository • Interaction is session based – Assemble credentials – Login into workspace Credentials myCredentials = new SimpleCredentials("USERID", "PASSWORD".toCharArray()); Session mySession = repository.login(myCredentials, "WORKSPACE"); 17
  • 18. Traversing the Content • Traverse the repository – From the root or any node Node rootNode = mySession.getRootNode(); Node albumNode = rootNode.getNode("slingshot/albums/travel"); Node europeNode = albumNode.getNode("Europe"); 18
  • 19. Retrieve a Property • Various ways to get a property – Different methods for each type – Type conversion if possible Property prop = albumNode.getProperty("slingshot:description"); Value value = prop.getValue(); String desc = value.getString(); value.getBoolean(); value.getStream(); value.getLong(); value.getDate(); value.getDouble(); 19
  • 20. Changing Content • Change everything you want – Add/Remove nodes – Add/Remove/Change properties – Transient space – Then save // change albumNode.addNode("newAlbum"); europeNode.setProperty("slingshot:description", "something"); // save... mySession.save(); // ... or revert all changes mySession.refresh(false); 20
  • 21. Interaction Summary • Get the repository • Login to a workspace – Provides a session • Use the session to – Access nodes and their properties – Change and save them 21
  • 22. CR : Combines Advantages Single storage for • Features of an RDBMS all content! – Structure, integrity – Query, transactions • Features of a filesystem – Hierarchy, binaries – Locking, access control • All the other good stuff – Observation, versioning – Unstructured – Multi values, sort order, full text – Import/Export (XML) 22
  • 23. Apache Jackrabbit 23 • JSR 170 and 283 reference implementation • Apache TLP since 2006 • Releases – 1.6 (JSR 170 based) – 2.0 Beta 2 is out – 2.0 Final (end of 2009) • Components – Commons, API – RMI, WebDAV, WebApp, JCA – OCM – And more... http://jackrabbit.apache.org/ 23
  • 24. Words of Advice • Read (or browse) the JCR spec – jcr-1.0.jar/jcr-2.0.jar included • Getting started with Jackrabbit – jackrabbit-webapp: Drop-in deployment – First Hops: Embedded repository – Take your time – Think about your use cases • Have a look at Apache Sling 24
  • 25. Agenda • JCR and Apache Jackrabbit • Basic Content Modeling • References and Search • Advanced Features • Demo: Sample Application • Summary and Questions 25
  • 26. Leverage the standard node types • Type hierarchy • Content hierarchy nt:hierarchyNode nt:folder nt:file nt:linkedFile nt:unstructured 26
  • 27. Bottom-up modeling: Node types slingshot:album > nt:folder slingshot:tag - slingshot:description (string) - slingshot:description (string) - slingshot:date (date) slingshot:photo > nt:file - slingshot:description (string) - slingshot:location (string) - slingshot:tags (string[]) 27
  • 28. Top-down modeling: Hierarchy Travel Family Europe Weddings Amsterdam Basel 2008 2007 City Photo Photo Photo Photo 28
  • 29. Namespaces • Namespaces can be used for – Node types – Node and property names • Single namespace per company or app • Reasonably unique namespace prefix • Prefixed names for structured content • Default namespace for unstructured content 29
  • 30. Content Modeling Advice I • Use an application root node – Examples: my:content or slingshot – Good for searching, backup, and migration • Avoid flat hierarchies – User interface complexity • Content-driven design – Design your content before your appl 30
  • 31. Content Modeling Advice II • Look at existing node types (JSR 2.0) • Make use of mixin node types • Checkout Apache Jackrabbit wiki and mailing lists – "Davids Model" 31
  • 32. David‘s Model • Rule #1: Data First, Structure Later. Maybe • Rule #2: Drive the content hierarchy, don‘t let it happen • Rule #6: Files are Files are Files • Look at http://wiki.apache.org/jackrabbit/Dav idsModel 32
  • 33. Agenda • JCR and Apache Jackrabbit • Basic Content Modeling • References and Search • Advanced Features • Summary and Questions 33
  • 34. References with JCR Tags Album Favorites Bird Tree Photo Top 10 Picks Photo link link link API: Node.getReferences():PropertyIterator Property.getNode():Node Node.setProperty(String name, Node) 34
  • 35. Alternative References I • Reference by name slingshot:photo > nt:file - slingshot:description (string) slingshot:tag - slingshot:location (string) - slingshot:description (string) - slingshot:tags (string[]) 35
  • 36. Alternative References II • Reference by path / slingshot:photo > nt:file - slingshot:description (string) Tags - slingshot:location (string) - slingshot:tags (string[]) /Tags/bird bird 36
  • 37. Searching • Query API – Java Query Object Model – SQL queries • Examples – SELECT * FROM slingshot:photo WHERE jcr:path LIKE ‘/slingshot/%’ – ..AND slingshot:description CONTAINS 'munich' API: Session.getWorkspace().getQueryManager():QueryManager QueryManager.createQuery(String stmt, String language):Query; Query.execute():QueryResult 37
  • 38. Agenda • JCR and Apache Jackrabbit • Basic Content Modeling • References and Search • Advanced Features • Summary and Questions 38
  • 39. Observation • Enables applications to register interest in events • Monitor changes • Act on changes API: ObservationManager: addEventListener(EventListener listener, int eventTypes, java.lang.String absPath, boolean isDeep, java.lang.String[] uuid, java.lang.String[] nodeTypeName, boolean noLocal) 39
  • 40. Observation Events • Describe changes to a workspace – Dispatched on persistent change • Provide the path of the item • Provide the user ID • Only provided to sessions with sufficient access privileges • Events may not be complete! – Example: removal of a tree of nodes 40
  • 41. Event Types • Five different types – Node added – Node removed – Property added – Property removed – Property changed 41
  • 42. Event Listeners • Registered with a workspace • Registration with optional filters – Like node types, paths • Receive events for every change API: public void onEvent(EventIterator events); 42
  • 43. Events Advice • Events occur after a save – Modification based on events is a new operation – Such events can be filtered • Events may not tell the complete story – Tree removal, copy, move • Most common pattern – Node added, removed, changed 43
  • 44. Staged Publishing: Versioning Version store Staging Live 44
  • 45. Advanced Development • Apache Sling – REST based web framework – Powered by OSGi – Scripting Inside • Apache Jackrabbit OCM – Map content to Java objects and vice versa – Similar to database ORMs 45
  • 46. JCR 2.0 Features • Abstract Query Model – Java Query Object Model / SQL • ACL and Access Control Policies – Plus Retention Policies and Hold • Nodetype Registry • New Property Types and Nodetypes • Shareable Nodes (Graph) • Journalling Observation 46
  • 47. Agenda • JCR and Apache Jackrabbit • Basic Content Modeling • References and Search • Advanced Features • Summary and Questions 47
  • 48. And remember... • (Nearly) everything is content – Application Domain Specific Content – Presentation Support (HTML, CSS, JavaScript, Images) – Documentation, Translations –… • With observation, versioning, search... 48
  • 49. Conclusion • Content Repositories – Combine advantages from FS and DB – Add important features – Structure/Access your data the way your domain requires it – Single repository for all your content! • JCR – The Java API • Apache Jackrabbit – Implementation 49
  • 50. Famous Last Words • Read the specification • JCR in your application? • Join the Jackrabbit community! • Seriously consider Apache Sling for web applications • Check for additional stuff like OCM 50
  • 51. Thanks for your attention! Q&A 51