활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.
활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.
how to read OSGI factory configuration values from configuration
i have created configuration which have three properties (string,string , Array ), same configuration for Apache Sling Logging Logger Configuration
please can you send me implementation code for how to get OSGI factory configuration values.
해결되었습니다! 솔루션으로 이동.
조회 수
답글
좋아요 수
Hi @Jorg,
Small correction. I think, Component annotation must have "configurationFactory = true" attribute to enable OSGI Service factory.
For more details, follow the instruction given in below doc.
Regards,
Jitendra
조회 수
답글
좋아요 수
See this AEM Community Article on this use case:
This development article guides you through creating an OSGi bundle that reads OSGi configuration values that are defined in CRXDE Lite. To read this development article, click:
https://helpx.adobe.com/experience-manager/using/osgi_config.html.
조회 수
답글
좋아요 수
private final String MY_OSGI_PROPERTY = "MyProperty"; private String myProperty; @Activate protected void activate(final Map<String, Object> config) { this.myProperty = PropertiesUtil.toString(config.get(MY_OSGI_PROPERTY), null); }
조회 수
답글
좋아요 수
Hi
Please refer to this Helpx artilce:-
Link:- https://helpx.adobe.com/experience-manager/using/osgi_config.html
This class contains this method that reads the configuration values.
//
myArraySetting = PropertiesUtil.toStringArray(properties.get(MY_PROPERTY_NAME), ArrayUtils.EMPTY_STRING_ARRAY);
protected void readProperties(Map<String, Object> properties)
{
LOG.info(properties.toString());
this.multiString = PropertiesUtil.toStringArray(properties.get("multifield"));
LOG.info("Mutli String Size: " + this.multiString.length);
this.simpleString = PropertiesUtil.toString(properties.get("simplefield"), "default");
LOG.info("Simple String: " + this.simpleString);
}
I hope this would help you.
Thanks and Regards
Kautuk Sahni
조회 수
답글
좋아요 수
Here is some sample code:
@Property(label = "Path", description = "Delete this path", value = "/tmp/mypath") public static final String CLEANUP_PATH = "cleanupPath"; protected void activate(ComponentContext componentContext){ configure(componentContext.getProperties()); } protected void configure(Dictionary<?, ?> properties) { this.cleanupPath = (String.valueOf(properties.get(CLEANUP_PATH)) != null)?String.valueOf(properties.get(CLEANUP_PATH)):null; LOGGER.info("configure: cleanupPath='{}''", this.cleanupPath); }
Hope this helps.
조회 수
답글
좋아요 수
In case you are referring to an OSGI service factory (your question isn't 100% clear to me): The difference from creating (and writing) a simple OSGI service to an OSGI service factory is just the "factory=true" parameter to the @Component annotation. Then you have the chance to create N instances of the configuration, and for each configuration a dedicated version of the service is started with this specific configuration.
조회 수
답글
좋아요 수
Hi @Jorg,
Small correction. I think, Component annotation must have "configurationFactory = true" attribute to enable OSGI Service factory.
For more details, follow the instruction given in below doc.
Regards,
Jitendra
조회 수
답글
좋아요 수