활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.
활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.
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!
해결되었습니다! 솔루션으로 이동.
조회 수
답글
좋아요 수
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
조회 수
답글
좋아요 수
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...
조회 수
답글
좋아요 수
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
조회 수
답글
좋아요 수
조회 수
답글
좋아요 수
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.
조회 수
답글
좋아요 수