简体   繁体   中英

How to read property from OSGI configuration in AEM 6.1 in model class which extends WCMUse class

I am extending my model class to WCMUse class to write my business logic. I have osgi configuration which has couple of properties. I want to read one of the property in my model class. I am not sure how to get the handle of osgi configuration in WCMUse class. Any pointers will be highly appreciated.

Adding the answer for future references.

You can use the #getSlingScriptHelper() method of the WCMUse class to get an handle of the SlingScriptHelper . This is the same sling object that is available through inclusion of global.jsp in traditional JSP scripts.

You can then call #getService() method of the SlingScriptHelper to look up the desired OSGi Service.

The following code snippet can be used in the model to get the service configuration

getSlingScriptHelper().getService(<<Configuration Service>>.class)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM