同一组件中的几个配置(@ Meta.OCD接口)

Nic*_*oul 2 configuration osgi liferay liferay-7

我有一个需要访问AConfiguration和BConfiguration的组件MyComponent:

my.MyComponent:

@Component(
    configurationPid = "[my.AConfiguration,my.BConfiguration]"
)
public class MyComponent {
    @Activate
    @Modified
    protected void activate(Map<String, Object> properties) {
        _aConfiguration = ConfigurableUtil
            .createConfigurable(AConfiguration.class, properties);
        _bConfiguration = ConfigurableUtil
            .createConfigurable(BConfiguration.class, properties);
    }

    public void hello() {
        System.out.println("A:" + _sConfiguration.valueA());
        System.out.println("B:" + _sConfiguration.valueB());
    }
}
Run Code Online (Sandbox Code Playgroud)

my.AConfiguration:

@Meta.OCD(
    id = "my.AConfiguration"
)
public interface AConfiguration {
    @Meta.AD(deflt = "6")
    public long valueA();
}
Run Code Online (Sandbox Code Playgroud)

my.BConfiguration:

@Meta.OCD(
    id = "my.BConfiguration"
)
public interface BConfiguration {
    @Meta.AD(deflt = "6")
    public long valueB();
}
Run Code Online (Sandbox Code Playgroud)

问题:配置valueA和valueB以7使用Liferay的配置UI无效,MyComponent.hello()仍然可以看到默认值6.

我究竟做错了什么?
使组件使用来自多个配置界面的配置信息的正确方法是什么?

使用案例:我的组件执行一些业务处理并将结果保存到远程服务器.有一个配置界面包含业务处理设置,一个配置界面包含远程服务器的URL.

Nei*_*ett 5

注释configurationPid上的属性格式@Component是错误的.它应该是:

configurationPid = { "my.AConfiguration", "my.BConfiguration" }
Run Code Online (Sandbox Code Playgroud)

这将创建两个条目字符串数组值,my.AConfigurationmy.BConfiguration.相反,您使用过:

configurationPid = "[my.AConfiguration,my.BConfiguration]"
Run Code Online (Sandbox Code Playgroud)

...这将创建一个单一的与文字值的字符串[my.AConfiguration,my.BConfiguration],这是几乎可以肯定不是你想要的.