OSGi从applet中检索BundleContext

时间:2013-10-18 13:30:37

标签: java applet osgi

我已经创建了一个osgi Bundle,它注册了一个带有嵌入式applet的html页面。

插件项目的结构如下:

/META-INF/MANIFEST.MF
/thesis/bot/wab/Activator.class      //BundleActivator
/thesis/bot/wab/Applet/DApplet.class //extends JApplet
/home.html

如何从DApplet获取BundleContext?

1 个答案:

答案 0 :(得分:0)

有没有办法在OSGi中运行它?像这样:

@Component(provide = Servlet.class, properties = { "alias=/someUrl" })
public class MyServer extends HttpServlet {
 BundleContext bundleContext;


 public void doGet(HttpServletRequest request,HttpServletResponse response) throws  ServletException, IOException {

     PrintWriter out = response.getWriter();
     out.println("OSGi On the Job and do your stuff from here");
 }
 // Your Activator
 @Activate
 public void activate(final BundleContext aContext, Map<String, Object> props) {
  this.bundleContext = aContext;

 }



}