As per my understanding when developing with CQ5, service layer will be located on the OSGI bundle. Does that mean for every service classes that I will create it will be equivalent to one OSGI Bundle? For example if I have 3 services for my CQ5 application namely: Login Service, UserManagement Service, Registration Service does it mean that there will be also 3 OSGI bundles to be deployed? and how does this bundles will communicate with each other?
Not really. Bundles are more like modules. So you can split your services into bundles basing on their functionality or if you would like to reuse them in other projects. For example you can have next structure:
- projectname-core: there you can have services, which can be used by other project as well. Like some content feed generators for external services, Log-in service (if it will be useful in other project as well:
- projectname-ui-beans: there you can have beans, which you will be injecting on your jsp pages;
- projectname-services: general services, which are specific for this project, like search or registration;
- projectname-taglib: there you have your own jsp tags implementation;
- projectname-it-test: bundle with integration tests;
- projectname-some-specific-stuff: there can be some services which are not dependent on any other bundle, like one-time content manipulation;
Refer this topic for basic structure and Maven archetype for creating it.
Upd1: Communication between bundles can be done in two ways:
- you can have one of your bundles as a dependency for another bundle. Then, you could just use @Reference to get services from other bundle
- also you can use events to do communication, see this for details.