Saturday, April 15, 2017

AEM 6 Advanced Interview Questions Part 1

AEM 6 Advanced Interview Questions Part 3


Here, I will try to list down some of the advanced AEM interview questions I have come across. Please correct my answers if required in the comments and I will do the changes accordingly.

1. Difference between service and component
A :
Service :
  • A service is an OSGI component that can be looked up from other OSGI components.
  • Any java object is eligible to be a service
  • All the services in OSGI are components
  • Services are maintained in service registry from which they can be looked up
Component :
  • A component is a java object whose life cycle is handled by the OSGI container.
  • Any java object is eligible to be a component
  • A component is not necessarily an OSGI service, however, to make it callable by other components it has to be declared as service.
2. How a class is made available to OSGI container?
A : By providing @component at the top of the class declaration

3. Do you always need @service and @component annotations for a class in OSGI?
A : No, a component may not be declared as an OSGI service. However, there is a requirement to consume/look up for the component in another component it has to be declared as @component.

4. How to debug a situation where a component is not configurable on ConfigMgr?
A : Following steps should be taken in order to ensure component is configurable

  • The attribute-value metadata=true of @component annotation is responsible to making the component configurable on ConfigMgr. That should be verified first.
  • If the component is using @reference to other service, they should be available to the component and should have been initialized
  • There should be configurable properties associated with the component using - @property or @properties 
5. What is the difference between Live Copy and Language Copy?
A : A Live Copy is the copy of blueprint/source with its live relation with the blueprint/source which means the changes in live copy and source are tracked. Source can be attached or detached or reattached or sync to the Live Copy. While a Language Copy is a static copy of some or all the pages of the source.

6. How Live Copy is connected to blueprint?
A : Using Rollout configuration the Live Copy can be configured to be updated automatically when a update in blueprint occurs.

7. MSM configuration.
Please refer - https://docs.adobe.com/docs/en/aem/6-0/administer/sites/multi-site-manager/msm-blueprints.html

8. How to configure run modes?
A : Run modes are configured in following ways.
  • Provide the run mode as name of AEM jar file e.g. cq6_publish_p4503.jar. Where publish is the run mode.
  • Provide property - sling.run.modes in sling.properties file
  • Provide run mode with java argument for example -Dsling.run.modes=publish
  • Provide -r <run mode> which starting the jar file using batch file
9. How is the configuration of AEM instance done according to run modes?
A : You can define a config (nt:folder) node inside your project folder - /apps/projectA and define configuration of a service/component by creating a node sling:OsgiConfig under it having the full qualifying name like org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl. The configuration should be provided as the property of this node.



When you specify the run mode along with config separated by a dot, it becomes the configuration of a specific run mode and is used when that particular run mode is initialized. For example config.author will define configurations for author run mode.




10. What is the advantages of using Sightly?
A : Following are the advantages of using Sightly over JSP.
  • Easy and no requirement of knowing JAVA to use Sightly.
  • Protection against cross scripting.
  • Uses sightly context to output data in correct format.
  • Clear separation of client side and back end logic. No scriptlets.
  • Strong connection to Sling.
  • Has two ways of handling backend logic. WCM Use Java API and WCM Use Javascript API.
11. What is HTML (display) context in Sightly?
A : The display context of a content refers to its location where it is used in the page. HTL is capable of identifying the context of the output except in case of CSS and JS where in if required explicit context can be passed. This context is used to prevent XSS security problem. XSS is cross site scripting attack on the website, in which attacker can inject the custom script and attack the site. HTL gives protection from this by introducing display context. HTL is capable of identifying the context in link, text and title properties. There are several display contexts those can be used when required. Which are listed below.
  • text
  • html
  • attribute
  • uri
  • number
  • scriptToken
  • scriptString
  • scriptComment
  • styleToken
  •  styleString
  • styleComment
  • unsafe
  • attributeName
  • elementName
12. Why designs are different from clientlibs and why should clientlibs be defined outside designs?
A : Designs contain the details of site level configurations of the components along with it it can contain the clientlibs. However, when a clientlibs are configured in designs, it will be combined into one main.js/main.css and will be loaded each time a page is called. However, there are cases when not all the scripts/css are needed to be loaded on page as they are not used by the components. In such cases, the clientlibs can be defined along with the component and imported according to the requirement on the page. This will ensure only those client libs are called which are required by the page/components on the page and they are easy to maintain due to their clear separation according to the page.

13. What does clientlibs contain and what is embed, dependencies and categories?
A: Clientlibs contain js.txt, css.txt and the sources of javascript and css.
  • Categories specify the clientslibs required by the page
  • Dependencies specify the clientlibs those are required to run the clientlibs defined in categories and it means there will be an extra call made to load these clientlibs.
  • Embed specifies aggregating the clientlibs along with the defined in categories, this means they will be attached to the main clientlibs.

14. Difference between CRX2.0 and OAK (CRX3.0).
A:
  • CRX2.0 is the implementation of Jackrabbit while OAK is the implementation of Jackrabbit OAK
  • Since CRX2.0 is implementation of Jackrabbit, it uses JCR completely, while OAK uses JCR just as facades.
  • CRX2.0 has persistence manager (PM) which writes data as blob however, OAK has microkernel which writes data as per underlying DB.
  • CRX2.0 uses Lucene while OAK uses Solr.
  • CRX2.0 doesn't support clustering (i.e. distributed database across the servers) while OAK uses MongoDB like database which use clustering.


15. Difference between CQ5.6 and AEM6.1?
A:
  • Since AEM6.0 the touch UI is introduced which was not there in CQ5.6
  • AEM6.1 uses OAK which 5.6 uses CRX2.0 which is adobe's implementation of JCR.
  • Since AEM6.0 sightly is introduced as new markup language to facilitate the front end developers with page definitions which reduces the requirement of having developers with knowledge of java.
  • CQSE servlet engine has been replaced by Eclipse Jetty 

16. Do you always require @activate and @deactivate?
A : No. They indicate the methods required for pre or post processing of the components/services.

17. How do you use a service in a component?
A : The simplest way is to use @reference annotation and use the name of the service.
If the service needs to be used inside a jsp, you can use following syntax of code in scriptlet.

com.adobe.cq.KeyService keyService = sling.getService(com.adobe.cq.KeyService.class);

18. Explain dispatcher configurations (especially /filter)
A : Please refer - Dispatcher Configurations

19. Explain @reference annotation.
A: This annotation is used for injecting an OSGI service in OSGI component/service. Following are the different attributes used along with the annotation.

name : in case name of the service is different from the declared variable reference
interfaceName : interface name for the service.
policy : It can be one of ReferencePolicy.STATIC or ReferencePolicy.DYNAMIC. Where in dynamic means, if the reference service goes off, it is bound to the calling component/service when it is on again dynamically without the requirement of resetting the calling component/service. By default this value is always static, which means the calling component/service will not be up until the reference is resolved.
target : to select the referenced service.
strategy : one of event or lookup. This value defines how the reference will be resolved.

20. How sling does resource resolution?
A : There are three basic steps.

  • URL decomposition : The URL is decomposed in protocol, path, extension, selector, suffix and parameters.
  • ResourceType identification : Using the path sling decided at which location in content repository the page resource should be looked for. From there, the sling:resouceType of the page is extracted. In case sling:resouceType is not available, sling:superResourceType is looked for. Once the resourceType is determined say /apps/project/components/pages/componentA, the script is located inside the component definition in apps folder.
  • Script resolution : Here the priorities to the scripts are given as per the name, extension, method and type, which is as follows.
    • selector + extension + jsp/html
    • selector + jsp/html
    • extension + jsp
    • node name + jsp/html
    • method + jsp/html first GET/HEAD and then POST, DELETE etc. These names has to be in capitals.
21. Why a webservice consumer in AEM should be implemented at server side instead of client side?
A : One should be evaluating the output of webservice in order to decide if the consumer should be implemented at service side or client side. For example a webservice giving response in JSON can be better be consumed on the client side while a webservice giving response in XML format can be better consumed on the server side. Also, while implementing the consumer client side, one should consider the size of the response returned by the webservice. Large sized responses should be handled by the server side consumer.

22. Analytics integration.
A : Please refer - SiteCatalyst

23. Sling Dynamic Includes in AEM.
A : This is a separate project created to handle the situation when there is a page with most of the static components and a dynamic component. This enables the dispatcher to cache the static components of the page and load the dynamic components from the publish instance. This is done using a servlet filter that intercepts the request of a component with given resourceType.

Implementation and configuration details can be found at - SDI

24. How to provide different configuration of the same service dynamically?
A : This is done by adding configurationFactory=true as one of the attributes in @component annotation as given in following example.

@component(label = "test component", immediate = true, enabled = true,
metatype = true,
description = "Testing configuration factory",
policy = ConfigurationPolicy.REQUIRE, configurationFactory = true)

This will allow multiple configuration of the component/service by providing + sign at right side on the configMgr.

25. Why an out of the box component should not be altered?
A: The out of the box components are prone to change when a new service pack is installed or when a version upgrade is done or when a new update is provided to the AEM. This will remove the existing configurations done in the component in libs folder. The other reason is the component might have been used inside another project/component which may bring inconsistent behavior in the component that is using the altered component.

26. How to create an overlay component?
A :An overlay component is created by copy pasting the component from \libs to \apps with exact path of the component and doing required changes.

27. How to create an overriden component?
A : A component can be overriden by creating a new component and providing sling:resourseSuperType property.

28. How to create a custom event handler?
A : Define a class that extends EventListner and implement the required method activate method which takes ComponentContext as the argument.

Using session, you can fetch the observation manager like

session.getWorkSpace().getObservationManager()

Using this observation manager you can add event listener with arguments like path, type, event (Node added,  node removed, node moved, persist, property added, property changed, property removed)


No comments:

Post a Comment

Some more AEM 6 Interview Questions for Architects

 Some more AEM 6 Interview Questions for Architects 1. Consider you have a workflow with two steps. One step is to transfer the asset from s...