Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Osgi 使用蓝图的ManagedServiceFactory_Osgi_Blueprint Osgi - Fatal编程技术网

Osgi 使用蓝图的ManagedServiceFactory

Osgi 使用蓝图的ManagedServiceFactory,osgi,blueprint-osgi,Osgi,Blueprint Osgi,可通过以下方式注册ManagedServiceFactory:- private ServiceRegistration factoryService; public void start(BundleContext context) { Dictionary props = new Hashtable(); props.put("service.pid", "test.smssenderfactory"); factoryService = context.regist

可通过以下方式注册ManagedServiceFactory:-

private ServiceRegistration factoryService;
public void start(BundleContext context) {
    Dictionary props = new Hashtable();
    props.put("service.pid", "test.smssenderfactory");
    factoryService = context.registerService(ManagedServiceFactory.class.getName(),
        new SmsSenderFactory(), props);
}

如何在蓝图中做到这一点(示例将非常有用)?

ApacheAries支持托管服务。您可以在ApacheAries blueprint的集成测试中找到示例。在这种情况下,您可以更改SMSSenderFactory的代码,而不是像blueprint为您所做的那样直接实现ManagedServiceFactory

您还可以将您的代码(在问题中作为示例提供)嵌入到bean的init方法中(如果这是您的问题)。在这种情况下,应该在bean的destroy方法中注销ManagedServiceFactory

第三种选择是将blueprint排除在游戏之外。您已经有了ManagedServiceFactory实现,为什么不直接在包的Activator中注册它呢

第四个选项是与注释集之一一起使用。在这种情况下,还将生成元类型信息,您可以通过webconsole配置SMSSender

我建议你使用最后一个选项