Expand my Community achievements bar.

SOLVED

Proper way of development

Avatar

Level 3

Hi

If I want to create an application in CQ5 which is the best way to develop the application?

1. Use a bundle(core) and import class and user methods in jsp?

2. Use bundle to register servlets and call those on each action?

3. Use any framework to take care all configurations?

Any other process are welcome..

If anyone has a sample project build on gemini blueprint, can you please share it?

If I am going to use a soap based web service in the application then what is the proper way to do that?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Do not mix up MVC (ie - Spring MVC) and OSGi. You are correct with Spring MVC - you have controllers and a DispatcherServlet. This servlet dispatches client requests to handlers. The default handler is a controller interface that lets you work with a ModelAndView instance.

However -- in CQ and OSGi in general -- its different. Each OSGi is its own module and you can call into them and write app logic to handle return values. Think of an OSGi as its own library that expose classes and methods that you can call into. When you get back the return value, you can display the data in a CQ web page. 

For example, in a lot of our community articles, we write the return value from an OSGi operation in a grid control. See this article as an example: http://scottsdigitalcommunity.blogspot.ca/2013/02/querying-adobe-experience-manager-data.html.

I highly recommend that you consider buying this OSGi programming book. Its a great book: 

http://www.amazon.com/OSGi-Action-Creating-Modular-Applications/dp/1933988916

Thanks

View solution in original post

3 Replies

Avatar

Level 10

OSGi bundles play a role when developing a CQ app. OSGi defines an architecture for developing and deploying modular applications and libraries (it is also known as the Dynamic Module System for Java). OSGi containers allow you to break your application into individual modules (are JAR 
files with additional meta information and called bundles in OSGi terminology) and manage the cross-dependencies between them.

A recommended way to build an OSGi bundle is by using Maven. We have different community articles on developing OSGi bundles by using Maven then deploying the bundle. For an example of building an OSGi Bundle by using Maven, see http://scottsdigitalcommunity.blogspot.ca/2013/02/querying-adobe-experience-manager-data.html.

To address your question regarding web services/soap -- the proper way to perform this use case in CQ is to develop an OSGi bundle that contains Java proxy classes that are created based on the WSDL of the web service that you want to consume. We have examples of how to do this:

http://scottsdigitalcommunity.blogspot.ca/2012/05/creating-adobe-cq-bundles-that-consume.html

This of course is a server-side operation that you can call from a CQ web page. You can call the server-side operation (that invokes the web service) and write the results to a CQ page. You can develop the CQ page to address your business needs For example -- see this article that displays the results returned by the web service call in a GUI located in the web page:

http://scottsdigitalcommunity.blogspot.ca/2012/05/using-jsonwriter-objects-to-display.html
 

Hope this helps

Avatar

Level 3

In a conventional web application we use some modularity like service layer, business layer, DAO layer like that. How can we achieve that in CQ5? Making each layer as separate bundle?

 

Can we maintain a MVC pattern here? passing all request through controller?

Avatar

Correct answer by
Level 10

Do not mix up MVC (ie - Spring MVC) and OSGi. You are correct with Spring MVC - you have controllers and a DispatcherServlet. This servlet dispatches client requests to handlers. The default handler is a controller interface that lets you work with a ModelAndView instance.

However -- in CQ and OSGi in general -- its different. Each OSGi is its own module and you can call into them and write app logic to handle return values. Think of an OSGi as its own library that expose classes and methods that you can call into. When you get back the return value, you can display the data in a CQ web page. 

For example, in a lot of our community articles, we write the return value from an OSGi operation in a grid control. See this article as an example: http://scottsdigitalcommunity.blogspot.ca/2013/02/querying-adobe-experience-manager-data.html.

I highly recommend that you consider buying this OSGi programming book. Its a great book: 

http://www.amazon.com/OSGi-Action-Creating-Modular-Applications/dp/1933988916

Thanks