Introduction to JCR and Apache Jackrabbit Jukka Zitting ApacheCon US 2008
JCR Crash Course! import  javax.jcr.*; import  org.apache.jackrabbit.core.TransientRepository; repository =  new   TransientRepository (); println  repository. getDescriptor (Repository.REP_NAME_DESC); Jackrabbit
Sessions and Workspaces credentials =  new  SimpleCredentials(   “username”, “password”. toCharArray ()); session = repository. login (credentials) workspace = session. getWorkspace () println  workspace. getName () default println  workspace. getAccessibleWorkspaceNames () { “default” }
Node Hierarchy root = session. getRootNode (); foo = root. addNode ("foo"); bar = root. addNode ("bar"); baz = bar. addNode ("baz"); println  baz. getPath (); /bar/baz
Properties a = foo. setProperty ("A", "abc"); b = foo. setProperty ("B", "123"); println  b. getPath (); /foo/B println  b. getLong () + 321; 444
Transient State other = repository. login (); println  other. itemExists ("/foo"); false session. save (); println  other. itemExists ("/foo"); true
XPath Query qm = workspace. getQueryManager (); query = qm. createQuery (   "//*[A = 'abc']", "xpath"); nodes = query. execute (). getNodes (); println  nodes. nextNode (). getPath (); /foo
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
And Remember! session. logout () other. logout ()
Content Modeling nt:hierarchyNode nt:folder nt:file nt:linkedFile nt:resource
Bottom-Up Modeling my:resource > nt:resource codec (string)
bitrate (long) my:tune > nt:file artist (string)
release date (date) my:album > nt:folder artist (string)
release date (date) my:review > nt:file author (string)
star rating (long)
Top-Down Modeling Album Images Tune Band Label Label Tune Album Reviews Label Band Reviews Tune Images

Introduction to JCR and Apache Jackrabbi

  • 1.
    Introduction to JCRand 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 Workspacescredentials = 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:hierarchyNodent: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.
  • 16.
    Top-Down Modeling AlbumImages Tune Band Label Label Tune Album Reviews Label Band Reviews Tune Images