This article describes how to configure a simple Web application based on Eclipse Equinox OSGi in Eclipse to build a more complex application based on the Eclipse version 3.3.1, which is used in this article. If your eclipse version is 3.2.0 or above, it should be OK.
One, support static pages and servlet
1. Create a new plugin project, Net.bjzhanghao.osgi.test, in the first step of the wizard, select this plug-in is target, and in the next "Plug-in Options", select "Generate an Activator ".
2. Add the following dependencies in the MANIFEST.MF of the example project, which are all from eclipse:
org.eclipse.equinox.http.jetty
org.eclipse.equinox.http.servlet
org.mortbay.j etty
org.apache.commons.logging
javax.servlet
org.eclipse.equinox.http.registry
3. In the example project root directory to create a directory to place Web files, such as "Web_files", in this directory to write a simple index.html file.
4. Create a Plugin.xml document for the project, which reads as follows:
Alias= "/web"
Base-name= "/web_files"/>
Note that this time if the MANIFEST.MF prompts the error, as long as the Bundle-symbolicname line after the addition of "; Singleton:=true" can be resolved.
5. You can start this application now. Select "Run->open Run Dialog ..." On the Eclipse menu, create a new startup configuration entry under the "OSGi Framework" on the left, and click "Deselect All" on the right to clear all the check boxes. Then select your own OSGi project under Workspace, and then click the "ADD Required bundles" button, and Eclipse will automatically select the items on which it depends. Finally press the "Debug" button to start, the embedded jetty and our project will be started together.