SlideShare a Scribd company logo
1 of 25
Bertrand Delacrétaz
Senior Developer, CQ5 R&D team, Adobe Basel
Apache Software Foundation Member and (current) Director
@bdelacretaz - http://grep.codeconsult.ch
Lausanne, May 2013
slides revision: 2013-05-30
1
RESTfulwebapps
withApacheSling
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Apache Sling: OSGi-based applications layer for JCR
2
content
everything is
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Everything is content!
3
Any app that requires more than
curl as a minimal client should
have a good reason.
Java
content
repository
JCR API
Apache SlingHTTP
Let’sbuildan
intelligentWeb
server.
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Content?
4
design
everything
website
code
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Website Content
5
/content
/geometrixx
/en
/company
/jcr:content
/par
/title
sling:resourceType
drives rendering
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 6
Apache Sling
«any» scripting
languagescript == servlet
OSGi-
based
RESTful default servlets
sling.apache.org
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Sling Architecture Overview
7
OSGi framework
(Apache Felix)
WebDAV
server
Felix OSGi
console
JCR
content
repository
JCR API
ECMAscript
JSP
Ruby
Velocity
JSR 223
scripting
resource
resolution
servlet/
script
standard
servlets
custom
servlets
Sling Core
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Sling is based on OSGi
Extreme modularity
Fosters better structured code
Dynamic plugins - for everything!
In-JVM Service-based architecture
8
OSGi bundle
Private packages
Public packages
Metadata
Matchless picture: Alvimann on morguefile.com
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Clean URLs with Sling: «Reclaiming the Web»
Sling
/cars/audi/s4.details.html
Content
Repository
Path
Selectorsand
extension
9
sling:resourceType
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Sling Sample Application
Slingbucksa RESTful coffee shop
10
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Slingbucks Application Flow
Customers,
public content
Staff,
private content
11
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Slingbucks use cases: Order Coffee
Display order form with configurable options.
Customer submits order.
Redisplay order for confirmation with hard to guess ID.
1
Content:
12
POST
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Slingbucks use cases: Confirm Order
Redisplay order form.
Customer either modifies and
recalculates price, or confirms order.
1
2Content:
13
POST
GET
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Slingbucks Process Order use case and content
Confirmed order moves under /private, for Slingbucks staff
App displays a list of confirmed orders to staff.
Staff delivers order and deletes it from list.
3 Orders really move!
14
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Slingbucks Resources Design
Security/ACLs
MeaningfulURLs
1:1JCRpathmapping
Object-oriented design?
No: everything is content: we want RESTful resources.
15
New order form:
http://slingbucks.com/public/orders.html
Order editing and confirmation (example):
http://slingbucks.com/public/orders/544da609.html
Price of an order:
Same but ending with .price.html selector
List of confirmed orders:
http://slingbucks.com/private/confirmed.html
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Sling gets the Web!
16
allyouneediscurlor any other HTTP client
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
The SlingPostServlet
$ curl -D -
-F "customerName=Bob The Geek"
-F sling:resourceType=slingbucks/order
-F lastModified=""
-F opt_coffeetype=capuccino
-F opt_size=medium
-F opt_sugar=raw
-F opt_cup=rosewood
http://u:pwd@slingserver/content/slingbucks/public/orders/
HTTP/1.1 201 Created
Location: /slingbucks/public/orders/117936075d4de452cbba5b468
17
SlingPostServlet
JCR
content
repository
JCR API
HTTP POST
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Default JSON GET servlet
$ curl http://localhost:8080/content
/slingbucks/public/orders
/fad01d62ca54209a1405e3b.tidy.json
{
"opt_size": "small",
"customerName": "Bob the Geek",
"opt_coffeetype": "espresso",
"opt_sugar": "none",
"sling:resourceType": "slingbucks/order",
"opt_cup": "plastic",
"lastModified": "Nov 01 2010 18:31:01",
"jcr:primaryType": "nt:unstructured"
}
18
DefaultGetServlet
JCR
content
repository
JCR API
HTTP GET
JSON
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Slingbucks Sample App
codeJust two OSGi services
and a few presentation scripts
19
Writinglotsof
code?
Maybeyou
shouldn’t
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Code: OSGi plugin for hard to guess node names
20
/** OSGi SCR instantiates this and registers as Service */
@Component
@Service
public class HexNodeNameGenerator
implements org.apache.sling..NodeNameGenerator {
@Override
/** Sling calls this when creating a node */
public String getNodeName(
SlingHttpServletRequest request,
String parentPath, ...)
{
...if path is in slingbucks tree:
return computeHardToGuessName();
...else return null
maven-scr-
plugin
processes
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Code: watch repository to move confirmed orders
/** OSGi SCR instantiates this */
@Component
public class ConfirmedOrdersObserver
implements EventListener, Runnable {
/** OSGi SCR provides this */
@Reference
private SlingRepository repository;
/** OSGi SCR calls this at startup */
protected void activate(ComponentContext ctx){
// Register with repository
// to callback our onEvent method
// on changes under /content/slingbucks/orders
...
public void onEvent(EventIterator it) {
while (it.hasNext()) {
if(path.endsWith(«orderConfirmed») {
... if orderConfirmed property is true:
... move node under private/
confirmed
... using
session.getWorkspace().move(....
21
Orders really move!
TwoJava
methodsina
Component
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Coffee options? defined by content -
"fields" : {
"coffeetype" : {
"jcr:title" : "Coffee type",
"espresso" : {
"jcr:title" : "Espresso",
"jcr:description" : "The Italian job",
"priceOffset" : 2.20
},
"capuccino" : {
"jcr:title" : "Capuccino",
"jcr:description" : "The one with cream on top",
"priceOffset" : 3.40
}
},
"size" : {
"jcr:title" : "Size",
"small" : {
"jcr:title" : "Small",
"jcr:description" : "1dl",
"priceFactor" : 1
},
"large" : {
"jcr:title" : "Large",
"jcr:description" : "5dl",
"priceFactor" : 2
}
}
HTTP GET with .json
extension.
POST to set values.
(out of the box)
22
Reconfigure
in-flight
withcurl!
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Slingbucks code size
Java code: 250 lines
3 java files
HTML representation scripts: 250 lines
7 esp files
Initial repository content: 85 lines
3 json files
Style and client-side javascript: 43 lines
1 css and 1 js file
Scripts and design
content:
23
Writinglotsofcode?
Maybeyoushouldn’t
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Did I mention this already?
Sling design promotes RESTful applications.
Powerful out of the box HTTP services.
OSGi plugins for (most) everything.
24
Java
content
repository
JCR API
Apache Sling
Writinglotsof
code?
Maybeyou
shouldn’t
everything
is
content!
© 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Where next?
25
Code at http://s.apache.org/slingbucks
Code and community at sling.apache.org
OSGi info at www.osgi.org
Slides at www.slideshare.net/bdelacretaz

More Related Content

What's hot

Rapid RESTful Web Applications with Apache Sling and Jackrabbit
Rapid RESTful Web Applications with Apache Sling and JackrabbitRapid RESTful Web Applications with Apache Sling and Jackrabbit
Rapid RESTful Web Applications with Apache Sling and JackrabbitCraig Dickson
 
Building domain-specific testing tools : lessons learned from the Apache Slin...
Building domain-specific testing tools : lessons learned from the Apache Slin...Building domain-specific testing tools : lessons learned from the Apache Slin...
Building domain-specific testing tools : lessons learned from the Apache Slin...Robert Munteanu
 
The Evolution of Airbnb's Frontend
The Evolution of Airbnb's FrontendThe Evolution of Airbnb's Frontend
The Evolution of Airbnb's FrontendSpike Brehm
 
Django rest framework
Django rest frameworkDjango rest framework
Django rest frameworkBlank Chen
 
Microservices with Spring Boot
Microservices with Spring BootMicroservices with Spring Boot
Microservices with Spring BootJoshua Long
 
Magento 2 Workflows
Magento 2 WorkflowsMagento 2 Workflows
Magento 2 WorkflowsRyan Street
 
Choosing a Javascript Framework
Choosing a Javascript FrameworkChoosing a Javascript Framework
Choosing a Javascript FrameworkAll Things Open
 
Dropwizard Internals
Dropwizard InternalsDropwizard Internals
Dropwizard Internalscarlo-rtr
 
Apache Camel in the belly of the Docker whale
Apache Camel in the belly of the Docker whaleApache Camel in the belly of the Docker whale
Apache Camel in the belly of the Docker whaleHenryk Konsek
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIWordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIBrian Hogg
 
Introduction to Play Framework
Introduction to Play FrameworkIntroduction to Play Framework
Introduction to Play FrameworkWarren Zhou
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkBo-Yi Wu
 
Developing Rest services with SailsJs by Andrey Kolodnitskiy
Developing Rest services with SailsJs by Andrey KolodnitskiyDeveloping Rest services with SailsJs by Andrey Kolodnitskiy
Developing Rest services with SailsJs by Andrey KolodnitskiyLohika_Odessa_TechTalks
 
Developing, Testing and Scaling with Apache Camel - UberConf 2015
Developing, Testing and Scaling with Apache Camel - UberConf 2015Developing, Testing and Scaling with Apache Camel - UberConf 2015
Developing, Testing and Scaling with Apache Camel - UberConf 2015Matt Raible
 
RESTful OSGi middleware for NoSQL databases with Docker
RESTful OSGi middleware for NoSQL databases with DockerRESTful OSGi middleware for NoSQL databases with Docker
RESTful OSGi middleware for NoSQL databases with DockerBertrand Delacretaz
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecturepostrational
 
Building an API with Django and Django REST Framework
Building an API with Django and Django REST FrameworkBuilding an API with Django and Django REST Framework
Building an API with Django and Django REST FrameworkChristopher Foresman
 
Scalable Django Architecture
Scalable Django ArchitectureScalable Django Architecture
Scalable Django ArchitectureRami Sayar
 

What's hot (20)

JCR and Sling Quick Dive
JCR and Sling Quick DiveJCR and Sling Quick Dive
JCR and Sling Quick Dive
 
Rapid RESTful Web Applications with Apache Sling and Jackrabbit
Rapid RESTful Web Applications with Apache Sling and JackrabbitRapid RESTful Web Applications with Apache Sling and Jackrabbit
Rapid RESTful Web Applications with Apache Sling and Jackrabbit
 
Building domain-specific testing tools : lessons learned from the Apache Slin...
Building domain-specific testing tools : lessons learned from the Apache Slin...Building domain-specific testing tools : lessons learned from the Apache Slin...
Building domain-specific testing tools : lessons learned from the Apache Slin...
 
The Evolution of Airbnb's Frontend
The Evolution of Airbnb's FrontendThe Evolution of Airbnb's Frontend
The Evolution of Airbnb's Frontend
 
Sails.js Intro
Sails.js IntroSails.js Intro
Sails.js Intro
 
Django rest framework
Django rest frameworkDjango rest framework
Django rest framework
 
Microservices with Spring Boot
Microservices with Spring BootMicroservices with Spring Boot
Microservices with Spring Boot
 
Magento 2 Workflows
Magento 2 WorkflowsMagento 2 Workflows
Magento 2 Workflows
 
Choosing a Javascript Framework
Choosing a Javascript FrameworkChoosing a Javascript Framework
Choosing a Javascript Framework
 
Dropwizard Internals
Dropwizard InternalsDropwizard Internals
Dropwizard Internals
 
Apache Camel in the belly of the Docker whale
Apache Camel in the belly of the Docker whaleApache Camel in the belly of the Docker whale
Apache Camel in the belly of the Docker whale
 
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST APIWordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
WordCamp Ann Arbor 2015 Introduction to Backbone + WP REST API
 
Introduction to Play Framework
Introduction to Play FrameworkIntroduction to Play Framework
Introduction to Play Framework
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Developing Rest services with SailsJs by Andrey Kolodnitskiy
Developing Rest services with SailsJs by Andrey KolodnitskiyDeveloping Rest services with SailsJs by Andrey Kolodnitskiy
Developing Rest services with SailsJs by Andrey Kolodnitskiy
 
Developing, Testing and Scaling with Apache Camel - UberConf 2015
Developing, Testing and Scaling with Apache Camel - UberConf 2015Developing, Testing and Scaling with Apache Camel - UberConf 2015
Developing, Testing and Scaling with Apache Camel - UberConf 2015
 
RESTful OSGi middleware for NoSQL databases with Docker
RESTful OSGi middleware for NoSQL databases with DockerRESTful OSGi middleware for NoSQL databases with Docker
RESTful OSGi middleware for NoSQL databases with Docker
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecture
 
Building an API with Django and Django REST Framework
Building an API with Django and Django REST FrameworkBuilding an API with Django and Django REST Framework
Building an API with Django and Django REST Framework
 
Scalable Django Architecture
Scalable Django ArchitectureScalable Django Architecture
Scalable Django Architecture
 

Similar to Apache Sling RESTful Web Apps Presentation

AEM and Sling
AEM and SlingAEM and Sling
AEM and SlingLo Ki
 
AEM and Sling
AEM and SlingAEM and Sling
AEM and SlingLokesh BS
 
REST API 20.2 - Appworks Gateway Integration.pptx
REST API 20.2 - Appworks Gateway Integration.pptxREST API 20.2 - Appworks Gateway Integration.pptx
REST API 20.2 - Appworks Gateway Integration.pptxJason452803
 
Open stack ocata summit enabling aws lambda-like functionality with openstac...
Open stack ocata summit  enabling aws lambda-like functionality with openstac...Open stack ocata summit  enabling aws lambda-like functionality with openstac...
Open stack ocata summit enabling aws lambda-like functionality with openstac...Shaun Murakami
 
Multi-container Applications on OpenShift with Ansible Service Broker
Multi-container Applications on OpenShift with Ansible Service BrokerMulti-container Applications on OpenShift with Ansible Service Broker
Multi-container Applications on OpenShift with Ansible Service BrokerAmazon Web Services
 
How Stuffle uses Docker for deployments
How Stuffle uses Docker for deploymentsHow Stuffle uses Docker for deployments
How Stuffle uses Docker for deploymentsRobinBrandt
 
Integrate any Angular Project into WebSphere Portal
Integrate any Angular Project into WebSphere PortalIntegrate any Angular Project into WebSphere Portal
Integrate any Angular Project into WebSphere PortalHimanshu Mendiratta
 
Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...
Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...
Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...mfrancis
 
Building Portable Applications with Kubernetes
Building Portable Applications with KubernetesBuilding Portable Applications with Kubernetes
Building Portable Applications with KubernetesKublr
 
Deploy and Access WebSphere Liberty and StrongLoop REST Endpoints on IBM Bluemix
Deploy and Access WebSphere Liberty and StrongLoop REST Endpoints on IBM BluemixDeploy and Access WebSphere Liberty and StrongLoop REST Endpoints on IBM Bluemix
Deploy and Access WebSphere Liberty and StrongLoop REST Endpoints on IBM BluemixArthur De Magalhaes
 
API Services: Building State-of-the-Art APIs
API Services: Building State-of-the-Art APIsAPI Services: Building State-of-the-Art APIs
API Services: Building State-of-the-Art APIsApigee | Google Cloud
 
High quality ap is with api platform
High quality ap is with api platformHigh quality ap is with api platform
High quality ap is with api platformNelson Kopliku
 
Web Apps atop a Content Repository
Web Apps atop a Content RepositoryWeb Apps atop a Content Repository
Web Apps atop a Content RepositoryGabriel Walt
 
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten ZiegelerOSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegelermfrancis
 
Scaling on EC2 in a fast-paced environment (LISA'11 - Full Paper)
Scaling on EC2 in a fast-paced environment (LISA'11 - Full Paper)Scaling on EC2 in a fast-paced environment (LISA'11 - Full Paper)
Scaling on EC2 in a fast-paced environment (LISA'11 - Full Paper)Nicolas Brousse
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kuberneteskloia
 

Similar to Apache Sling RESTful Web Apps Presentation (20)

AEM and Sling
AEM and SlingAEM and Sling
AEM and Sling
 
AEM and Sling
AEM and SlingAEM and Sling
AEM and Sling
 
REST API 20.2 - Appworks Gateway Integration.pptx
REST API 20.2 - Appworks Gateway Integration.pptxREST API 20.2 - Appworks Gateway Integration.pptx
REST API 20.2 - Appworks Gateway Integration.pptx
 
Open stack ocata summit enabling aws lambda-like functionality with openstac...
Open stack ocata summit  enabling aws lambda-like functionality with openstac...Open stack ocata summit  enabling aws lambda-like functionality with openstac...
Open stack ocata summit enabling aws lambda-like functionality with openstac...
 
Multi-container Applications on OpenShift with Ansible Service Broker
Multi-container Applications on OpenShift with Ansible Service BrokerMulti-container Applications on OpenShift with Ansible Service Broker
Multi-container Applications on OpenShift with Ansible Service Broker
 
How Stuffle uses Docker for deployments
How Stuffle uses Docker for deploymentsHow Stuffle uses Docker for deployments
How Stuffle uses Docker for deployments
 
Integrate any Angular Project into WebSphere Portal
Integrate any Angular Project into WebSphere PortalIntegrate any Angular Project into WebSphere Portal
Integrate any Angular Project into WebSphere Portal
 
Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...
Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...
Creating an all-purpose REST API for Cloud services using OSGi and Sling - C ...
 
Building Portable Applications with Kubernetes
Building Portable Applications with KubernetesBuilding Portable Applications with Kubernetes
Building Portable Applications with Kubernetes
 
Shipping logs to splunk from a container in aws howto
Shipping logs to splunk from a container in aws howtoShipping logs to splunk from a container in aws howto
Shipping logs to splunk from a container in aws howto
 
Deploy and Access WebSphere Liberty and StrongLoop REST Endpoints on IBM Bluemix
Deploy and Access WebSphere Liberty and StrongLoop REST Endpoints on IBM BluemixDeploy and Access WebSphere Liberty and StrongLoop REST Endpoints on IBM Bluemix
Deploy and Access WebSphere Liberty and StrongLoop REST Endpoints on IBM Bluemix
 
API Services: Building State-of-the-Art APIs
API Services: Building State-of-the-Art APIsAPI Services: Building State-of-the-Art APIs
API Services: Building State-of-the-Art APIs
 
High quality ap is with api platform
High quality ap is with api platformHigh quality ap is with api platform
High quality ap is with api platform
 
Web Apps atop a Content Repository
Web Apps atop a Content RepositoryWeb Apps atop a Content Repository
Web Apps atop a Content Repository
 
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten ZiegelerOSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
OSGi Enterprise R6 specs are out! - David Bosschaert & Carsten Ziegeler
 
London Hug 20/6 - Vault production
London Hug 20/6 - Vault productionLondon Hug 20/6 - Vault production
London Hug 20/6 - Vault production
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 
Scaling on EC2 in a fast-paced environment (LISA'11 - Full Paper)
Scaling on EC2 in a fast-paced environment (LISA'11 - Full Paper)Scaling on EC2 in a fast-paced environment (LISA'11 - Full Paper)
Scaling on EC2 in a fast-paced environment (LISA'11 - Full Paper)
 
sveltekit-en.pdf
sveltekit-en.pdfsveltekit-en.pdf
sveltekit-en.pdf
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kubernetes
 

More from Bertrand Delacretaz

VanillaJS & the Web Platform, a match made in heaven?
VanillaJS & the Web Platform, a match made in heaven?VanillaJS & the Web Platform, a match made in heaven?
VanillaJS & the Web Platform, a match made in heaven?Bertrand Delacretaz
 
Surviving large online communities with conciseness and clarity
Surviving large online communities with conciseness and clarity Surviving large online communities with conciseness and clarity
Surviving large online communities with conciseness and clarity Bertrand Delacretaz
 
Repoinit: a mini-language for content repository initialization
Repoinit: a mini-language for content repository initializationRepoinit: a mini-language for content repository initialization
Repoinit: a mini-language for content repository initializationBertrand Delacretaz
 
The Moving House Model, adhocracy and remote collaboration
The Moving House Model, adhocracy and remote collaborationThe Moving House Model, adhocracy and remote collaboration
The Moving House Model, adhocracy and remote collaborationBertrand Delacretaz
 
GraphQL in Apache Sling - but isn't it the opposite of REST?
GraphQL in Apache Sling - but isn't it the opposite of REST?GraphQL in Apache Sling - but isn't it the opposite of REST?
GraphQL in Apache Sling - but isn't it the opposite of REST?Bertrand Delacretaz
 
How to convince your left brain (or manager) to follow the Open Source path t...
How to convince your left brain (or manager) to follow the Open Source path t...How to convince your left brain (or manager) to follow the Open Source path t...
How to convince your left brain (or manager) to follow the Open Source path t...Bertrand Delacretaz
 
L'Open Source change le Monde - BlendWebMix 2019
L'Open Source change le Monde - BlendWebMix 2019L'Open Source change le Monde - BlendWebMix 2019
L'Open Source change le Monde - BlendWebMix 2019Bertrand Delacretaz
 
Shared Neurons - the Secret Sauce of Open Source communities?
Shared Neurons - the Secret Sauce of Open Source communities?Shared Neurons - the Secret Sauce of Open Source communities?
Shared Neurons - the Secret Sauce of Open Source communities?Bertrand Delacretaz
 
Sling and Serverless, Best Friends Forever?
Sling and Serverless, Best Friends Forever?Sling and Serverless, Best Friends Forever?
Sling and Serverless, Best Friends Forever?Bertrand Delacretaz
 
Serverless - introduction et perspectives concrètes
Serverless - introduction et perspectives concrètesServerless - introduction et perspectives concrètes
Serverless - introduction et perspectives concrètesBertrand Delacretaz
 
State of the Feather - ApacheCon North America 2018
State of the Feather - ApacheCon North America 2018State of the Feather - ApacheCon North America 2018
State of the Feather - ApacheCon North America 2018Bertrand Delacretaz
 
Karate, the black belt of HTTP API testing?
Karate, the black belt of HTTP API testing?Karate, the black belt of HTTP API testing?
Karate, the black belt of HTTP API testing?Bertrand Delacretaz
 
Open Source at Scale: the Apache Software Foundation (2018)
Open Source at Scale: the Apache Software Foundation (2018)Open Source at Scale: the Apache Software Foundation (2018)
Open Source at Scale: the Apache Software Foundation (2018)Bertrand Delacretaz
 
They don't understand me! Tales from the multi-cultural trenches
They don't understand me! Tales from the multi-cultural trenchesThey don't understand me! Tales from the multi-cultural trenches
They don't understand me! Tales from the multi-cultural trenchesBertrand Delacretaz
 
Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)
Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)
Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)Bertrand Delacretaz
 
Project and Community Services the Apache Way
Project and Community Services the Apache WayProject and Community Services the Apache Way
Project and Community Services the Apache WayBertrand Delacretaz
 
La Fondation Apache - keynote au Paris Open Source Summit 2017
La Fondation Apache - keynote au Paris Open Source Summit 2017La Fondation Apache - keynote au Paris Open Source Summit 2017
La Fondation Apache - keynote au Paris Open Source Summit 2017Bertrand Delacretaz
 
Asynchronous Decision Making - FOSS Backstage 2017
Asynchronous Decision Making - FOSS Backstage 2017Asynchronous Decision Making - FOSS Backstage 2017
Asynchronous Decision Making - FOSS Backstage 2017Bertrand Delacretaz
 
Building an Apache Sling Rendering Farm
Building an Apache Sling Rendering FarmBuilding an Apache Sling Rendering Farm
Building an Apache Sling Rendering FarmBertrand Delacretaz
 

More from Bertrand Delacretaz (20)

VanillaJS & the Web Platform, a match made in heaven?
VanillaJS & the Web Platform, a match made in heaven?VanillaJS & the Web Platform, a match made in heaven?
VanillaJS & the Web Platform, a match made in heaven?
 
Surviving large online communities with conciseness and clarity
Surviving large online communities with conciseness and clarity Surviving large online communities with conciseness and clarity
Surviving large online communities with conciseness and clarity
 
Repoinit: a mini-language for content repository initialization
Repoinit: a mini-language for content repository initializationRepoinit: a mini-language for content repository initialization
Repoinit: a mini-language for content repository initialization
 
The Moving House Model, adhocracy and remote collaboration
The Moving House Model, adhocracy and remote collaborationThe Moving House Model, adhocracy and remote collaboration
The Moving House Model, adhocracy and remote collaboration
 
GraphQL in Apache Sling - but isn't it the opposite of REST?
GraphQL in Apache Sling - but isn't it the opposite of REST?GraphQL in Apache Sling - but isn't it the opposite of REST?
GraphQL in Apache Sling - but isn't it the opposite of REST?
 
Open Source Changes the World!
Open Source Changes the World!Open Source Changes the World!
Open Source Changes the World!
 
How to convince your left brain (or manager) to follow the Open Source path t...
How to convince your left brain (or manager) to follow the Open Source path t...How to convince your left brain (or manager) to follow the Open Source path t...
How to convince your left brain (or manager) to follow the Open Source path t...
 
L'Open Source change le Monde - BlendWebMix 2019
L'Open Source change le Monde - BlendWebMix 2019L'Open Source change le Monde - BlendWebMix 2019
L'Open Source change le Monde - BlendWebMix 2019
 
Shared Neurons - the Secret Sauce of Open Source communities?
Shared Neurons - the Secret Sauce of Open Source communities?Shared Neurons - the Secret Sauce of Open Source communities?
Shared Neurons - the Secret Sauce of Open Source communities?
 
Sling and Serverless, Best Friends Forever?
Sling and Serverless, Best Friends Forever?Sling and Serverless, Best Friends Forever?
Sling and Serverless, Best Friends Forever?
 
Serverless - introduction et perspectives concrètes
Serverless - introduction et perspectives concrètesServerless - introduction et perspectives concrètes
Serverless - introduction et perspectives concrètes
 
State of the Feather - ApacheCon North America 2018
State of the Feather - ApacheCon North America 2018State of the Feather - ApacheCon North America 2018
State of the Feather - ApacheCon North America 2018
 
Karate, the black belt of HTTP API testing?
Karate, the black belt of HTTP API testing?Karate, the black belt of HTTP API testing?
Karate, the black belt of HTTP API testing?
 
Open Source at Scale: the Apache Software Foundation (2018)
Open Source at Scale: the Apache Software Foundation (2018)Open Source at Scale: the Apache Software Foundation (2018)
Open Source at Scale: the Apache Software Foundation (2018)
 
They don't understand me! Tales from the multi-cultural trenches
They don't understand me! Tales from the multi-cultural trenchesThey don't understand me! Tales from the multi-cultural trenches
They don't understand me! Tales from the multi-cultural trenches
 
Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)
Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)
Prise de Décisions Asynchrone, Devoxx France 2018 (avec vidéo)
 
Project and Community Services the Apache Way
Project and Community Services the Apache WayProject and Community Services the Apache Way
Project and Community Services the Apache Way
 
La Fondation Apache - keynote au Paris Open Source Summit 2017
La Fondation Apache - keynote au Paris Open Source Summit 2017La Fondation Apache - keynote au Paris Open Source Summit 2017
La Fondation Apache - keynote au Paris Open Source Summit 2017
 
Asynchronous Decision Making - FOSS Backstage 2017
Asynchronous Decision Making - FOSS Backstage 2017Asynchronous Decision Making - FOSS Backstage 2017
Asynchronous Decision Making - FOSS Backstage 2017
 
Building an Apache Sling Rendering Farm
Building an Apache Sling Rendering FarmBuilding an Apache Sling Rendering Farm
Building an Apache Sling Rendering Farm
 

Recently uploaded

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 

Recently uploaded (20)

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 

Apache Sling RESTful Web Apps Presentation

  • 1. Bertrand Delacrétaz Senior Developer, CQ5 R&D team, Adobe Basel Apache Software Foundation Member and (current) Director @bdelacretaz - http://grep.codeconsult.ch Lausanne, May 2013 slides revision: 2013-05-30 1 RESTfulwebapps withApacheSling
  • 2. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Apache Sling: OSGi-based applications layer for JCR 2 content everything is
  • 3. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Everything is content! 3 Any app that requires more than curl as a minimal client should have a good reason. Java content repository JCR API Apache SlingHTTP Let’sbuildan intelligentWeb server.
  • 4. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Content? 4 design everything website code
  • 5. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Website Content 5 /content /geometrixx /en /company /jcr:content /par /title sling:resourceType drives rendering
  • 6. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 6 Apache Sling «any» scripting languagescript == servlet OSGi- based RESTful default servlets sling.apache.org
  • 7. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Sling Architecture Overview 7 OSGi framework (Apache Felix) WebDAV server Felix OSGi console JCR content repository JCR API ECMAscript JSP Ruby Velocity JSR 223 scripting resource resolution servlet/ script standard servlets custom servlets Sling Core
  • 8. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Sling is based on OSGi Extreme modularity Fosters better structured code Dynamic plugins - for everything! In-JVM Service-based architecture 8 OSGi bundle Private packages Public packages Metadata Matchless picture: Alvimann on morguefile.com
  • 9. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Clean URLs with Sling: «Reclaiming the Web» Sling /cars/audi/s4.details.html Content Repository Path Selectorsand extension 9 sling:resourceType
  • 10. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Sling Sample Application Slingbucksa RESTful coffee shop 10
  • 11. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Slingbucks Application Flow Customers, public content Staff, private content 11
  • 12. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Slingbucks use cases: Order Coffee Display order form with configurable options. Customer submits order. Redisplay order for confirmation with hard to guess ID. 1 Content: 12 POST
  • 13. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Slingbucks use cases: Confirm Order Redisplay order form. Customer either modifies and recalculates price, or confirms order. 1 2Content: 13 POST GET
  • 14. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Slingbucks Process Order use case and content Confirmed order moves under /private, for Slingbucks staff App displays a list of confirmed orders to staff. Staff delivers order and deletes it from list. 3 Orders really move! 14
  • 15. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Slingbucks Resources Design Security/ACLs MeaningfulURLs 1:1JCRpathmapping Object-oriented design? No: everything is content: we want RESTful resources. 15 New order form: http://slingbucks.com/public/orders.html Order editing and confirmation (example): http://slingbucks.com/public/orders/544da609.html Price of an order: Same but ending with .price.html selector List of confirmed orders: http://slingbucks.com/private/confirmed.html
  • 16. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Sling gets the Web! 16 allyouneediscurlor any other HTTP client
  • 17. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. The SlingPostServlet $ curl -D - -F "customerName=Bob The Geek" -F sling:resourceType=slingbucks/order -F lastModified="" -F opt_coffeetype=capuccino -F opt_size=medium -F opt_sugar=raw -F opt_cup=rosewood http://u:pwd@slingserver/content/slingbucks/public/orders/ HTTP/1.1 201 Created Location: /slingbucks/public/orders/117936075d4de452cbba5b468 17 SlingPostServlet JCR content repository JCR API HTTP POST
  • 18. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Default JSON GET servlet $ curl http://localhost:8080/content /slingbucks/public/orders /fad01d62ca54209a1405e3b.tidy.json { "opt_size": "small", "customerName": "Bob the Geek", "opt_coffeetype": "espresso", "opt_sugar": "none", "sling:resourceType": "slingbucks/order", "opt_cup": "plastic", "lastModified": "Nov 01 2010 18:31:01", "jcr:primaryType": "nt:unstructured" } 18 DefaultGetServlet JCR content repository JCR API HTTP GET JSON
  • 19. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Slingbucks Sample App codeJust two OSGi services and a few presentation scripts 19 Writinglotsof code? Maybeyou shouldn’t
  • 20. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Code: OSGi plugin for hard to guess node names 20 /** OSGi SCR instantiates this and registers as Service */ @Component @Service public class HexNodeNameGenerator implements org.apache.sling..NodeNameGenerator { @Override /** Sling calls this when creating a node */ public String getNodeName( SlingHttpServletRequest request, String parentPath, ...) { ...if path is in slingbucks tree: return computeHardToGuessName(); ...else return null maven-scr- plugin processes
  • 21. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Code: watch repository to move confirmed orders /** OSGi SCR instantiates this */ @Component public class ConfirmedOrdersObserver implements EventListener, Runnable { /** OSGi SCR provides this */ @Reference private SlingRepository repository; /** OSGi SCR calls this at startup */ protected void activate(ComponentContext ctx){ // Register with repository // to callback our onEvent method // on changes under /content/slingbucks/orders ... public void onEvent(EventIterator it) { while (it.hasNext()) { if(path.endsWith(«orderConfirmed») { ... if orderConfirmed property is true: ... move node under private/ confirmed ... using session.getWorkspace().move(.... 21 Orders really move! TwoJava methodsina Component
  • 22. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Coffee options? defined by content - "fields" : { "coffeetype" : { "jcr:title" : "Coffee type", "espresso" : { "jcr:title" : "Espresso", "jcr:description" : "The Italian job", "priceOffset" : 2.20 }, "capuccino" : { "jcr:title" : "Capuccino", "jcr:description" : "The one with cream on top", "priceOffset" : 3.40 } }, "size" : { "jcr:title" : "Size", "small" : { "jcr:title" : "Small", "jcr:description" : "1dl", "priceFactor" : 1 }, "large" : { "jcr:title" : "Large", "jcr:description" : "5dl", "priceFactor" : 2 } } HTTP GET with .json extension. POST to set values. (out of the box) 22 Reconfigure in-flight withcurl!
  • 23. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Slingbucks code size Java code: 250 lines 3 java files HTML representation scripts: 250 lines 7 esp files Initial repository content: 85 lines 3 json files Style and client-side javascript: 43 lines 1 css and 1 js file Scripts and design content: 23 Writinglotsofcode? Maybeyoushouldn’t
  • 24. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Did I mention this already? Sling design promotes RESTful applications. Powerful out of the box HTTP services. OSGi plugins for (most) everything. 24 Java content repository JCR API Apache Sling Writinglotsof code? Maybeyou shouldn’t everything is content!
  • 25. © 2011 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Where next? 25 Code at http://s.apache.org/slingbucks Code and community at sling.apache.org OSGi info at www.osgi.org Slides at www.slideshare.net/bdelacretaz