Webmardi - 07.07.2015
at Lausanne
Content-centric web
architectures
Case study : Apache Sling
Fabrice HongMatthieu CornutTitouan Galopin
AEM team AEM team
Agenda
1. What is a CMS?
2. Content-centric design
3. Sling content delivery
4. How Sling uses the JCR
5. Demo
1.What is a CMS?
Content
Management
System
Editable by the author
=
Not managed by developer
The aim: let the author
manage as much things
as possible
What is really editable
by the author?
The minimal CMS
The minimal CMS
Editable pages
Content edition
The minimal CMS
Editable pages
Content edition
id title body date
1 Accueil Bienvenue ... 07-07-15
... ... ... ...
The classical CMS
The classical CMS
Editable pages organised
in categories
Content organisation
The classical CMS
Editable pages organised
in categories
Content organisation
id parent title body date
1 NULL Accueil Bienvenue! 07-07-15
2 1 Sous-page ... 07-07-15
The enterprise CMS
The enterprise CMS
Editable types of content
Content type composition
The enterprise CMS
Editable types of content
Content type composition
Implementation ? Hum ...
The ideal way: nodes
Most generic storage method
when to use it ?
2. Content-centric design
structure
data
Who is the leader ?
structure
data
Back to IT
Predefine the structure Let the structure emerge
or
Ask yourself
Is it known in advance ?
● The final result
● The evolution
o consumers
o the interface
o the scale
Caching - ajax injection
Caching - SSI
CDN Caching - ajax injection
Add servers
Thin / Thick client
CDN Caching - ESI
! page loading, SEO
! dev env.
! business logic, SEO
! server price
Visitor number
Visitor location
Interactivity
Slow Backend
integration
Evolutions Solutions Down sides
moreover, conditions are constantly
evolving...
The right balance is not
easy to choose
STRUCTURE FIRST in an
impredictible ecosystem
or, how should we extend the house ?
DATA FIRST can be ambivalent
Apache Sling
a content-centric web framework
Some history about Apache Sling
● Initially : internal framework powering CQ5 (WCMS from Day Software)
● 2007 - Donated to Apache Software foundation
● 2009 - Graduated as Apache top level project
● 2010 - Day Software aquired by Adobe. CQ5 renamed to AEM
● Sling still used by AEM
Java Content Repository (JCR)
Stack
Apache Sling
Java Runtime Environement
Servlet Engine App Server (optional)
OSGIFramework
CMS App
Apache Felix
Apache
Jackrabbit
And how you *should* leverage it
3. How Sling uses the JCR
Before all : some specs
A CMS data structure
Hierarchies can store nearly every logic in a natural and readable way
JCR features
“Content Repositories are the best of
databases and file systems”
JCR 1.0 : JSR-170
JCR 2.0 : JSR-283
How do Sling uses the JCR ?
title
author
news list content
navigation
footer
edit
Example : online newspaper website
Services
Controller
Templates
Url
Mapping
Url
Mapping
● Mapping news?id=23 -> newsController
● Get / store content from database
● Map content to template vars
● Select template
● CRUD
● Access Control Management
● Versioning
Services
Controller
Templates
DatabaseDatabase
Server
Static
Standard web framework
Web
Client
In Sling, it will be entirely in database
Typical content
● Page organisation
● Internal page structure
● Authoring content
But also:
Validation rules
Rendition scripts Jobs
Java
The answer to life, the universe and
everything
The JCR
In a Sling application :
● Externalize what does not require java skills
o rapid testing / developing / demos
o visualisation (in opposition to JAR content)
● Leverage JCR features
Practical for development
news-list
news1
news2
Filesystem
mappable ● Human readable
● IDE friendly
● VCS friendly
JCR (Apache Jackrabbit)
And Sling ?
Apache Sling
Java Runtime Environement
Servlet Engine App Server (optional)
OSGIFramework
CMS App
events, search, versioning, access control
?
How a Sling application *should* interact
with the JCR ?
4. Sling Content Delivery
Services
Controller
Templates
Url
Mapping
Url
Mapping
Services
Controller
Templates
Database
Server
Static logic
Standard webapp
Web
Client
Database
Server
Web
Client
REST API
binding
Sling idea
Java Content Repository (JCR)
REST:
● CRUD ops. for each nodes
○ GET, POST, PUT, DELETE
● Cacheable
● Stateless / scalable
Templates /
ComponentsContent
Server
Web
Client
REST API
binding
Sling idea
Java Content Repository (JCR)
Templates /
ComponentsContent
Content first !
website/news.jsp?id=341
website/news/webmardi/2015_07_07-sling.html
How to write in database ?
<form method="POST">
<input type="text" name="title"/>
<input type="text" name="content"/>
<input type="submit" name="save"/>
</form>
Security ? Binding Logic ?
Access
Control
Management
Event
observation
Servlet / Filters
OSGI
Services
● REST force server side simplicity
● Boilerplate layers replaced by safeguards
● Everything that is externalized in JCR is interoperable
The client chose the
representation
content
news-list
news1
news2
components
news
news.jsp
.content.xml
title
contentof type
refers
Server
news-list/news2.html
news-list/news2.small.html
Content representation
small.jsp
Web
Client
path selector extension (additional discriminator for servlet)
Sling rendering resolution
news.esp
<div class="newsTitle">
<%= currentNode.title %>
</div>
<div>
<div class="newsContent">
<%= currentNode.content %>
</div>
<% sling.include("./author", "replaceSelectors=quickLink") %>
</div>
Scriptable in
● JSP
● ESP
● Groovy
● Ruby
● Velocity
More resilient to external
evolution ?
Caching - ajax injection
Caching - SSI
CDN Caching - ajax injection
Add servers
Thin / Thick client
CDN Caching - ESI
! page loading, SEO
! dev env.
! business logic, SEO
! server price
Visitor number
Visitor location
Interactivity
Slow Backend
integration
Evolutions Solutions Down sides
Component inclusion
newsList
news1
news2
Application Server Web Server
CDN
other content
Switzerland
Cache
China
Application includes Server side includes Ajax includes
ajax or html include
ajax or html include
Conditions for ambivalence
Must be flexible on:
where components are included
how to the components is represented
content-centric -> independence of components :
each component is responsible for loading its data and dependencies
newsList/news1.html
newsList/news1.json
newsList/news1.small.html
Extreme example
Sling Dynamic Include allows to switch dynamically
between :
● Server side include
● Edge side include
● Ajax include
5. Demo
Summary
● Structure first or Data first
o One shot project / Evolutive system
o relation with agilty ?
● Go along with the technology
o leverage JCR features
o leverage sling REST approach
Content-centric architectures - case study : Apache Sling

Content-centric architectures - case study : Apache Sling

Editor's Notes

  • #2 test
  • #22 Une resource
  • #23 religions ? vous êtes surement du premier groupe utile pour des gens qui doivent conseiller sur les techno http://dev.day.com/content/ddc/blog/2008/10.html
  • #24 analogie
  • #28 Parfois on ne peux pas savoir a l’avance: L’évolution le poid que va avoir chaque désavantage
  • #35 OSGI: Qui ne connait pas OSGI ? plateforme de bundles java communiquants entre eux, et pouvant être installés ou desinstallés a la volée pas besoin de redemarrer tout le systeme Sling coder sa web app directement. Egalement une excellente base pour coder son CMS. AEM ou CQ5 est dessus.
  • #36 C’est une couche de persistance. Mais elle offre des fonctionnalités bcp plus haut niveau. Ces fonctionnalités orientent le programmeur déjà très tot a concevoir son application d’une manière différente
  • #39 best phrase
  • #41 partons d’un exemple concret composition des pages edition des articles
  • #42 1) ce mécanisme n’existe plus, en tout cas pas par page, puisqu’on ne peut connaitre le contenu de la page a l’avance. 2) Tout avoir en tant que composants n’est pas forcément obligatoire pour un CMF générique. Tout veux dire mais distinction
  • #44 Validation rules
  • #45 La business logique reste a coder. Tout ce qui est wiring, représenation des données eventing, versionning exemple : Validation rules
  • #46 concerns especially the authoring content
  • #47 On s’attendrait d’un framework web qu’il fasse ca, mais non
  • #48 *should*
  • #50 REST REST propose un style d’architecture de service qui reflète le JCR Avantages sont bien connus stateless: REST n’expose que des resources au client, avec des operations simples evite de: stocker l’etat courant coté serveur : scalable simplifie la logique serveur : pas besoin de gérer cette multitude d’états
  • #51 REST REST propose un style d’architecture de service qui reflète le JCR Avantages sont bien connus stateless: REST n’expose que des resources au client, avec des operations simples evite de: stocker l’etat courant coté serveur : scalable simplifie la logique serveur : pas besoin de gérer cette multitude d’états
  • #52 exemple de la “Validation”
  • #55 improve
  • #60 content centric sling
  • #62 Approche incrémentale
  • #63 Go along with the technology java for business logic do guide lines store naturally on jcr Data first flexible to evolutions scalable way of coding also solve non CMS problems