Hi everyone,
we have two special components in an OSGi Bundle. One should only run on the author instance and the other only on publish. Does anyone of you know how to disable each component on author/publish while activating the bundle?
We've tried this so far:
private static final String AUTHOR_RUN_MODE = "author"; @Activate public void activate(final ComponentContext context) throws Exception { @SuppressWarnings("rawtypes") final Dictionary properties = context.getProperties(); if (!slingSettingsService.getRunModes().contains(AUTHOR_RUN_MODE)) { final String componentName = (String) properties.get(ComponentConstants.COMPONENT_NAME); context.disableComponent(componentName); } }
Thanks in advance!
Solved! Go to Solution.
Views
Replies
Total Likes
a better way would be to use OSGI bool type property, read the value of that property (which will either be boolean true or false) and accordingly disable the OSGI component in activate method.
Now the value of the Bool property can be driven and forced to true or false as per your AEM run modes.. i.e. using runmode specific environment configuration file.
Follow the mentioned article to understand more on environment specific OSGI configuration - http://www.wemblog.com/2012/10/how-to-work-with-configurations-in-cq.html
Hope it helps.
- Runal
Views
Replies
Total Likes
You can create config nodes under your project in AEM. Refer - http://docs.adobe.com/docs/en/cq/5-6-1/deploying/configuring_osgi.html#Creating%20the%20Configuratio...
Views
Replies
Total Likes
a better way would be to use OSGI bool type property, read the value of that property (which will either be boolean true or false) and accordingly disable the OSGI component in activate method.
Now the value of the Bool property can be driven and forced to true or false as per your AEM run modes.. i.e. using runmode specific environment configuration file.
Follow the mentioned article to understand more on environment specific OSGI configuration - http://www.wemblog.com/2012/10/how-to-work-with-configurations-in-cq.html
Hope it helps.
- Runal
Views
Replies
Total Likes
Views
Replies
Total Likes
I prefer to do this via configuration, and not via code.
You can use: policy=ConfigurationPolicy.REQUIRE
on @Component for this
When this is on your OSGi-component, this component will only be 'active' if there is a config supplied for it.
Thanks for your help. We didn't want to use a configuration file but it looks like that this is the best way so far to solve the problem.
Views
Replies
Total Likes