【发布时间】:2011-12-15 10:46:34
【问题描述】:
我正在尝试编写一个基于 OSGi 的桌面应用程序。我有一个 Swing JFrame,我想增加添加模块(其他包)的可能性。我浏览了EclipseZone OSGi at JSig tutorial,但每个应用程序都是从 OSGi 框架(在本例中为 Knopflerfish OSGi 桌面)启动的。
所以我的问题是,是否可以选择在没有可见 OSGi 框架的情况下启动应用程序?我知道,从代码中可以更改捆绑包的属性,但是如何更改框架的属性呢? (例如,默认捆绑存储位置、捆绑在该位置时的默认操作等?)
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 桌面上运行良好,但我希望它在没有它的情况下运行。
【问题讨论】: