2016-03-01 20 views
7

我有一個組件,其屬性如下。爲什麼sling:AEG中的/ etc /文件夾中的OsgiConfig節點不工作?

@Component(immediate = true, metatype = true, label = "Conf Details") 
@Service(value = { LocationConfigurationUtil.class }) 
@Properties({ 
     @Property(label = "location blueprint", name = "locationPath", value = "", description = "..."), 
     @Property(label = "location page template", name = "locationTemplate", value = "", description = "..."), 
     @Property(label = "basepath live copies", name = "liveCopyRoot", value = "/content/WebRoot", description = "...") }) 
public class LocationConfigurationUtil { 
@Activate 
    protected void activate(Map<String, Object> mapCreated) { 
      // some code 
    } 
} 

爲了使它成爲jcr節點中的可編輯屬性,我使用了非標準方法。我在路徑/apps/system/config中創建了sling:OsgiConfig,它具有在java代碼中聲明的屬性,該屬性工作正常。

screen shot

但如果我只是有相同sling:OsgiConfig/etc/myapp/myconfig,這是行不通的。

回答

9

使用默認設置時,JCR安裝程序提供程序不會在/libs/apps以外的文件夾中查找可安裝的軟件包和節點(sling:OsgiConfig)。因此/etc中的任何配置都不會被加載。

如果要更改此行爲,請在osgi配置控制檯中的「Apache Sling JCR Installer」配置中輸入搜索路徑條目。但請注意不推薦,您不應該在/etc中放置任何sling:osgiconfig節點。

+0

添加'/ etc:300'後,它開始在'/ etc/system/config /'中工作。但是文件夾'/ etc/myapp/myconfig'仍然無法工作。 – Dileepa

+1

將文件夾myconfig重命名爲config。 – awd

+0

工作。謝謝。 :) – Dileepa

5

請注意,將配置節點放在/etc下是一個非常糟糕的主意。

從視圖,/libs/apps安全點被鎖定了,但/etc/你打開自己至少兩個主要的安全漏洞:

  • OSGi的配置可以通過匿名用戶讀取
  • 代碼可以由非特權用戶部署

請重新考慮將/etc路徑添加到JCR安裝程序搜索路徑條目,而是部署您的配置文件離子到/apps

相關問題