Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

How to create an instance of ConfigurationAdmin without using the @Reference annotatio

Avatar

Level 4

The @Reference annotation doesn't work with all classes. I'd like to know if there is a way to create an instance using a static method on a factory class or if there is some other way. I've tried using the @Reference annotation in a utility class but it doesn't resolve the ConfigurationAdmin.

3 Replies

Avatar

Level 10

Hi there,

Thank you for reaching out to Adobe Community.

Which product exactly is it related to?

Thanks!

Avatar

Level 10

Can you please explain your use case more. @Reference is used within an OSGi bundle to inject another service into an OSGi service. For example - you can use @Refercne to inject a DataSourcePool into an OSGi service.

If this is not an AEM service - then @Reference will not work as there is nothing to inject. 

Avatar

Level 10

You can create an instance using BundleContext instead of @reference. refer [1] for an example

[1] http://adobeaemclub.com/osgi-services-without-annotation/