Taming Jcr With Sling
-
Upload
bertrand-delacretaz -
Category
Technology
-
view
5.877 -
download
3
description
Transcript of Taming Jcr With Sling
![Page 1: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/1.jpg)
Technology Presentation 1
Taming content repositories with Apache Sling
Bertrand Delacrétaz, Senior R&D DeveloperMichael Marth, Technology EvangelistDay Software, www.day.com
OpenExpo 2008, Winterthur, September 25th
Slides revision: 2008-09-24Slides design: David Nuescheler
1mercredi, 24 septembre 2008
![Page 2: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/2.jpg)
Taming Content RepositoriesWeb Development
The Web vs. JCR - Intro
Blog in 15 minutes
So what?silver
2mercredi, 24 septembre 2008
![Page 3: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/3.jpg)
Intro to JCR
JCR = Java Content Repository API
JSR-170 / JSR-283
Everything Is Content - and JCR manages it as trees of Nodes and Properties, using rich data types.
silver
3mercredi, 24 septembre 2008
![Page 4: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/4.jpg)
What’s JCR?
`çåíÉåí=oÉéçëáíçêó=Ñçê=g~î~qj=íÉÅÜåçäçÖó=^mfpéÉÅJiÉ~ÇWa~ó=pçÑíï~êÉpí~íìëW=cáå~ä=oÉäÉ~ëÉ=NTJàìåJOMMR
gpoJNTM
bñéÉêí=dêçìéW
4mercredi, 24 septembre 2008
![Page 5: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/5.jpg)
bñéÉêí=dêçìéW
gpoJNTM gpoJOUP
`çåíÉåí=oÉéçëáíçêó=Ñçê=g~î~qj=íÉÅÜåçäçÖó=^mf=îOKMpéÉÅJiÉ~ÇWa~ó=pçÑíï~êÉpí~íìëW=mìÄäáÅ=oÉîáÉï=`äçëÉÇ=ëÉéJOMMT
What’s JCR?
5mercredi, 24 septembre 2008
![Page 6: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/6.jpg)
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.” ?
6mercredi, 24 septembre 2008
![Page 7: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/7.jpg)
Best of both worlds.
data base filesystem
content repository
read
write
hier-archiesstreams
locking accesscontrol
integrity structure
tx query
un-structured“full-text” sort
orderversion
ingobser-vation
multi-value
7mercredi, 24 septembre 2008
![Page 8: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/8.jpg)
Known compliant Repositories
Apache Jackrabbit Oracle XML DBExo
ECMS PlatformMicrosoft
Sharepoint OpenText Livelink
Day CRX IBM FileNet P8 Xythos Repository Alfresco ECM Vignette V7
Interwoven Repository IBM CM EMC Documentum
How many
RDBMS vendors
do you need?+hundreds of TCKsregistered
* *
*
*
* using third party connector
*
8mercredi, 24 septembre 2008
![Page 9: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/9.jpg)
Sourcemix Sourcemix
Percussion Rhythmix Lutece
Portal
QuickWCM WCMS
Jahia Framework
Hippo CMS
InfoQ Online CommunityNuxeo ECM
Sakai E-learning
TYPO3 v5.0 WCMGX WebManager
Exo ECMS Platform
Liferay Enterprise Portal
Artifactory Maven Proxy
IBM FileNet WebSiteManagerApache James
medic-2-medic mapofmedicine
Day Communiqué WCMS
Apache Tapestry
Day Communique Collab
QSLabs ComplianceApache
Cocoon
Alfresco ECMSApache Sling
Mindquarry Collaboration
Day Communique DAMmagnolia WCMS
JBoss Portal
Some known JCR Applications
Sun OpenPortal Interface 21
Spring Framework
Fast Enterprise SearchOracle PortalBEA Portal
9mercredi, 24 septembre 2008
![Page 10: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/10.jpg)
JCR code excerptRepository repository = new TransientRepository();Session session = repository.login(...);
// Create contentNode root = session.getRootNode();Node hello = root.addNode("hello");Node world = hello.addNode("world");
world.setProperty("message", "Hello, World!");session.save();
// Retrieve contentNode node = root.getNode("hello/world");print(node.getPath());print(node.getProperty("message").getString());
10mercredi, 24 septembre 2008
![Page 11: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/11.jpg)
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/sling11mercredi, 24 septembre 2008
![Page 12: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/12.jpg)
JCR: David Nuescheler
REST over JCR
REST -> Roy T. Fielding
released y2k162 pages
v1.0 released 2005
+300 pages
12mercredi, 24 septembre 2008
![Page 13: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/13.jpg)
Repository
Reclaiming the web.Sling URL decomposition.
/cars/audi/s4.details.html
Content Repository Path...selects a particular script
13mercredi, 24 septembre 2008
![Page 14: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/14.jpg)
Sling architecture
OSGi bundles
OSGi webapp
OSGi framework(Apache Felix)
JCRrepository
javascript
JSPRuby
Velocityetc..
debugger
WebDAVserver
Sling OSGiconsole
browserfilesystem
JSR-170 API
HTTP
resource resolution
custom servletsand components
JSR 223 scripting
servlet/script resolution
standardservlets
14mercredi, 24 septembre 2008
![Page 15: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/15.jpg)
A Sling-based blog282 lines of code
100% scripted, no tools required besides Sling
Simple, modular code structure
Promotes RESTful thinking
15mercredi, 24 septembre 2008
![Page 16: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/16.jpg)
Sling blog scriptsadmin.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)
16mercredi, 24 septembre 2008
![Page 17: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/17.jpg)
Creating content (post.esp)<form method="POST" action="/content/myblog/posts/*"> <p><label>Title</label><input name="title" type="text"/></p>
<p><p><label>Body</label><textarea name="posttext" cols="40" rows="5">
<input name=":redirect" type="hidden" value="/content/myblog/posts.admin.html"/>
<input type="submit" value="Post"></form>
17mercredi, 24 septembre 2008
![Page 18: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/18.jpg)
Rendering content (html.esp)<html><% sling.include("/content/myblog.header.html") %>
<body> <h2> <%=currentNode.title %> </h2> <% var a = currentNode.getNode("attachments").getNodes() ; for(i in a) { var attachmentNode = a[i]; ... %>}
</body></html>
18mercredi, 24 septembre 2008
![Page 19: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/19.jpg)
Sling blog demo
19mercredi, 24 septembre 2008
![Page 20: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/20.jpg)
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.
20mercredi, 24 septembre 2008
![Page 21: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/21.jpg)
JCR observationString[] nodeTypes = { "nt:file" };boolean isDeep = true;
observationManager.addEventListener( this, Event.NODE_ADDED | Event.NODE_REMOVED, "/content/myblog/posts", isDeep, ...types);...public void onEvent( EventIterator eventIterator) { ... }
21mercredi, 24 septembre 2008
![Page 22: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/22.jpg)
Thumbnails bundle demo
22mercredi, 24 septembre 2008
![Page 23: Taming Jcr With Sling](https://reader034.fdocuments.us/reader034/viewer/2022052523/5550fbfcb4c9057b478b4a83/html5/thumbnails/23.jpg)
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!
23mercredi, 24 septembre 2008