How to read OSGI run mode configurations with OSGI R6 annotation? | Community
Skip to main content
Level 2
December 28, 2017

How to read OSGI run mode configurations with OSGI R6 annotation?

  • December 28, 2017
  • 3 replies
  • 8899 views

I am working on the migration of SCR annotation to OSGI R6 annotations. But I am not sure on how to progress with the OSGI run mode configuration migration using the new @component annotation provided by org.osgi.service.component.annotations. Any help would be appreciated.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

VeenaVikraman
Community Advisor
Community Advisor
December 28, 2017
Level 2
December 29, 2017

Thanks Veena for your reply. I am trying to migrate something similar in this document. (https://helpx.adobe.com/experience-manager/using/osgi_config.html ). They are using SCR annotations in this. I am trying to do that using the OSGI R6 annotations.

smacdonald2008
Level 10
December 29, 2017

See - Using OSGi annotations (>= AEM6.2) - Experience Delivers

There are code examples too in GitHub.

susheel
Level 5
December 29, 2017

@ObjectClassDefinition(name = "Example Global Configs", description = "Example Global Configs")

public @interface ExampleGlobalConfig {

    @AttributeDefinition(name = "example.path", description = "This is example path")

    String getExamplePath() default "";

}

@Component(service = ExampleGlobalConfigService.class, immediate = true)

@Designate(ocd = ExampleGlobalConfig.class)

public class ExampleGlobalConfigService {

/**

* example path

*/

private String examplePath;

@Activate

@Modified

protected void activate(final ExampleGlobalConfig exampleGlobalConfig) {

examplePath = exampleGlobalConfig.getExamplePath();

}

/**

* @return the exampleath

        */

public String getExamplePath() {

return examplePath;

}

}


May be you can do something like this. You can use the service in servlets or sling models or wcmusepojo or anywhere else you need

Level 2
January 1, 2018

Thanks susheel for your reply but I am trying to rewrite this one 'I am trying to rewrite this one 'https://helpx.adobe.com/experience-manager/using/osgi_config.html'. Unfortunately these code examples are not helping me.

Level 2
January 2, 2018

Thanks all for your help. I got it resolved. What I did was that I created a new component without specifying the name attribute. Then created OSGI config nodes under different run modes. Then in the activate method with parameter of type Map simply called the property field name.