3

I'm working with JBossAS7. My application has some OSGI modules and big non-OSGI part. I tried lookup osgi services in non-osgi subsystem through JNDI but they are not present in JNDI context. I found similar problem at JBOSS 7 - Osgi Bundles not present in JNDI TREE but I dont found any solution there. If JBoss team didn't implement this functionality yet, how can I resolve this problem now?

I tried adding my service to JNDI context manually but got an exception because JNDI context is read only(according to https://issues.jboss.org/browse/AS7-421)

4

1 回答 1

6

它还没有完全集成(监视JBOSGI-81以检查状态),但是我认为您可以通过使用 Apache Aries JNDI OSGi 捆绑包并将它们部署在 JBoss AS7 中来完成这项工作。

为此,请部署并启动

JNDI 包会抱怨它不能使用 NamingManager 设置一些静态,但是您可以忽略它,因为 AS7 JNDI 会处理这些。安装了上面的捆绑包后,您应该可以做到

osgi:service/org.foo.SomeInterface

osgi:servicelist 

键入查找... 例如,您可以尝试以下方法来查找框架注册的 Start Level Service:

osgi:service/org.osgi.service.startlevel.StartLevel

我刚刚用 AS7 7.1.2 尝试过它,它对我有用......

需要注意的一点是,如果您要查找的实体实现了在另一个 AS7/MSC 模块或 OSGi 包中定义的接口,那么如果您希望能够转换到此接口,则需要确保消费者对其具有可见性。在 OSGi 世界中,您可以只导入包,但在 AS7 模块(例如,war 文件)中,您可以通过添加Dependencies清单头来实现这一点。

于 2012-05-10T16:04:19.450 回答