0
我已經在config.author,config.publish等配置文件夾內創建了sling:OsgiConfig節點。我試圖做這樣的事情來從這些節點的屬性:AEM 6:SlingBindings對象爲空
public static List fetchTokenLinksFromOsgiConfig(final SlingHttpServletRequest slingRequest) throws IOException {
List<String> tokenlinksList = new ArrayList<String>();
SlingBindings bindings = (SlingBindings) slingRequest.getAttribute(SlingBindings.class.getName());
log.info("=================inside fetchTokenLinksFromOsgiConfig======================"+bindings);
SlingScriptHelper sling = bindings.getSling();
Configuration conf = sling.getService(org.osgi.service.cm.ConfigurationAdmin.class).getConfiguration("com.xxxxx.TokenLinksConfig");
log.info("=================inside fetchTokenLinksFromOsgiConfig:::taking configurations======================");
String TokenId = (String) conf.getProperties().get("TokenId");
String TokenSecret = (String) conf.getProperties().get("TokenSecret");
String OAuthLink = (String) conf.getProperties().get("OAuthLink");
log.info("=================TokenId:::TokenSecret:::OAuthLink======================"+TokenId +" "+TokenSecret+" "+OAuthLink);
if(!StringUtil.isEmpty(TokenId)) {
tokenlinksList.add(TokenId);
}
if(!StringUtil.isEmpty(TokenSecret)) {
tokenlinksList.add(TokenSecret);
}
if(!StringUtil.isEmpty(OAuthLink)) {
tokenlinksList.add(OAuthLink);
}
return tokenlinksList;
}
我打電話從吊索的servlet這樣這個方法:
List tokenList = OsgiConfigUtil.fetchTokenLinksFromOsgiConfig(slingRequest);
但類型SlingBindings的綁定對象來了空值。我不知道如何解決這個問題?
在此先感謝