0% found this document useful (0 votes)
94 views

Effective Web Application Development With Apache Sling 0

The document discusses the Apache Sling framework for building web applications. It provides an overview of Apache Sling including its history and activity level. The key concepts behind Apache Sling are that it is OSGi-powered, REST-based, content-driven, and allows for scripting inside. The main building blocks discussed are resource types, script resolution, request selectors, resource providers, and the Java Content Repository (JCR). The document also covers how to build Sling applications through modeling content in the JCR, reading from the repository, extensions, and deployment.

Uploaded by

Shashank Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views

Effective Web Application Development With Apache Sling 0

The document discusses the Apache Sling framework for building web applications. It provides an overview of Apache Sling including its history and activity level. The key concepts behind Apache Sling are that it is OSGi-powered, REST-based, content-driven, and allows for scripting inside. The main building blocks discussed are resource types, script resolution, request selectors, resource providers, and the Java Content Repository (JCR). The document also covers how to build Sling applications through modeling content in the JCR, reading from the repository, extensions, and deployment.

Uploaded by

Shashank Singh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

Effective Web Application

Development with Apache Sling


Robert Munteanu ( @rombert ) , Adobe Systems Romania

About the Speaker

Apache Sling PMC member

Fanboy of the Sling/JCR/OSGi stack

Enthusiastic Open-Source contributor

Senior Computer Scientist at Adobe in Romania

Speaker.currentSpeaker().interrupt();

11/18/14

Presentation Flow

Quick facts and figures

Conceptual foundations

Building blocks

Building Sling applications

11/18/14

Quick facts and figures

Apache Sling - History

200x

Pre-Apache

11/18/14

2007

incubation

2009
TLP

2014

Version 7

Apache Sling High-level View of the Code

Source: OpenHub

11/18/14

Apache Sling - Activity Level

Source: OpenHub

Source: status.apache.org
11/18/14

Conceptual Foundations

Apache Sling Conceptual Foundations

OSGi-powered

REST-based
Content-driven
Apache

11/18/14

Scripting inside

Apache Sling Apache Open Source

17

Felix

Aries

ServiceMix

Commons

Geronimo

11/18/14

Jackrabbit

Derby

Tika

10

Apache Sling REST-based

/blog/{0}.html
/blog/

11/18/14

BlogViewController
BlogListController

HomeController

/
/blog
/blog/hello-world

SlingMainServlet

11

Apache Sling Content-Driven


blog
hello-world
jcr:content
images
some-cat.jpg
other-cat.jpg

11/18/14

12

Apache Sling Content-Driven

some-cat.jpg
- jcr:primaryType = app:asset
- jcr:title = Some Cat
- jcr:description = A longer description of this picture
of a cat
- jcr:created = 2014-06-03T00:00:00.000+02:00
- jcr:lastUpdated = 2014-06-03T11:00:00.000+02:00
- tags = [Animal, Cat, Color]
- width = 400
- height = 600

11/18/14

13

Apache Sling Scripting Inside

JSP

11/18/14

14

Apache Sling Scripting Inside


libs
blogapp
welcome.jsp
welcome
json.html

11/18/14

15

Apache Sling OSGi-powered

Provision and deploy bundles

Configure, register and lookup services

Eventing

Web Console

11/18/14

16

Building blocks

Apache Sling Serving a request


GET /blog/welcome.html

/blog/welcome

11/18/14

???

myblog/blog.groovy

18

Apache Sling Resource Types


blog [blogapp/listing]
hello-world
jcr:content [blogapp/blog/content]
images
some-cat.jpg
other-cat.jpg

11/18/14

19

Apache Sling Script Resolution


GET /blog.html

Type: blogapp/listing
Extension: html
Method: GET

/libs/blogapp/listing.jsp
/libs/blogapp/listing/html.jsp
@SlingServlet(resourceTypes=blogapp/list
ing,...)
11/18/14

20

Apache Sling Request Selectors


GET /blog.rss.xml

Type: blogapp/listing
Extension: xml
Selector: rss
Method: GET

/libs/blogapp/listing/rss.html

11/18/14

21

Apache Sling Resource Providers

JCR
FS

11/18/14

/
/content/
/content/comments
/logs

MongoDB
Cassandra

22

Apache Sling JCR

11/18/14

23

Apache Sling JCR implementations

Apache Jackrabbit Oak

11/18/14

24

Building Sling Applications

Apache Sling JCR modeling


images
some-cat.jpg
renditions

File upload
Observation

small.jpg
ripple.jpg
annotations

ACLs

initial-review
11/18/14

26

Apache Sling - JCR


etc
rendition
ripple
- orientation = /etc/rendition/ripple/options
/orientation/vertical
- antialiasing = true
- edges = /etc/rendition/ripple/options/
edges/wrap
- wave type = /etc/rendition/ripple/options/
wave_type/simple
- period = 20
- amplitude = 5
11/18/14

27

Apache Sling Everything is a Resource

Everything is a Resource

11/18/14

28

Apache Sling Reading from the Repository


@SlingServlet(resourceTypes = "blogapp/listing",
extensions = "xml", methods = "GET")
public class RSSFeedServlet extends
SlingSafeMethodsServlet {
@Override
protected void doGet(SlingHttpServletRequest request,
SlingHttpServletResponse response) throws
ServletException, IOException {
// actual implementation
}
}

11/18/14

29

Apache Sling Reading from the Repository


Resource res = request.getResource();
ValueMap properties =
res.adaptTo(ValueMap.class);
String title = properties.get(jcr:title,
Missing);
Post post = res.adaptTo(Post.class);
title = post.getTitle();

11/18/14

30

Apache Sling - Extensions

Thread Pools and Scheduled Tasks

I18n

Caching

Models

Health Checks

Eventing

11/18/14

31

Apache Sling - SlingQuery


Get the closest Folder parent
$(resource).parents("sling:Folder").last();

Get the second child of each resource


$(resource1, resource2).children(":eq(1)");

Find children named en or de


$(resource).children("#en, #de")

11/18/14

32

Apache Sling - Deployment

Single executable Jar or War file the Sling launchpad


Configuration defined in multiple text files, defining bundles,
configuration, variables, bootstrap commands, etc

11/18/14

33

Apache Sling Provisioning Model


[feature name=main]
[variables]
io.version=1.4
[configurations]
org.apache.jackrabbit.....SegmentNodeStoreService
name="Default\ NodeStore"
repository.home="sling/oak/repository"
[artifacts startLevel=5]
commons-io/commons-io/${io.version}/jar
commons-fileupload/commons-fileupload/1.3.1/jar

11/18/14

34

Apache Sling - Tooling

Maven Plugins

Bundle deployment

Launchpad creation

Maven Archetypes

IDE Tooling

Eclipse

Netbeans (external)

11/18/14

35

Resources

http://sling.apache.org/

http://jackrabbit.apache.org/

11/18/14

36

You might also like