OSGi – Accessing Bundle/Service information from BundleContext

Here are few code snippets compiled in a java program, which would help you fetch bundle and service information from BundleContext. The snippets cover: Fetching bundle information Fetching ServiceReference from bundle Fetching Service from bundleContext More API details can be retrived from: https://osgi.org/javadoc/r4v43/core/org/osgi/framework/Bundle.html https://osgi.org/javadoc/r4v43/core/org/osgi/framework/ServiceReference.html    

Advertisements

Default component configurations via Conf Nodes

Have you faced issue of design dialog configurations being overwritten by deployment? Starting AEM 6.1, AEM provides ability to avoid design configuration overwrite, by extracting configurations from /etc to /conf. Example: Lets consider a scenario where business had requested a default title 'Contact Us' for a component. Few months later, they change the title to 'Contact … Continue reading Default component configurations via Conf Nodes

ResourceChangeListener v/s Sling Event

With introduction of ResourceChangeListener, this blog is an effort to help developers choose between ResourceChangeListener and Sling Event for an implementation. ResourceChangeListener: pros: Can be configured to listen to only specific paths. Multiple watch paths can also be configured to provide it a more granular approach. For a bulk operation concerning N resources, listener will be executed … Continue reading ResourceChangeListener v/s Sling Event

AbstractResourceVisitor for traversing resource trees

We often come across features that require traversal of a resource tree (e.g. processing assets in a folder). In such scenarios, recommendation is to use tree traversal than queries. More details of similar scenarios can found on link  Sling provides AbstractResourceVisitor API, which performs traversal through a resource tree, allowing a developer to focus on processing child resources. How to … Continue reading AbstractResourceVisitor for traversing resource trees