21
©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Condential. JCR & Sling quick dive Paolo Moadelli | Senior Sales Engineer

JCR and Sling Quick Dive

Embed Size (px)

DESCRIPTION

When getting in first touch with CQ5 and CRX, shipped by Day Software, now part of Adobe, the stakeholders need to understand the basic concept of the Open Architecture embraced by those systems.This is an easy to understand introduction to JCR and Sling architecture.

Citation preview

Page 1: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

JCR & Sling quick divePaolo Mo"adelli | Senior Sales Engineer

Page 2: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Background

■ !e WWW design approach:■ Single, simple standardize interface■ Independent from storage/creation■ Trascends the complexity

■ Same design principles for application development:■ Commitment to standardization ■ Simple, generic, Content-Centric interface

2

Page 3: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Content-centric vs Control-centric interfaces

■ Content-centric interfaces principles:■ Uniform identi!ers■ Standard methods■ Extensible representation types■ Simpli!ed application integration (much less interfaces)

■ Content Repository API = Uniform interface

3

Page 4: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Content Repository

■ A Content Repository supports:■ Diverse data:

■ small & large, structured & unstructured, binary, metadata & relationships■ Services:

■ access control, locking, versioning, transactions, observation

■ "e Java Content Repository provides:■ Abstraction of data storage■ Generalized content services■ Separation of real storage from application interactions■ Standard API

4

Page 5: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

JCR

■ !e JCR speci"cation de"nes an abstract model and a Java API for data storage and related services commonly used by content-oriented applications.

■ Target: any application that must handle both unstructured digital assets and structured or semi-structured information.

5

Page 6: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

JCR: !e Repository Model

■ Workspaces■ Hierarchy of nodes■ Properties associated to a node■ Node types de"ne constraints(properties and child nodes)

6

Repository

Workspace Workspace Workspace

[root] [root] [root]

jcr:title = ‘Hello World’jcr:lastModifiedBy = ‘admin’

Page 7: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

JSON representation of a node

7

http://localhost:7402/content/firststeps.infinity.json

Page 8: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

JCR code sample

Repository repository = new TransientRepository(); Session session = repository.login(new SimpleCredentials("username", "password".toCharArray()));

// Store content 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"); System.out.println(node.getPath()); System.out.println(node.getProperty("message").getString());

// Remove content root.getNode("hello").remove(); session.save();

8

Page 9: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

JCR: Repository Functionalities

■ Level 1■ Login■ Read Nodes & properties■ XML export■ XPath queries■ Node types discovery■ Namespaces remapping

9

■ Level 2■ Write nodes & properties■ XML Import■ Assign a node types to nodes■ Change namespace registry

■ Optional■ Locking■ Transactions■ Versioning

■ SQL search■ Observation

Page 10: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

JCR: Observation

■ Observation enables an application to receive noti"cation of persistence changes in the workspace. Base for BPM.■ NODE_ADDED■ NODE_MOVED■ NODE_REMOVED■ PROPERTY_ADDED■ PROPERTY_REMOVED■ PROPERTY_CHANGED

■ Can be asynchronous or journaled

10

Page 11: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

JCR: Content Modelling

■ 2 use cases:

■ Structured content (e.g. !le storage)■ Needs de"nition of content models;■ Needs a stable structure;■ nt:resource

■ Unstructured content■ Any properties and child nodes allowed■ nt:unstructured

11

[nt:resource] > mix:mimeType, mix:lastModifiedprimaryitem jcr:data- jcr:data (BINARY) mandatory

Page 12: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

JCR: node types & mixin types

■ prede"ned node types:■ nt:unstructured■ nt:"le■ nt:folder■ nt:resource represents the actual content of a "le.■ nt:version

■ mixin types provide extra characteristics to the node:■ mix:versionable: allows a node to support versioning■ mix:lockable: enables locking capabilities■ mix:referenceable: provides an auto-created jcr:uuid property

12

Page 13: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

JCR Ecosystem

■ Open Standard■ Java Community Process (h"p://jcp.org)

■ Sustainability■ Reference Implementation & TCK

■ Apache infrastructure■ license, workspace, information

■ Community■ open review, testing & collaboration

■ Open adoption

13

Page 14: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Sling

■ OSGI-based scriptable application layer on top of JCR

■ REST based web framework■ Content-driven, using a JCR content repository■ Powered by OSGi■ Scripting inside, multiple languages (JSP, server-side javascript, Scala, etc.)■ Apache Open Source project

14

Page 15: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

!e Sling style

■ If you happen to hear this sentence:■ “Sling is not a web applications framework, it’s a web framework.”

■ It means:■ Sling is built in a way that embraces the web.■ Sling design is based on the principles of the WWW.■ Sling processes HTTP requests in a RESTful way.

15

Page 16: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

CRX Architecture

16

OSGI framework (felix)

JCR repository (jackrabbit)

JCR api

Application framework (sling)

HTTP

‣ manages bundles as app components‣ provides system services to bundles

‣ stores the content

‣ processes HTTP requests in a RESTful way

specification implementation

architectural style

Page 17: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Sling Architecture

17

felix

jackrabbitJCR api

HTTP

standardservlets

custom servletsand components

resourceresolution

servlet/scriptresolution

JSR 223scripting

javascript

Ruby

WedDAVserver

sling OSGIconsole

sling

JSP

Scala

...

Page 18: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Sling examples using cURL

■ Create a node■ curl -F"sling:resourceType=foo/bar" -F"title=some title" h"p://admin:admin@localhost:7402/content/mynode

■ Create a node (auto-named)■ curl -X POST "h"p://admin:admin@localhost:7402/content/blog"■ curl -D - -F"title=Adventures with Sling" "h"p://admin:admin@localhost:7402/content/blog/*"

18

Page 19: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Sling URL decomposition

19

/geometrixx/en/products/triangle.html

/geometrixx/en/products/triangle.teaser.html

de#nes the resource de#nes the rendition

Page 20: JCR and Sling Quick Dive

©2010 Adobe Systems Incorporated. All Rights Reserved. Adobe Con!dential.

Sling URL decomposition

20

/geometrixx/en/products/triangle.teaser.html

sling:resourceTypegeometrixx/components/contentpage