SlideShare a Scribd company logo
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 1
JCR, Sling or AEM? Which API should I use and
when?
Maciej Matuszewski
maciej.matuszewski@cognifide.com
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 2
What is the High-level API?
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 3
What is the Low-level API?
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 4
JCR, Sling and AEM
AEM
Sling
JCR
Other
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 5
Why bother?
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 6
Become an AEM Expert
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 7
resource.getChild("text")
node.getNode("text")
node.getProperty("jcr:title").getString()
resource.getChild("jcr:title").adaptTo(String.class)
page.getTitle()
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 8
node.addNode(String relPath)
resourceResolver.create(Resource parent, String name,
Map<String,Object> properties)
node.orderBefore(String srcChildRelPath, String destChildRelPath)
pageManager.order(Page page, String beforeName)
pageManager.order(Resource resource, String beforeName)
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 9
Don’t mix abstraction layers
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 10
Session session = resourceResolver.adaptTo(Session.class);
QueryManager queryManager = session.getWorkspace().getQueryManager();
Query query = queryManager.createQuery(QUERY_STRING, Query.JCR_SQL2);
QueryResult queryResult = query.execute();
NodeIterator nodeIterator = queryResult.getNodes();
while (nodeIterator.hasNext()) {
Node nextNode = nodeIterator.nextNode();
String path = nextNode.getPath();
Resource resource = resourceResolver.getResource(path);
veryImportantMethod(resource);
}
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 11
Iterator<Resource> resourcesIterator = resourceResolver
.findResources(QUERY_STRING, Query.JCR_SQL2);
while (resourcesIterator.hasNext()) {
Resource resource = resourcesIterator.next();
veryImportantMethod(resource);
}
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 12
@Inject
public CarModel(Resource resource) throws RepositoryException {
Node node = resource.adaptTo(Node.class);
Node pageNode;
if (node.getParent().getName().equals("rightParsys")) {
pageNode = node.getParent().getParent().getParent().getParent();
} else {
pageNode = node.getParent().getParent().getParent();
}
String pageTitle = node.getProperty("jcr:title").getString();
}
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 13
@Inject
public CarModel(@CurrentPage Page page) {
String pageTitle = page.getTitle();
}
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 14
resourceResolver.commit();
Session session = resourceResolver.adaptTo(Session.class);
session.save();
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 15
What are your tools?
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 16
Components
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 17
Components
Servlets
Filters
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 18
Components
OSGi Services
Servlets
Filters
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 19
Components
OSGi Services
Servlets
Filters
Templates
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 20
Components
OSGi Services
Servlets
Filters
Templates
Replication
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 21
Components
OSGi Services
Servlets
Filters
Templates
Querying Repository
Replication
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 22
Components
OSGi Services
Servlets
Filters
Templates
Querying Repository
Replication
Dispatcher
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 23
Components
OSGi Services
Servlets
Filters
Workflows
Templates
Querying Repository
Replication
Dispatcher
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 24
Components
OSGi Services
Servlets
Dynamic dialogs
Filters
Workflows
Templates
Querying Repository
Replication
Dispatcher
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 25
Components
OSGi Services
Servlets
Dynamic dialogs
Filters
Events
Jobs
Workflows
Templates
Querying Repository
Replication
Dispatcher
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 26
Components
OSGi Services
Servlets
Dynamic dialogs
Filters
Events
Jobs
Workflows
Templates
Digital Assets
Querying Repository
Replication
Dispatcher
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 27
Components
OSGi Services
Servlets
Dynamic dialogs
Filters
Events
Jobs
Workflows
Templates
Users and groups
ACLs
Digital Assets
Querying Repository
Replication
Dispatcher
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 28
Components
OSGi Services
Servlets
Dynamic dialogs
Filters
Events
Jobs
Workflows
Templates
Users and groups
ACLs
Digital Assets
Targeting and Analytics
Querying Repository
Replication
Dispatcher
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 29
Components
OSGi Services
Servlets
Dynamic dialogs
Filters
Events
Jobs
Workflows
Templates
Users and groups
ACLs
Digital Assets
Multi-Site Management
Targeting and Analytics
Querying Repository
Replication
Dispatcher
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 30
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 31
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 32
Sling advantages
More extendable/customizable
Simpler API, less exceptions
Adapters - http://localhost:4502/system/console/adapters
Support for ResourceDecorator, ResourceMerger and custom ResourceProviders
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 33
Models
SlingModels
Slice
Neba
etc.
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 34
@SlingServlet(resourceTypes = "myapp/core/components/car",
extensions = "json", selectors = "version")
public class CarServlet extends SlingSafeMethodsServlet {
@Override
protected void doGet(SlingHttpServletRequest request,
SlingHttpServletResponse response)
throws ServletException, IOException {
Resource resource = request.getResource();
CarModel model = resource.adaptTo(CarModel.class);
model.getVersion();
model.getRegistration();
model.getFuelType();
//TODO
}
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 35
<div class="car-info">
Name: ${model.name}
Registration: ${model.registration}
Version: ${model.version}
</div>
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 36
AEM API is helpful
Authoring pages
Tagging
DAM
Replication
Workflows
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 37
Pages
Page containingPage = pageManager.getContainingPage(resource);
containingPage.getTitle();
Page newPage = pageManager.create(resource.getPath(), "child-page",
"/apps/myapp/core/templates/basic", "Child Page");
resource.adaptTo(ReplicationStatus.class).isActivated()
pageManager.touch(Node page, boolean shallow, Calendar now,
boolean clearRepl)
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 38
Digital Asset Management
DamUtils
Asset
Metadata
MIME type
Renditions
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 39
Tags
RangeIterator<Resource> tagsIterator = tagManager.find("geometrixx:events");
TagManager.FindResults findResults = tagManager.findByTitle("Events");
Tag[] tags = tagManager.getTags(resource);
for (Tag tag : tags) {
long count = tag.getCount();
Iterator<Resource> resources = tag.find();
}
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 40
Keep JCR for special occasions
Workspace Management
Versioning
Access Control Management
Users and Groups
Locking
Lifecycle Management
Mixins
Node Type Management
Primary Type Change
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 41
Performance
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 42
Performance
Important argument to use low level API
Higher level API usually means additional overhead
Best performance is always achieved by using lowest possible API
Let’s test it!
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 43
Node rootNode = getNode("/content/geometrixx")
println countChildren(rootNode)
long countChildren(Node root) {
long count = 0
NodeIterator iterator = root.getNodes()
while (iterator.hasNext()) {
Node child = iterator.nextNode()
count += countChildren(child)
count++
}
return count
}
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 44
Resource root = getResource("/content/geometrixx")
println countChildren(root)
long countChildren(Resource root) {
long count = 0
Iterator<Resource> iterator = root.listChildren()
while (iterator.hasNext()) {
Resource child = iterator.next()
count += countChildren(child)
count++
}
return count
}
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 45
0 2 4 6 8
AEM 5.6.1
AEM 6.0 SP2
Traversing /content/geometrixx tree
Sling API JCR API
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 46
GEOMETRIXX_CONTENT_PATH =
"/content/geometrixx/en/toolbar/profiles/forgot/thank_you/jcr:content/par"
Node parsysNode = getNode(GEOMETRIXX_CONTENT_PATH)
for (int i = 0; i < 10000; i++) parsysNode.getNode("text")
Resource parsysResource = getResource(GEOMETRIXX_CONTENT_PATH)
for (int i = 0; i < 10000; i++) parsysResource.getChild("text")
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 47
GEOMETRIXX_CONTENT_PATH =
"/content/geometrixx/en/toolbar/profiles/forgot/thank_you/jcr:content/par"
Node parsysNode = getNode(GEOMETRIXX_CONTENT_PATH)
for (int i = 0; i < 10000; i++) parsysNode.getNode("text")
Resource parsysResource = getResource(GEOMETRIXX_CONTENT_PATH)
for (int i = 0; i < 10000; i++) parsysResource.getChild("text")
JCR time – 37 ms
Sling time – 931 ms
Times for 10000 operations
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 48
Performance summary
JCR is much faster than Sling
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 49
Performance summary
JCR is much faster than Sling
Q.E.D.
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 50
Performance summary
JCR is much faster than Sling
Q.E.D.
So what?!
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 51
Component’s performance
Sample page with 3 Rich Text components
Let each component get it’s child 3 times
Resource.getChild() operation takes 0.0931 ms
Node.getNode() operation takes 0.0037 ms
Header
Menu
Carousel
Rich Text
Rich Text Rich Text
Article List
Footer
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 52
Component’s performance
Sample page with 3 Rich Text components
Let each component get it’s child 3 times
Resource.getChild() operation takes 0.0931 ms
Node.getNode() operation takes 0.0037 ms
Difference between JCR and Sling for entire
page is less than 1 ms!
Header
Menu
Carousel
Rich Text
Rich Text Rich Text
Article List
Footer
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 53
Component’s performance
Sample page with 3 Rich Text components
Let each component get it’s child 3 times
Resource.getChild() operation takes 0.0931 ms
Node.getNode() operation takes 0.0037 ms
Difference between JCR and Sling for entire
page is less than 1 ms!
And it’s without cache on dispather
or performance tunning.
Header
Menu
Carousel
Rich Text
Rich Text Rich Text
Article List
Footer
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 54
Batch operations
Data import/export
Non-cached
Constantly repeated
Low-level
Components
Servlets
Non-critical
One time ops
High-level
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 55
The future of digital marketing. London, Poland, Copenhagen.
© 29/06/2015 Page 56
Thank you!
Przemysław Pakulski
Tomasz Rękawek
maciej.matuszewski@cognifide.com

More Related Content

PDF
Understanding Sling Models in AEM
PPTX
AEM and Sling
PPTX
Rest and Sling Resolution
PPTX
Sling Models Overview
PDF
Aem dispatcher – tips & tricks
PDF
AEM Best Practices for Component Development
PPTX
PPTX
React-JS.pptx
Understanding Sling Models in AEM
AEM and Sling
Rest and Sling Resolution
Sling Models Overview
Aem dispatcher – tips & tricks
AEM Best Practices for Component Development
React-JS.pptx

What's hot (20)

PDF
AEM Sightly Deep Dive
PPTX
AEM Rich Text Editor (RTE) Deep Dive
PDF
Reactjs workshop (1)
PPTX
AEM - Client Libraries
PPTX
Sling models by Justin Edelson
PPTX
React Hooks
PDF
introduction to Vue.js 3
PPTX
Angular modules in depth
PDF
React js
PPTX
Introduction to Django
PDF
React
PPTX
PPT
Angular 8
ODP
Basics of VueJS
PDF
Angular Directives
PDF
Angular - Chapter 4 - Data and Event Handling
PPTX
Dynamic components using SPA concepts in AEM
PDF
Angular - Chapter 7 - HTTP Services
PDF
Spring Framework - Core
PPTX
AEM Sightly Deep Dive
AEM Rich Text Editor (RTE) Deep Dive
Reactjs workshop (1)
AEM - Client Libraries
Sling models by Justin Edelson
React Hooks
introduction to Vue.js 3
Angular modules in depth
React js
Introduction to Django
React
Angular 8
Basics of VueJS
Angular Directives
Angular - Chapter 4 - Data and Event Handling
Dynamic components using SPA concepts in AEM
Angular - Chapter 7 - HTTP Services
Spring Framework - Core
Ad

Similar to JCR, Sling or AEM? Which API should I use and when? (20)

PPTX
When dispatcher caching is not enough...
PDF
An Innovative Big-Data Web Scraping Tech Company
PDF
Boost your productivity for free!
PDF
Aftermarket2012 cargotec malcolmyoull
PDF
API Monetization
PDF
An Innovative Big-Data Web Scraping Tech Company
PDF
Operationalizing AI at scale using MADlib Flow - Greenplum Summit 2019
PDF
Introduction to tag management
PPT
IBM Cloud - Vision, Strategy & Midrange Solutions.ppt
PDF
TFF2015, Christian Bizer, Uni Mannheim "Schema.org-Annotationen in Webseiten"
PPTX
TechEvent DWH Modernization
PDF
Realising Digital’s Full Potential in the Value Chain
PDF
BIG IoT Marketplace & API
PDF
[apidays LIVE HONK KONG] - Building an Integrated Supply Chain for APIs
PDF
It’s Not About What You Know. It’s About What You Can Do
PDF
Flink Forward Berlin 2017: Bas Geerdink, Martijn Visser - Fast Data at ING - ...
PPTX
The next generation of ap is luis weir.cwin18.telford
PDF
Apache kafka event_streaming___kai_waehner
PDF
The Rise Of Event Streaming – Why Apache Kafka Changes Everything
PDF
INTERFACE, by apidays - From Monolith to Open Finance with APIs by Marcilio ...
When dispatcher caching is not enough...
An Innovative Big-Data Web Scraping Tech Company
Boost your productivity for free!
Aftermarket2012 cargotec malcolmyoull
API Monetization
An Innovative Big-Data Web Scraping Tech Company
Operationalizing AI at scale using MADlib Flow - Greenplum Summit 2019
Introduction to tag management
IBM Cloud - Vision, Strategy & Midrange Solutions.ppt
TFF2015, Christian Bizer, Uni Mannheim "Schema.org-Annotationen in Webseiten"
TechEvent DWH Modernization
Realising Digital’s Full Potential in the Value Chain
BIG IoT Marketplace & API
[apidays LIVE HONK KONG] - Building an Integrated Supply Chain for APIs
It’s Not About What You Know. It’s About What You Can Do
Flink Forward Berlin 2017: Bas Geerdink, Martijn Visser - Fast Data at ING - ...
The next generation of ap is luis weir.cwin18.telford
Apache kafka event_streaming___kai_waehner
The Rise Of Event Streaming – Why Apache Kafka Changes Everything
INTERFACE, by apidays - From Monolith to Open Finance with APIs by Marcilio ...
Ad

More from connectwebex (19)

PDF
Jackrabbit OCM in practice
PDF
Building Creative Product Extensions with Experience Manager
PDF
AEM 6 DAM - Integrations, Integrations, Integrations
PDF
Build single page applications using AngularJS on AEM
PDF
SonarQube for AEM
PDF
Presentation daniel takai
PDF
Presentation thomas simlinger
PDF
five Sling features you should know
PDF
Efficient content structures and queries in CRX/CQ
PDF
Web, Mobile, App and Back!
PDF
Tighten your Security and Privacy
PDF
THE BREAK-UP - A user interface love story
PDF
Configuring CQ Security
PDF
Integration Testing in AEM
PDF
Sling Component Filters in CQ5
PDF
Integrating Backend Systems
PDF
Scaling CQ5
PDF
Auto-testing production CQ instances with Muppet
PDF
CQ Maven Methods
Jackrabbit OCM in practice
Building Creative Product Extensions with Experience Manager
AEM 6 DAM - Integrations, Integrations, Integrations
Build single page applications using AngularJS on AEM
SonarQube for AEM
Presentation daniel takai
Presentation thomas simlinger
five Sling features you should know
Efficient content structures and queries in CRX/CQ
Web, Mobile, App and Back!
Tighten your Security and Privacy
THE BREAK-UP - A user interface love story
Configuring CQ Security
Integration Testing in AEM
Sling Component Filters in CQ5
Integrating Backend Systems
Scaling CQ5
Auto-testing production CQ instances with Muppet
CQ Maven Methods

JCR, Sling or AEM? Which API should I use and when?

  • 1. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 1 JCR, Sling or AEM? Which API should I use and when? Maciej Matuszewski [email protected]
  • 2. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 2 What is the High-level API?
  • 3. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 3 What is the Low-level API?
  • 4. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 4 JCR, Sling and AEM AEM Sling JCR Other
  • 5. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 5 Why bother?
  • 6. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 6 Become an AEM Expert
  • 7. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 7 resource.getChild("text") node.getNode("text") node.getProperty("jcr:title").getString() resource.getChild("jcr:title").adaptTo(String.class) page.getTitle()
  • 8. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 8 node.addNode(String relPath) resourceResolver.create(Resource parent, String name, Map<String,Object> properties) node.orderBefore(String srcChildRelPath, String destChildRelPath) pageManager.order(Page page, String beforeName) pageManager.order(Resource resource, String beforeName)
  • 9. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 9 Don’t mix abstraction layers
  • 10. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 10 Session session = resourceResolver.adaptTo(Session.class); QueryManager queryManager = session.getWorkspace().getQueryManager(); Query query = queryManager.createQuery(QUERY_STRING, Query.JCR_SQL2); QueryResult queryResult = query.execute(); NodeIterator nodeIterator = queryResult.getNodes(); while (nodeIterator.hasNext()) { Node nextNode = nodeIterator.nextNode(); String path = nextNode.getPath(); Resource resource = resourceResolver.getResource(path); veryImportantMethod(resource); }
  • 11. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 11 Iterator<Resource> resourcesIterator = resourceResolver .findResources(QUERY_STRING, Query.JCR_SQL2); while (resourcesIterator.hasNext()) { Resource resource = resourcesIterator.next(); veryImportantMethod(resource); }
  • 12. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 12 @Inject public CarModel(Resource resource) throws RepositoryException { Node node = resource.adaptTo(Node.class); Node pageNode; if (node.getParent().getName().equals("rightParsys")) { pageNode = node.getParent().getParent().getParent().getParent(); } else { pageNode = node.getParent().getParent().getParent(); } String pageTitle = node.getProperty("jcr:title").getString(); }
  • 13. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 13 @Inject public CarModel(@CurrentPage Page page) { String pageTitle = page.getTitle(); }
  • 14. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 14 resourceResolver.commit(); Session session = resourceResolver.adaptTo(Session.class); session.save();
  • 15. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 15 What are your tools?
  • 16. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 16 Components
  • 17. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 17 Components Servlets Filters
  • 18. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 18 Components OSGi Services Servlets Filters
  • 19. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 19 Components OSGi Services Servlets Filters Templates
  • 20. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 20 Components OSGi Services Servlets Filters Templates Replication
  • 21. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 21 Components OSGi Services Servlets Filters Templates Querying Repository Replication
  • 22. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 22 Components OSGi Services Servlets Filters Templates Querying Repository Replication Dispatcher
  • 23. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 23 Components OSGi Services Servlets Filters Workflows Templates Querying Repository Replication Dispatcher
  • 24. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 24 Components OSGi Services Servlets Dynamic dialogs Filters Workflows Templates Querying Repository Replication Dispatcher
  • 25. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 25 Components OSGi Services Servlets Dynamic dialogs Filters Events Jobs Workflows Templates Querying Repository Replication Dispatcher
  • 26. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 26 Components OSGi Services Servlets Dynamic dialogs Filters Events Jobs Workflows Templates Digital Assets Querying Repository Replication Dispatcher
  • 27. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 27 Components OSGi Services Servlets Dynamic dialogs Filters Events Jobs Workflows Templates Users and groups ACLs Digital Assets Querying Repository Replication Dispatcher
  • 28. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 28 Components OSGi Services Servlets Dynamic dialogs Filters Events Jobs Workflows Templates Users and groups ACLs Digital Assets Targeting and Analytics Querying Repository Replication Dispatcher
  • 29. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 29 Components OSGi Services Servlets Dynamic dialogs Filters Events Jobs Workflows Templates Users and groups ACLs Digital Assets Multi-Site Management Targeting and Analytics Querying Repository Replication Dispatcher
  • 30. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 30
  • 31. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 31
  • 32. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 32 Sling advantages More extendable/customizable Simpler API, less exceptions Adapters - http://localhost:4502/system/console/adapters Support for ResourceDecorator, ResourceMerger and custom ResourceProviders
  • 33. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 33 Models SlingModels Slice Neba etc.
  • 34. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 34 @SlingServlet(resourceTypes = "myapp/core/components/car", extensions = "json", selectors = "version") public class CarServlet extends SlingSafeMethodsServlet { @Override protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { Resource resource = request.getResource(); CarModel model = resource.adaptTo(CarModel.class); model.getVersion(); model.getRegistration(); model.getFuelType(); //TODO }
  • 35. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 35 <div class="car-info"> Name: ${model.name} Registration: ${model.registration} Version: ${model.version} </div>
  • 36. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 36 AEM API is helpful Authoring pages Tagging DAM Replication Workflows
  • 37. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 37 Pages Page containingPage = pageManager.getContainingPage(resource); containingPage.getTitle(); Page newPage = pageManager.create(resource.getPath(), "child-page", "/apps/myapp/core/templates/basic", "Child Page"); resource.adaptTo(ReplicationStatus.class).isActivated() pageManager.touch(Node page, boolean shallow, Calendar now, boolean clearRepl)
  • 38. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 38 Digital Asset Management DamUtils Asset Metadata MIME type Renditions
  • 39. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 39 Tags RangeIterator<Resource> tagsIterator = tagManager.find("geometrixx:events"); TagManager.FindResults findResults = tagManager.findByTitle("Events"); Tag[] tags = tagManager.getTags(resource); for (Tag tag : tags) { long count = tag.getCount(); Iterator<Resource> resources = tag.find(); }
  • 40. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 40 Keep JCR for special occasions Workspace Management Versioning Access Control Management Users and Groups Locking Lifecycle Management Mixins Node Type Management Primary Type Change
  • 41. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 41 Performance
  • 42. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 42 Performance Important argument to use low level API Higher level API usually means additional overhead Best performance is always achieved by using lowest possible API Let’s test it!
  • 43. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 43 Node rootNode = getNode("/content/geometrixx") println countChildren(rootNode) long countChildren(Node root) { long count = 0 NodeIterator iterator = root.getNodes() while (iterator.hasNext()) { Node child = iterator.nextNode() count += countChildren(child) count++ } return count }
  • 44. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 44 Resource root = getResource("/content/geometrixx") println countChildren(root) long countChildren(Resource root) { long count = 0 Iterator<Resource> iterator = root.listChildren() while (iterator.hasNext()) { Resource child = iterator.next() count += countChildren(child) count++ } return count }
  • 45. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 45 0 2 4 6 8 AEM 5.6.1 AEM 6.0 SP2 Traversing /content/geometrixx tree Sling API JCR API
  • 46. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 46 GEOMETRIXX_CONTENT_PATH = "/content/geometrixx/en/toolbar/profiles/forgot/thank_you/jcr:content/par" Node parsysNode = getNode(GEOMETRIXX_CONTENT_PATH) for (int i = 0; i < 10000; i++) parsysNode.getNode("text") Resource parsysResource = getResource(GEOMETRIXX_CONTENT_PATH) for (int i = 0; i < 10000; i++) parsysResource.getChild("text")
  • 47. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 47 GEOMETRIXX_CONTENT_PATH = "/content/geometrixx/en/toolbar/profiles/forgot/thank_you/jcr:content/par" Node parsysNode = getNode(GEOMETRIXX_CONTENT_PATH) for (int i = 0; i < 10000; i++) parsysNode.getNode("text") Resource parsysResource = getResource(GEOMETRIXX_CONTENT_PATH) for (int i = 0; i < 10000; i++) parsysResource.getChild("text") JCR time – 37 ms Sling time – 931 ms Times for 10000 operations
  • 48. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 48 Performance summary JCR is much faster than Sling
  • 49. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 49 Performance summary JCR is much faster than Sling Q.E.D.
  • 50. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 50 Performance summary JCR is much faster than Sling Q.E.D. So what?!
  • 51. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 51 Component’s performance Sample page with 3 Rich Text components Let each component get it’s child 3 times Resource.getChild() operation takes 0.0931 ms Node.getNode() operation takes 0.0037 ms Header Menu Carousel Rich Text Rich Text Rich Text Article List Footer
  • 52. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 52 Component’s performance Sample page with 3 Rich Text components Let each component get it’s child 3 times Resource.getChild() operation takes 0.0931 ms Node.getNode() operation takes 0.0037 ms Difference between JCR and Sling for entire page is less than 1 ms! Header Menu Carousel Rich Text Rich Text Rich Text Article List Footer
  • 53. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 53 Component’s performance Sample page with 3 Rich Text components Let each component get it’s child 3 times Resource.getChild() operation takes 0.0931 ms Node.getNode() operation takes 0.0037 ms Difference between JCR and Sling for entire page is less than 1 ms! And it’s without cache on dispather or performance tunning. Header Menu Carousel Rich Text Rich Text Rich Text Article List Footer
  • 54. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 54 Batch operations Data import/export Non-cached Constantly repeated Low-level Components Servlets Non-critical One time ops High-level
  • 55. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 55
  • 56. The future of digital marketing. London, Poland, Copenhagen. © 29/06/2015 Page 56 Thank you! Przemysław Pakulski Tomasz Rękawek [email protected]