RESTful web applications with Apache Sling - ApacheCon

72 downloads 108 Views 3MB Size Report
Nov 3, 2010 ... applications with. Apache Sling ... code content! /libs. /cq. /code. /install. /xyz.jar. Page 6. Apache. Sling. Applications layer for JCR repositories.
RESTful web applications with Apache Sling Bertrand Delacrétaz Senior Developer, R&D, Day Software, now part of Adobe Apache Software Foundation Member and Director http://grep.codeconsult.ch - twitter: @bdelacretaz - [email protected] ApacheCon NA 2010, Atlanta slides revision: 2010-11-03

1

everything is

content JCR API The Java Content Repository Tree of nodes and properties JSR-170, JSR-283

Sling Restful Web Apps

Text, images, media, configurations, code, binary OSGi bundles, etc...

RESTful Web

URLs map to resources, not commands

website content /content /geometrixx /en /company /jcr:content /par /title

blog design content

/etc/designs/blog/kubrick/jcr:content

code content! /libs /cq /code /install /xyz.jar

Apache Sling powered by

Applications layer for JCR repositories

resource-based

script == servlet «any» scripting language powerful default servlets OSGi-based

debugger

HTTP

filesystem

browser

WebDAV server

Felix OSGi console

content administration UI standard servlets resource resolution

custom servlets and components servlet/script resolution

javascript

JSR 223 scripting

JSP Ruby Velocity etc..

OSGi framework (Apache Felix) JCR API

Apache Sling architecture

JCR content repository

storage components

Apache Sling

Reclaiming the Web: Sling URL decomposition /cars/audi/s4.details.html Content Repository Pat h

Sling Restful Web Apps

...selector + extension select particular scrip a t

Repository

Bertrand Delacretaz

OSGi? Great for modularity Fosters better structured code Dynamic services and plugins Tooling needs to improve, but usable OSGi skills? - OSGi way of thinking is new... Asynchronous startup can be problematic if using declarative services Sling Restful Web Apps

rs, e p o l eve ry! d p p A wor don’t

Bertrand Delacretaz

What can you do with Sling?

Next-generation RESTful kernel for permeable, social, personal and remixable collaboration/ learning environment. See http://sakaiproject.org/case-studies

idium.no - fullservice hosted CMS integrated with CRM. Autoscales on Amazon EC based on JCR clustering and Sling event support.

Web Content Management Multi-channel + mobile

Customer Engagement Management

Digital Assets Management powered by

e-commerce

BIG websites

Content Applications Platform

www.day.com

CQ5

Sling blog 46 lines of code http://x42.ch/05.40.01

Sling POST Servlet: create content # POST to Sling curl -F title=hi http://localhost:8888/foo -> 200 OK # GET created node in json format curl http://localhost:8888/foo.tidy.json { "jcr:primaryType": "nt:unstructured", "title": "hi" } POST ters se t e param operties r p e d o ! p n tu e s o r e Z Sling Restful Bertrand Delacretaz Web Apps

HTML form for editing Title: Text: Sling Restful Web Apps

s d l e i f Form e h t e v i r d el d o m t conten Bertrand Delacretaz

sling.js: initializes form fields ...(as in step 1)... Sling.wizard();

) D ( U R C t Instan Sling Restful Web Apps

Bertrand Delacretaz

sling.js: generate navigation