【发布时间】:2011-12-11 20:08:33
【问题描述】:
我创建了一个非常简单的包:
public class Main implements BundleActivator, ServiceListener{
public void start(BundleContext bc) throws Exception {
bc.addServiceListener(this);
//trivial system out
System.out.println("started");
//output to file
FileWriter fw = new FileWriter("test.txt");
fw.write("it has worked");
fw.close();
//opening of a frame
JFrame f = new JFrame();
JLabel l = new JLabel("test");
f.add(l);
f.setVisible(true);
f.pack();
}
(other methods with empty body)
我已经编辑了清单文件:
Bundle-Name: Service listener example
Bundle-Description: A bundle that displays messages at startup and whe service events occur
Bundle-Vendor: Apache Felix
Bundle-Version: 1.0.0
Bundle-Activator: tosgi01.Main
Import-Package: org.osgi.framework
我整理了所有这些东西,推出了 felix 并: 启动文件:testosgi.jar
它不会给出错误,但也不起作用。 有没有办法获得一些关于正在发生的事情的详细信息?
【问题讨论】:
-
我认为这个链接http://www.javacodegeeks.com/2012/04/osgi-modularizing-your-application.html为您提供了更好的解决方案来满足您的需求。
标签: java osgi apache-felix