This document discusses an overview of Apache Sling, including quick facts about its history and community, its conceptual foundations as a REST-based and content-driven framework powered by OSGi and scripting, its main building blocks like resource providers and JCR, and how to build Sling applications by modeling content in JCR, accessing resources, using templating with Sightly, extensions, deployment and tooling.
Unlocking the Future of AI Agents with Large Language Models
Effective Web Application Development with Apache Sling
1. http://robert.muntea.nu @rombert
Effective Web Application Development with Apache Sling
Effective Web Application Development
with Apache Sling
Robert Munteanu
ApacheCon Core Europe 2015
2. http://robert.muntea.nu @rombert
Who I am
$DAYJOB
Adobe Experience
Manager
Apache Sling
Apache Jackrabbit
Apache Felix
FOSS
Apache Sling
MantisBT
Mylyn Connector for
MantisBT
Mylyn Connector for Review
Board
Speaker.currentSpeaker().interrupt();
30. http://robert.muntea.nu @rombert
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
}
}
31. http://robert.muntea.nu @rombert
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();
32. http://robert.muntea.nu @rombert
Another templating language?
●
Secure by default – XSS protection
●
Batteries not included to encourage separation of
concerns
●
Natural templating by blending in HTML5
documents
36. http://robert.muntea.nu @rombert
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")