小编SDJ*_*SDJ的帖子

OSGi - system.bundle是什么意思?

我是OSGi的新手.我在Jboss AS 7.1中使用Apache felix for OSGi容器.在访问"localhost:8090/system/console"时,我可以找到已安装的软件包列表.当我检查一个bundle的导入包时,我发现很少从system.bundle导入.
来自system.bundle的导入包javax.activation,version = 0.0.0 (0)
我的问题是,system.bundle是什么意思?从哪里装货?

java osgi apache-felix jboss7.x

3
推荐指数
1
解决办法
891
查看次数

多个 OSGi 服务

我是 OSGi 的新手,正在尝试使用 OSGi 开发应用程序。我有一个 OSGi 服务,它有一个接口和两个实现。

界面: ExportService

实现:ExcelExportServiceImplPdfExportServiceImpl

ExportService是我的接口ExcelExportServiceImplPdfExportServiceImplExportService.

我想ExcelExportServiceImplPdfExportServiceImpl作为两种不同的服务。

从我的应用程序包中,如果我想使用 excel 导出,我应该能够在ExcelExportServiceImpl不涉及PdfExportServiceImpl.

如何注册两个具有相同接口的不同服务?

@Override
public void start(BundleContext context) throws Exception {
        context.registerService(ExportService.class.getName(), new ExcelExportServiceImpl(), null);
        context.registerService(ExportService.class.getName(), new PdfExportServiceImpl(), null);
    }
}
Run Code Online (Sandbox Code Playgroud)

现在,我在我的激活器中想出了上面的代码,它似乎不起作用,因为这两个服务都ExportService.class.getName()作为类名。如何使用一个接口在同一个 bundle 中实现两个不同的服务?

更新/解决方案:

我在我的服务包的激活器中更改了如下代码,

@Override
public void start(BundleContext context) throws Exception {
        Hashtable excelProperty = new Hashtable();
        excelProperty.put("type", "excel");
        excelServiceRegistration = context.registerService(ExportService.class.getName(), new ExcelExportServiceImpl(), excelProperty); …
Run Code Online (Sandbox Code Playgroud)

java service osgi osgi-bundle

3
推荐指数
1
解决办法
1579
查看次数

标签 统计

java ×2

osgi ×2

apache-felix ×1

jboss7.x ×1

osgi-bundle ×1

service ×1