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.
Views
Replies
Total Likes
Could you please provide a sample of code you are trying to migrate ?
May be this might help as a starting point
http://blogs.adobe.com/experiencedelivers/experience-management/using-osgi-annotations-aem6-2/
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
See - Using OSGi annotations (>= AEM6.2) - Experience Delivers
There are code examples too in GitHub.
Views
Replies
Total Likes
Hi smacdonald2008,
Thanks for your reply but I am afraid these docs are not helping me. Earlier I read run mode configurations using
@Property(unbounded=PropertyUnbounded.DEFAULT, label="Standard Rates Service URL", description="URL to connect Standard Rates Service API")
and in the @Activate I apply the below code to read the property values.
protected void activate(Map<String, Object> properties)
{
this.standardrateserviceurl = PropertiesUtil.toString(properties.get(STANDARD_SERVICE_URL), "default");
}
By using this I can create a node of type 'sling:OsgiConfig' with fully qualified class name under each run mode config folders. This would help me from manually changing the property files in each environment.
But I am not sure on how to do that using the OSGI R6 annotations.
I am trying to rewrite this one 'https://helpx.adobe.com/experience-manager/using/osgi_config.html'
Views
Replies
Total Likes
Exactly same as before, but rely on the new OSGi annotations, annotations, @Activated and @Modified are still there.
Regards,
Peter
Views
Replies
Total Likes
@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
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies