42
http://robert.muntea.nu @rombert Effective Web Application Development with Apache Sling Effective Web Application Development with Apache Sling Robert Munteanu, Adobe Systems CodeCamp Iași 2016

Effective web application development with Apache Sling

Embed Size (px)

Citation preview

Page 1: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Effective Web Application Development with Apache Sling

Effective Web Application Developmentwith Apache Sling

Robert Munteanu, Adobe SystemsCodeCamp Iași 2016

Page 2: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Agenda

● What is Apache Sling?● Content-Driven/RESTful applications● What can Sling do for me?● Demo● Wrap-up

Page 3: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

What is Apache Sling?

● What is Apache Sling?● Content-Driven/RESTful applications● What can Sling do for me?● Demo● Wrap-up

Page 4: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Modular

Page 5: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

RESTful

Page 6: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Serve

Page 7: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Library?

Page 8: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Application Server?

Page 9: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

It’s Apache Sling!

Page 10: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

What is Apache Sling?

Content-DrivenRESTful applications Modularity

Less @Magic,Fewer @SuprisesOpen Source

Page 11: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

History

2007Incubation

2009TLP

2015Version 8

200xPre-Apache

Page 12: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Code statistics

Page 13: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Content-driven, RESTful applications

● What is Apache Sling?● Content-Driven/RESTful applications● What can Sling do for me?● Demo● Wrap-up

Page 14: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

What is a content-driven application?

Page 15: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

What is a not a content-driven application?

● HTTP proxy for anonymity● Bitcoin miners● Stock exchange trading

Page 16: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

What does a content-driven application consist of?

Data Code

Page 17: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

What is a resource?

● The smallest individually addressable unit● Minimally has a name● Key-value for properties● Optionally has a parent● Optionally has a child

Page 18: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

What is a resource?

GET /news/sling/release-8.html HTTP/1.1

Page 19: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Resources – Blog post

/posts/hello_world.html

Title : Hello, world Body: ... Author [/users/admin] Publish date: 2016-01-01T23:00:00Z Comments [/comments/hello_world/resources] Images [/comments/hello_world/assets]

Page 20: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Resources – User

/users/admin.json

Name: admin Last logged in: 2012-05-13T12:00:00Z Enabled: false

Page 21: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Resources – Image

/assets/cat_laser_pointer.jpg

Name: Cat following laser pointer. LOL! Media type: image/jpeg Contents: <binary> Thumbs: [/assets/cat_laser_pointer/renditions]

Page 22: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Serving content – Controller-driven

@GetMethod@AtLocation(“/users/{name}.html”)public byte[] handleUser(String name) { … }

map “users”map “articles” as “news”GET “images”

Page 23: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Serving content – Controller-driven

WelcomeController/

UserController/users

ArticleController/articles

Page 24: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Serving content – resource-driven

Page 25: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Serving content – resource-driven

/ [sling:redirect]

content [my/site/listing] news [my/site/listing]

sling-launchpad-8 [my/site/article] sling-ide-tooling-11 [my/site/article]

assets [sling:Folder] sling_logo.png [nt:file]

Page 26: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

What can Sling do for me?

● What is Apache Sling?● Content-Driven/RESTful applications● What can Sling do for me?● Demo● Wrap-up

Page 27: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Persistence using JCR

Page 28: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Modularity with OSGi

● The solution we chose for modularity and services● Comes with lots of add-ons:

● Eventing● Administrative console● Configuration● Hot deployment● etc

● Forces application to handle the “real-world” dynamics● Easy configuration using annotations

Page 29: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Pluggable repositories

JCR

MongoDB

Couchbase

Filesystem

Page 30: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Pluggable authentication

Oauth

FormOak

Externale.g. LDAP

Basic HTTP

Page 31: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Templating engines

Page 32: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Others …

● Caching● Eventing● Logging● Health Checks● XSS protection● Validation

Page 33: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Developer Tools

Page 34: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Deployment options

Page 35: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Deployment Topologies - Standalone

Sling + OakSegment NodeStore

HTTP Frontend(httpd, varnish, nginx, etc )

Page 36: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Deployment Topologies

HTTP Frontend(httpd, varnish, nginx, etc )

Sling + OakDocument NodeStore

MongoDB

Sling + OakDocument NodeStore

Page 37: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Adminstrative web console

Page 38: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Adminstrative web console

Page 39: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Adminstrative web console

Page 40: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Adminstrative web console

Page 41: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Demo

● What is Apache Sling?● Content-Driven/RESTful applications● What can Sling do for me?● Demo● Wrap-up

Page 42: Effective web application development with Apache Sling

http://robert.muntea.nu @rombert

Resources

● https://sling.apache.org● https://jackrabbit.apache.org/oak/● http://www.slideshare.net/rombertw/ ● @rombert