Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

Programmatically Activate/Deactivate the configuration of OSGI bundle

Avatar

Level 2

Hi,

      How to programmatically activate/deactivate(start/stop) the configuration of the osgi bundle(Not bundle start/stop)?

Please provide the example or syntax for this issue.

Thanks & Regards,

Ashwini

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

You can get the bundle using BundleContext and start stop using Bundle APIs.

https://osgi.org/javadoc/r4v43/core/org/osgi/framework/BundleContext.html

https://osgi.org/javadoc/r4v43/core/org/osgi/framework/Bundle.html  '

https://www.javatips.net/api/org.osgi.framework.frameworkutil

BundleContext bundleContext = FrameworkUtil.getBundle(MyClass.class).getBundleContext();



Arun Patidar

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi,

You can get the bundle using BundleContext and start stop using Bundle APIs.

https://osgi.org/javadoc/r4v43/core/org/osgi/framework/BundleContext.html

https://osgi.org/javadoc/r4v43/core/org/osgi/framework/Bundle.html  '

https://www.javatips.net/api/org.osgi.framework.frameworkutil

BundleContext bundleContext = FrameworkUtil.getBundle(MyClass.class).getBundleContext();



Arun Patidar

Avatar

Community Advisor

One way to make the configurations ineffective is to have a checkbox. The related service can check the value of this property and proceed with the functions accordingly. To programmatically alter configs, please visit ConfigurationAdmin – Access OSGi configuration of other services


Aanchal Sikka