You are on page 1of 7

CQ5 Interview Questions

1) What is CQ5? What is a Content Management System? 2) What is the technology stack of cq5? 3) What is a Content Repository? What is JCR? 4) What is REST? 5) What is Sling? how is it different from other java web development frameworks? 6) How is resource resolution done in Sling? 7) How is URL resolution done in sling? 8) What is OSGi? What is the benefit of OSGi? What is Felix? 9) What is the role of Dispatcher in CQ5? 10) How is content moved from author instance to publish instance? What is Replication agent? 11) How is content moved from publish instance to author instance? What is reverse replication? how does it work? 12) What is persistence manager in cq5? 13) What is a component? How to create a new component?How to configure a component? 14) What are widgets? how are widgets used? 15) What is a template? 16) What is scaffolding? 17) What is a file-vault? 18) How does cq5 workflow works? Answers : 1) What is CQ5? What is a Content Management System? CQ5 is a java based content management system from adobe, previously Day CQ5. 1) It is based on a content repository(i.e it uses a content repository to store the content of a website) and use JCR(java content repository) specification to access the content repository. 2) It uses RESTful Apache Sling framework to map request url to the corresponding node in content repository 3) it uses powerful OSGi framework internally to allow modular application development. It means individual pieces of your application(called bundles in terms of OSGi) can be independently started and stopped. CQ5 uses Apache Felix as the OSGi container. Therefore different parts of cq5 can be independently started and stopped.

Coming to why a content management system is required? Some websites are very dynamic in nature, content needs to be updated frequently, so it is easier to manage the content of such websites using a CMS. 2) What is the technology stack of cq5? Cq5 uses the following technologies : 1) JCR java specification for accessing a content repository JSR-283 specification jcr 2.0 , cq5 uses its own implementation of jcr called CRX. Apache Jackrabbit is an open-source implementation of jcr 2.0 specification. 2) Apache Sling RESTful framework to access a jcr over http protocol. It maps the request url to the node in jcr. 3) OSGi framework for modular application development using java. Each module called bundle can be independently started and stopped. 3) What is a content repository? What is JCR? A Content repository is basically a place where digital content is stored. Generally the structure of the content repository is hierarchial and represented as a tree structure where each node of the tree is used to store content. Java Content Repository is a specification provided by the java community to access the content repository in a uniform way (platform independent and vendor independent way). The specification was initially released as JSR-170(JCR 1.0) and then later revised version 2 as (JCR-283). The javax.jcr API provides the various classes and interfaces to access a content repository Apache Jackrabbit is an open-source implementation of JCR- 2.0 specification. It provides some wrapper classes and interfaces specific to jackrabbit plus many more functionalities on top of jcr. The org.apache.jackrabbit packages are used to access Jackrabbit. 4) What is REST? What is a RESTful Framework? REST stands for Representational State Transfer. According to the REST architecture, there are 6 constrainst which should be followed: Client?erver There should be a clear separation between a client and server. Stateless

The client?erver communication is further constrained by no client context being stored on the server between requests. Each request from any client contains all of the information necessary to service the request, and any session state is held in the client. The server can be statefulstateful. Cacheable As on the World Wide Web, clients can cache responses. Responses must therefore, implicitly or explicitly, define themselves as cacheable, or not, to prevent clients reusing stale or inappropriate data in response to further requests. Well-managed caching partially or completely eliminates some clientserver interactions, further improving scalability and performance. One more thing which differentiates as RESTful framework from other web-development frameworks is that generally all web-development frameworks rely heavily only on HTTP Get and Post Requests. While a restful leverages the maximum of http protocol. It uses all the types of http request(HEAD,GET,POST,PUT,DELETE). For example - consider a scenario where you want to delete a product from a product list with product_id=111; The server side code for the same will be somewhat like this if a HTTP GET request is sent from clientbrowser with product_id=111 appended to the url. public void doGet(HttpServletRequest request, HttpServletResponse response) { String prod_id = req.getParameter(product_id); Connection con = DBConnection.getConnection(); Statement st = con.createStatement(); st.executeQuery(delete * from product where product_id=+product_id+); } As you can see In the above piece of code, we are using a GET request to perform a delete operation on a resource. Therefore we are not using the real power of HTTP protocol. According to REST principles, the same could have been done by sending a HTTP DELETE request from client browser and at server side. public void doDelete(HttpServletRequest request, HttpServletResponse response) { String prod_id = req.getParameter(product_id); Connection con = DBConnection.getConnection();

Statement st = con.createStatement(); st.executeQuery(delete * from product where product_id=+product_id+); } Similarly to read a resource use GET scenario get product details create a new resource POST scenario add a new product update a resource PUT - scenario update an existing product details get product meta information use HEAD scenario reading the meta-information of products (say inventory information) 5) What is Sling? How is it different from other web-development frameworks? Apache Sling is RESTful framework to access a java content repository over http protocol. It is a content driven framework that is it maps the incoming user request based on URI to the corresponding node in the content repository and depending on the type of the request(GET,POST, etc) executes the corresponding dynamic script. For example - consider a scenario where a user is hitting a US website products page and getting the details of product1. The incoming URL request from user will be www.mywebsite.com/products/product1.html This would be mapped by the sling resource resolver to a node in the JCR /content/mywebsite/us/products/product1 Now the Sling resource resolver will check the properties of this node and check the sling:resourceType property of this node, which will tell the script that will be used to render the content of this page. For example if value of sling:resourceType property is /apps/mywebsite/products/GET/body.jsp Then for all the incoming GET requests on the product1 node, the above script will be used to render the content. The main advantages of sling are: ) it maps the url directly to the content ) it is restful. 6) How is resource resolution done in Sling?

The below images tells us how a URL is resolved and mapped to a resource.

Consider the URL GET www.mywebsite.com/products/product1.printable.a4.html/a/b?x=12 Here the type of request will be HTTP GET request We can break it down into its composite parts:

protocol
http://

host
myhost

content path
products/product1

selector(s)
.printable.a4.

extension
html /

suffix
a/b ?

param(s)
x=12

8) What is OSGi? What is the benefit of OSGi? What is Felix? OSGi is a framework which allows modular development of applications using java. A large application can be constructed using small reusable components(called bundles in terms of OSGi) each of which can be independently started, stopped, and also can be configured dynamically while running without requiring a restart. Consider a scenario where you have a large application which uses a logging framework. This logging framework can be deployed as an OSGi Bundle, which can be managed independently. Therefore, it can be

started when required by our application and can be stopped when not in use. Also the OSGi container makes these bundles available as services, which can be subsribed by other parts of application. The main advantages of using OSGi : 1) reduces the complexity of the system. 2) Makes the components loosely couples and easy to manage. 3) Increases the performance of the system, since parts of application which are not in use,need not to be loaded in the memory(although there is not a drastic change in performance and also some people argue that running an OSGi container itself takes huge memory). 9) What is the role of Dispatcher in CQ5? Dispatcher is a CQ5 tool for caching and load-balancing. It has 2 responsibilities. 1) Caching To cache as much content as possible, so that it doesnt need to access layout engine frequently for generating content dynamically. 2) Load-balancing To increase the performance by load-balancing. Dispatcher uses 2 main strategies for caching. 1) Cache as much content as possible as static pages. 2) Accessing layout engine as little as possible. Note : The Dispatcher uses a Cache Directory for caching static content. The cached documents are created in the root of a web-server. Dispatcher uses the following methods for caching : 1) Dispatcher invalidates those pages whose content has been updated and replaces it with new content. 2) Auto-Inavidation automatically removes the content parts which are out of date. Coming to load-balancing, if there are multiple cq instances configured with a dispatcher, the dispatcher can do a load-balancing and if there is too much load on any cq instance, it can relay the request to another less busy instance. How Dispatcher performs Load-balancing 1) Performance Statistics Dispatcher keeps statistics on how fast each instance of cq is responding to a particular url. Based on those metrics, dispatcher determines which instance of cq will fetch the quickest response for any request and relays the request to that cq instance. 2) Sticky Connections when a user session is established, then all incoming requests from that user should be served by the same cq instance, because other cq instances cannot recognize the user session and generate personalized pages for him. Dispatcher makes sure all requests for user session are served from the same cq instance.

9) How is Content Moved from author to publish instance?

The content once published is moved from author instance to publish instance using replication agent.
Replication agent has following responsibilities: 1. Move content from author to publish instance. 2. If any content is updated, then it flushes the older content from dispatcher cache. A development environment can contain multiple cq-author and multiple cq-publish instances, therefore an author instace can be configured to have many replication agents. Each of which will replicate the content in 1 or more publish instances. When a request is made from user to publish any content, then the replication agent packages the content and places it in a replication queue. A Listener servlet in publish instance receives the content package and updates the content in publish instance. The default listener servlet in publish instance is http://localhost:4503/bin/recieve . 11) How is content moved from publish instance to author instance? Consider the scenario where your website is having a blog or a forum, and the users are posting comments in the blog. Then that comments will only be in publish instance. The content is moved from publish instance to author instance using reverse replication and the job is done by reverse replication agent. The reverse replication agent places any content updates in an outbox configured in publish instance. The replication listeners in author environment keep listening to the publish outbox and whenever any content is placed in publish outbox, the listeners update the content in author instance. 12) What is persistence manager in cq5?

CQ uses persistence manager to save the content to a persistent storage like file system or a database. By default the crx content is stored using Tar Persistence manager. It stores the content to filesystem in standard linux archive files called tar. if you want to store the repository content in a database, then you can configure cq5 to use a database persistence manager.

You might also like