我正在尝试编写基于OSGi的桌面应用程序。我有一个Swing JFrame,我想添加添加模块(其他包)的可能性。我走过了EclipseZone OSGi at JSig tutorial,但每个应用程序都是从OSGi Framework开始的(在这种情况下,是Knopflerfish OSGi Desktop)。在桌面独立应用程序中使用OSGi
所以我的问题是,是否有启动时不可见的OSGi框架的应用程序的选项?我知道,从代码中可以改变bundle的属性,但是如何改变框架的属性呢? (例如,默认捆绑的存储位置,默认的行动时,束在位置等等?)
public class MainFrame extends ServiceTracker implements BundleActivator {
public MainFrame(BundleContext context, JToolBar toolBar) {
// select, which services is the bundle tracking
super(context, JMenu.class.getName(), null);
}
@Override
public void start(BundleContext context) throws Exception {
//display a JFrame
}
@Override
public void stop(BundleContext context) throws Exception {
//hide a JFrame
}
@Override
public Object addingService(ServiceReference reference) {
// Process a Service and return a JMenu
return new JMenu();
}
@Override
public void removedService(ServiceReference reference, Object service) {
// remove a JMenu from a JFrame
}
public static void main(String[] args) {
// ????????????????????????????????????????????
// ????????????????????????????????????????????
}
}
我上面写的(我已经张贴只是一个草图)一类,但我不知道,什么在main()函数中写入。这个包在Knopflerfish OSGi Desktop中工作正常,但我希望它在没有它的情况下运行。
谢谢!博客帖子本身实际上解决了它。 – Benjamin 2011-12-21 05:17:13