2013-10-18 30 views
0

我製作了一個osgi Bundle,它註冊了一個帶有嵌入式applet的html頁面。OSGi從applet中檢索BundleContext

項目插頭的結構如下:

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

我怎樣才能從DApplet的BundleContext的?

+0

如何使用OSGi與小程序?啓動或嵌入(請參閱此文章http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html)? – Dewfy

+0

我使用嵌入在Tomcat中的equinox(使用servlet橋),使用applet我使用httpservice註冊了帶有Applet標籤的html頁面,並且我還註冊了applet需要的.class文件。它的工作原理,但我不知道如何獲得bundlecontext。 –

+0

僅僅因爲OSGi在Tomcat中運行並不意味着它也在applet中運行。該applet運行在另一臺計算機上的Web瀏覽器中 - 這是一個完全不同的環境。 –

回答

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; 

} 



} 
+0

我不明白這是如何回答這個問題的? Applet在最終用戶瀏覽器上運行。 – eis

+0

對不起,如果我離開了基地,我只想簡單地考慮這個問題。我傾向於OSGi解決方案(也是問題)。 :-)這也是一個有趣的話題。 – Tony