Embedding an HTTP server in Equinox

Equinox provides two complete implementations of the OSGi Http Service suitable for embedding.

  • org.eclipse.equinox.http
    Very small footprint suitable for resource constrained environments.
    API compatible with Servlet 2.4 but provides limited support beyond Servlet API 2.1.
  • org.eclipse.equinox.http.jetty
    Implemented using Jetty as the underlying engine for providing Servlet API 2.4 Support.

Bundles

The following bundles are involved in putting together an Http Service environment:

  • org.eclipse.equinox.http
OR
  • org.eclipse.equinox.http.jetty
  • org.eclipse.equinox.http.servlet
  • org.mortbay.jetty (v5_1_11 - from Orbit Depot)
  • org.apache.commons.logging (v1_0_4 - from Orbit Depot)

  • javax.servlet (v2_4 - from Orbit Depot)
  • [optional] org.eclipse.equinox.http.registry
    Provides servlet, resource, and httpcontext extension points based on an OSGi HttpService.

The org.eclipse.equinox.* projects can be retrieved from the equinox CVS depot.
(e.g. cvsroot/eclipse/org.eclipse.equinox.http)

The 3rd party bundles can be retrieved from the Orbit CVS Depott.
(e.g. cvsroot/tools/org.eclipse.orbit/javax.servlet [branch v2_4])]

[Suggested] If you're using Eclipse it might be far simpler to "import" a team project set with everything needed.
Equinox Http Service: (regular) or (proxied)
Jetty-based Http Service: (regular) or (proxied)

Additional Notes:

  • To build and use these projects you'll need to be running the Eclipse SDK 3.2 or later.

Writing the server application

See the Writing a bundle-based server application for information on how to write a bundle based web application.

Running the server

To run the server and your application, carry out the following steps:

  • Create an OSGi Framework launch configuration Run > Run... > OSGi Framework
  • In the Plug-ins tab, de-select all the bundles
  • Select the bundles listed above and your application (e.g., com.example.http.application)
  • Run the launch configuration
  • Launch your favorite web browser and access the URLs

Buy The Book

Equinox News feed
EclipseRT