How osgi bundles are used by slings

I'm just starting to develop Apache and CQ5. There is such a concept for using OSGI packages in Sling.

I cannot find out how the binding structure actually interacts with these packages, and where does the response from the packets come from?

+7
source share
1 answer

OSGi is the module platform and service platform used by Sling and the CQ5 product. Sling itself consists of a series of packages hosted in a Felix OSGi container. Bundles are a collection of groups of components / services and container-managed java classes. A package can specify which packages will be imported, exported, as well as versions of these dependencies.

There are several ways to interact with Sling's OSGi. From JSP / JSP, you can use a sling object (such as SlingScriptHelper ), which is most likely available on your JSP page if you include the following line:

<%@include file="/libs/foundation/global.jsp"%> 

in your component or follow these steps:

 <cq:defineObjects> 

You can use it like this:

 QueryBuilder queryBuilder = sling.getService(QueryBuilder.class); 

In addition, if you have your own OSGi components (e.g. Servlet, Service, etc.), you can add links to other OSGI components / services using SCR annotations. Bertrand describes this in his response to Getting OSGi Services from a Package in Sling / CQ . Effectively this means adding the @Reference annotation to your OSGI component variables in your components, for example:

  @Reference private SlingRepository repository; 

When your component is loaded, this link will be entered into the OSGi container.

The bundle has no answer as such. The deployed package should be visible on the system console:

 http://localhost:4502/system/console/bundles 

with the components, services and configuration indicated here:

 http://localhost:4502/system/console/services http://localhost:4502/system/console/components http://localhost:4502/system/console/configMgr 

(Replace localhost: 4502 with your own CQ server host: port)

Once you get the component reference, you can call methods on this and use the return values ​​from these calls.

+7
source

All Articles