我有一个服务器端应用程序,并且想要将osgi框架嵌入到动态包加载中。
假设我想公开一个QuoteImpl实现IQuote(实例化为服务器容器引导程序/ Spring的一部分),供不同的Bundle使用。OSGI Embedded Equinox - 用于访问未在osgi框架中实例化的pojos的包
Q1。是否有一种将服务器应用程序实例暴露给Bundle的干净方式? (顺便说一句,因为遗产是不可能使服务器代码捆绑:)并且不想让整个应用程序osgi'ed。
试图通过服务和捆绑暴露投入IQuote。不知道我做得很好,但由于IQuote驻留在核心应用程序项目中而不是捆绑项目,导致未解决的编译问题失败。有任何想法吗?
尼尔非常感谢您回来。我真的用你的博客作为指导。 – Slash 2012-01-11 10:01:05
伟大的博客btw。我解决了编译问题。我有3个项目引用包(包含Iquote接口),Consumer包(使用IQuote)和Launcher项目(模仿我的应用程序服务器(不是包)并以编程方式注册服务IQuote的实现)。当我尝试执行context.getServiceReference(IQuoteService.class.getName())时,我在consumer bundle中为serviceReference获得一个NULL; 我的问题是:当然,我错过了一些东西。实施是否需要捆绑?启动器在我启动框架时注册服务(不在Activator中) – Slash 2012-01-11 10:14:18
'public static void main(String [] args){ \t .. \t FrameworkFactory frameworkFactory = ServiceLoader.load(FrameworkFactory.class).iterator()。next (); config.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA “osgi.main”); 框架框架= frameworkFactory.newFramework(config); framework.start(); \t \t \t \t \t BundleContext context = framework.getBundleContext(); context.registerService(IQuoteService.class.getName(),new SimpleQuote(),null); \t} } – Slash 2012-01-11 11:06:15