本文介绍了动态更新iPOJO中的定位服务提供者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个组件声明为:

<ipojo>
    <component classname="HelloClass" name="helloCom" immediate="true">
        <requires field="delayService" id="id1">
        </requires>
    </component>
    <instance component="helloCom" name="hello">
        <property name="requires.from">
            <property name="id1" value="A"/>
        </property>
    </instance> 
</ipojo>

此组件的jar文件:helloComponent.jar

The jar file of this component :helloComponent.jar

现在,我想将(value ="A")更新为(value ="AA").因此,我使用ConfigurationAdmin实现了一个组件来更新此属性

Now, i want to update (value="A") to (value="AA"). Thus, i implement a component using ConfigurationAdmin to update this property

public class ControllerReconfiguration {

private ConfigurationAdmin m_configAdmin;

@SuppressWarnings({ "rawtypes", "unchecked" })
public void reconfigure() throws IOException {
    Configuration configuration = m_configAdmin.getConfiguration("hello","file:./helloComponent.jar");
    configuration.setBundleLocation("file:./helloComponent.jar");
    Properties props = new Properties();
    //Dictionary props = new Hashtable();
    props.put("id1", "AA");
    configuration.update(props);
    System.out.println("Update");       

}
}

但是,此ControllerReconfiguration组件无法在"hello"实例中更新值"A"(通过"AA").

However, this ControllerReconfiguration component can't update the value 'A' (by 'AA') in 'hello' instance.

请如何修改此ControllerReconfiguration组件?

How to modify this ControllerReconfiguration component, please ?

感谢您的帮助.

推荐答案

不幸的是,您不能像这样推送新的"from"配置.

Unfortunately, you can't push new 'from' configuration like this.

但是,您可以直接使用iPOJO内省API: http://felix.apache.org/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/ipojo-advanced -topics/using-ipojo-introspection-api.html

However, you can use the iPOJO introspection API directly: http://felix.apache.org/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/ipojo-advanced-topics/using-ipojo-introspection-api.html

  1. 获取实例的架构服务
  2. 获取InstanceDescription和DependencyDescription
  3. 调用setFilter方法

这篇关于动态更新iPOJO中的定位服务提供者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 14:22