Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Osgi Config in Plain JAVA

Avatar

Avatar
Validate 1
Level 1
arvind
Level 1

Likes

2 likes

Total Posts

24 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
arvind
Level 1

Likes

2 likes

Total Posts

24 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile
arvind
Level 1

16-07-2020

Dear Team,

 

Is there any way to read OSGI Configuration values in a Plain JAVA Class (Not Service or Component) ?

 

Better if someone could help me out with example.

 

Thank you in advance.

 

Regards,

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
MVP
ArpitVarshney
MVP

Likes

135 likes

Total Posts

185 posts

Correct Reply

36 solutions
Top badges earned
Validate 1
Establish
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Validate 1
MVP
ArpitVarshney
MVP

Likes

135 likes

Total Posts

185 posts

Correct Reply

36 solutions
Top badges earned
Validate 1
Establish
Give Back 5
Give Back 3
Give Back 25
View profile
ArpitVarshney
MVP

16-07-2020

Hi @arvind 

Could you try below code:

 

BundleContext bundleContext = FrameworkUtil.getBundle(ServiceName.class).getBundleContext();
ServiceReference<?> configurationAdminReference =
bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
ConfigurationAdmin confAdmin = (ConfigurationAdmin) bundleContext.getService(configurationAdminReference);
Configuration config = confAdmin.getConfiguration("service-pid");
Dictionary<String, Object> properties = config.getProperties();
if (properties == null) {
LOGGER.error("No Properties found for the Config PID: {}", configPid);
} else {
String property = (String) properties.get("propertyName");
}

 

Note: Replace hardcoded service-pid and ServiceName with actual one.

Reference :https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-read-osgi-configura...

 

Regards,

Arpit

Answers (0)