AEM OSGI Configuration | Community
Skip to main content

2 replies

Level 4
July 8, 2025

Hi @nsvsrk ,

 

OSGI Config:

  • Whenever we need to pass different values (ex: service endpoints) to the same parameters based on run mode(environment, ex: Dev), we shall use OSGI configs.
  • These configs help to make this change without touching code and restart the server.
  • There is a java class which read values from the respective configuration into code, in that java class we shall provide default values but in OSGI configuration we need to pass the actual value as this value take precedence.
@Getter @Component( service = SampleConfig.class, immediate = true, configurationPolicy = ConfigurationPolicy.REQUIRE ) @Designate(ocd = SampleConfig.Configuration.class) public class SampleConfig { … … @ObjectClassDefinition( name = “Sample”, description = “Sample” ) public @interface Configuration { @AttributeDefinition(name = “Prop1) String prop1(); @AttributeDefinition(name = “Prop2”) boolean prop2() default true; } }
  • As fas as i know, we can create through code only.

Thanks,

Raju.

Translate
nsvsrkAuthor
Level 8
July 10, 2025

Hi,

 

I want to mark this reply as correct.

 

But I do not see that button on this post.

 

Any ideas?

 

Thanks,

RK.

Translate