© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
A virtual developer conference for Adobe Experience
Manager
Introduction to Back End Development in Adobe Experience
ManagerVarun Mitra | Partner Training Instructor
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Introduction to Back End Development in Adobe Experience
Manager
2
1 | Maven and Archetypes
2 | Introducing OSGI
3 | Sling: Servlets, Scheduling & Models
4 | Session Management
.
5 | Query Optimization
.
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 3
Maven and Archetypes
1. Maven simplifies and provides an uniform build process.
2. Maven makes use of a Project Object Model(POM)
3. pom.xml file defines Project Information, Build Environment Settings and
Relationships.
4. A Maven Archetype is a Project Template
5. Maven Archetypes can be used with AEM Sling Plugin for Eclipse.
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 4
1. SCR Annotation
a. @component: A JAVA class file that can be stopped or started.
b. @service: An extesnion of component, can be looked up using its interface name.
c. @reference: Defines References to the other services.
d. @properties: Defines properties which are made available to the component.
2. All services are components.
3. @component annotation is mandatory in order to use the rest.
4. Use @component(metatype=true) to create custom OSGI configurations.
Introducing OSGI
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 5
Introducing Sling
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 6
Sling Servlets
 Sling Servlet API extends HTTPServlet class
 Use @slingServlet annotation to define a Sling Servlet
 Avoid @slingServlet(paths=‘/bin/foo/bar’)
 Use @slingServlet(resourceTypes=‘/company/foo/bar’, selectors=“{‘foo’,’bar’}”)
 Default Servlet Execution path - /bin
 Define additional execution path with the help of Apache Sling Servlet/Script Resolver and
Error Handler
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 7
Sling Scheduling
 Scheduler can implement the Runnable API or make use of the Scheduler Interface.
 Scheduler make use of a CRON expression to execute periodically.
Sling Models
 Provides a framework for development
 Annotation driven POJOs
 OOTB works with:
 SlingBindings
 OSGi services
 request attributes
 Adaptable to multiple objects
 Resource and SlingHttpServletRequest
 Use annotations to handle inputs
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 8
Session Management
 Use loginService(String subServiceName, String workspace) for providing Super User Access
to the repository.
 Use ResourceResolver API to obtain the logged in user session
 Do not use repository.loginAdministrative or repository.login(userid, password)
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 9
Query Optimization
 Use sling:Folder or oak:Unstructured when large number of sibling nodes are
expected and ordering is not required. Use nt:unstructured and
sling:OrderedFolder otherwise.
 Avoid Queries in components.
 Use node based API’s if the prior knowledge of the location of data is
available.
 All queries are converted to SQL2 before being run, however the overhead of
query conversion is minimal.
 Use Explain query tool to understand how a query would be executed.
 Enable debug on Query API’s to further analyse the Query Performance:
 org.apache.jackrabbit.oak.plugins.index
 org.apache.jackrabbit.oak.query
 com.day.cq.search
© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Q&A
10
Varun mitra
vmitra@adobe.com
LinkedIn: Varun mitra

IMMERSE'16 Introduction to adobe experience manager back end

  • 1.
    © 2016 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. A virtual developer conference for Adobe Experience Manager Introduction to Back End Development in Adobe Experience ManagerVarun Mitra | Partner Training Instructor
  • 2.
    © 2016 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Introduction to Back End Development in Adobe Experience Manager 2 1 | Maven and Archetypes 2 | Introducing OSGI 3 | Sling: Servlets, Scheduling & Models 4 | Session Management . 5 | Query Optimization .
  • 3.
    © 2016 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. 3 Maven and Archetypes 1. Maven simplifies and provides an uniform build process. 2. Maven makes use of a Project Object Model(POM) 3. pom.xml file defines Project Information, Build Environment Settings and Relationships. 4. A Maven Archetype is a Project Template 5. Maven Archetypes can be used with AEM Sling Plugin for Eclipse.
  • 4.
    © 2016 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. 4 1. SCR Annotation a. @component: A JAVA class file that can be stopped or started. b. @service: An extesnion of component, can be looked up using its interface name. c. @reference: Defines References to the other services. d. @properties: Defines properties which are made available to the component. 2. All services are components. 3. @component annotation is mandatory in order to use the rest. 4. Use @component(metatype=true) to create custom OSGI configurations. Introducing OSGI
  • 5.
    © 2016 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. 5 Introducing Sling
  • 6.
    © 2016 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. 6 Sling Servlets  Sling Servlet API extends HTTPServlet class  Use @slingServlet annotation to define a Sling Servlet  Avoid @slingServlet(paths=‘/bin/foo/bar’)  Use @slingServlet(resourceTypes=‘/company/foo/bar’, selectors=“{‘foo’,’bar’}”)  Default Servlet Execution path - /bin  Define additional execution path with the help of Apache Sling Servlet/Script Resolver and Error Handler
  • 7.
    © 2016 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. 7 Sling Scheduling  Scheduler can implement the Runnable API or make use of the Scheduler Interface.  Scheduler make use of a CRON expression to execute periodically. Sling Models  Provides a framework for development  Annotation driven POJOs  OOTB works with:  SlingBindings  OSGi services  request attributes  Adaptable to multiple objects  Resource and SlingHttpServletRequest  Use annotations to handle inputs
  • 8.
    © 2016 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. 8 Session Management  Use loginService(String subServiceName, String workspace) for providing Super User Access to the repository.  Use ResourceResolver API to obtain the logged in user session  Do not use repository.loginAdministrative or repository.login(userid, password)
  • 9.
    © 2016 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential. 9 Query Optimization  Use sling:Folder or oak:Unstructured when large number of sibling nodes are expected and ordering is not required. Use nt:unstructured and sling:OrderedFolder otherwise.  Avoid Queries in components.  Use node based API’s if the prior knowledge of the location of data is available.  All queries are converted to SQL2 before being run, however the overhead of query conversion is minimal.  Use Explain query tool to understand how a query would be executed.  Enable debug on Query API’s to further analyse the Query Performance:  org.apache.jackrabbit.oak.plugins.index  org.apache.jackrabbit.oak.query  com.day.cq.search
  • 10.
    © 2016 AdobeSystems Incorporated. All Rights Reserved. Adobe Confidential.© 2016 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Q&A 10 Varun mitra vmitra@adobe.com LinkedIn: Varun mitra