Your SlideShare is downloading. ×
Introduction to JCR and Apache Jackrabbi
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Introduction to JCR and Apache Jackrabbi

5,333

Published on

0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,333
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
209
Comments
0
Likes
4
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Introduction to JCR and Apache Jackrabbit Jukka Zitting ApacheCon US 2008
  • 2. JCR Crash Course!
      import javax.jcr.*; import org.apache.jackrabbit.core.TransientRepository; repository = new TransientRepository (); println repository. getDescriptor (Repository.REP_NAME_DESC);
      • Jackrabbit
  • 3. Sessions and Workspaces
      credentials = new SimpleCredentials( “username”, “password”. toCharArray ()); session = repository. login (credentials) workspace = session. getWorkspace () println workspace. getName ()
      • default
      println workspace. getAccessibleWorkspaceNames ()
      • { “default” }
  • 4. Node Hierarchy
      root = session. getRootNode (); foo = root. addNode ("foo"); bar = root. addNode ("bar"); baz = bar. addNode ("baz"); println baz. getPath ();
      • /bar/baz
  • 5. Properties
      a = foo. setProperty ("A", "abc"); b = foo. setProperty ("B", "123"); println b. getPath ();
      • /foo/B
      println b. getLong () + 321;
      • 444
  • 6. Transient State
      other = repository. login (); println other. itemExists ("/foo");
      • false
      session. save (); println other. itemExists ("/foo");
      • true
  • 7. XPath Query
      qm = workspace. getQueryManager (); query = qm. createQuery ( "//*[A = 'abc']", "xpath"); nodes = query. execute (). getNodes (); println nodes. nextNode (). getPath ();
      • /foo
  • 8. SQL Query
      query = qm. createQuery ( "SELECT * FROM nt:base” + “ WHERE A = 'abc'", "sql"); rows = query. execute (). getRows (); println rows. nextRow () . getValue ("jcr:path"). getString ()
      • /foo
  • 9. And Remember!
      session. logout () other. logout ()
  • 10. Content Modeling nt:hierarchyNode nt:folder nt:file nt:linkedFile nt:resource
  • 11. Bottom-Up Modeling my:resource > nt:resource
    • codec (string)
    • 12. bitrate (long)
    my:tune > nt:file
    • artist (string)
    • 13. release date (date)
    my:album > nt:folder
    • artist (string)
    • 14. release date (date)
    my:review > nt:file
    • author (string)
    • 15. star rating (long)
  • 16. Top-Down Modeling Album Images Tune Band Label Label Tune Album Reviews Label Band Reviews Tune Images
  • 17. Finding Content by Reference Rock tags tunes Tune Tune Classic Top 10 playlists Picks link link link
  • 18. Finding Content by Search Looking for XPath SQL Latest releases /jcr:root/my:tunes//element(*,my:tune) [@released > xs:dateTime(‘…’)] SELECT * FROM my:tune WHERE jcr:path LIKE ‘/my:tunes/%’ AND released > DATE ‘…’ Reviews with keywords /jcr:root/my:tunes//element(*,my:review) /jcr:content[jcr:contains(.,’…’)] SELECT * FROM my:review WHERE jcr:path LIKE ‘/my:tunes/%’ AND CONTAINS(*,‘…’)
  • 19. Versioning and Publishing Version store Live Staging
  • 20. http://jackrabbit.apache.org/

×