实例化OSGi服务我具有其中我有以下组分的OSGi模块化系统:发布非@与iPOJO
- 一些具体协议实例实现方式中,其代表通过specfic协议的特定服务器的连接(实例化每个连接服务)
- 一些具体协议实例管理器服务,创建和预先配置按需实例(多个singletone服务从中,通常,不同的包)
- ,其聚合协议管理服务,并要求他们提供协议实例连接管理需要的时候(单singletone服务)
它们被打包到OSGi包如下:
`-ConnectionManager
`-ConnectionManager.class
`-IrcProtocol
`-IrcProtocolManagerService.class
`-IrcProtocolInstance.class
`-XMPPProtocol
`-XMPPProtocolManagerService.class
`-XMPPProtocolInstance.class
的ConnectionManager
标注有
@Provides
@Instantiate
@Component
并实现Subscriber
接口,enbles它具有发送和收听邮件的能力,可以输入某种类型的Event Admin
。
每个*ProtocolManager
标注有
@Provides
@Instantiate
@Component
并实现ProtocolManager
接口,这使得它的发现由ConnectionManager
服务侦听器。
每个*ProtocolInstance
是annoteted与
@Provides
@Component
,并实现Subscriber
接口。它还实现了ProtocolInstance
接口,它提供了如connect()
和disconnect()
这样的通用连接操作。
这里的问题是,ProtocolInstance
S被手工制作,用new
运营商的ProtocolManager
内,而不是由@Instantiate
注释触发,正因为如此 - 不参与iPOJO服务发布,尽管这是@Provides
注释。
的问题是:如何正确(最好声明,与注解)发布该程序创建ProtocolListener
服务,而无需手动潜入原OSGi服务发布(至少外一些工厂,也许)?或者,也许,如何重新构建我的系统,以便更好地与无声的iPOJO指南一起玩呢?