Note | ||
---|---|---|
| ||
Documentation of Http Service 2.0.x in progress. |
Apache Felix HTTP Service
This bundle implements the HTTP Service Specification as described in chapter 102 of the OSGi Compendium, embedding the Jetty servlet container. The goal of the OSGI HTTP Service is to provide a standard and simplified way to register servlets and resources in a Servlet container, and to associate them with URIs.
Installing the Apache Felix HTTP Service bundle
The Apache Felix HTTP Service bundle can be installed and executed in any R4 OSGi container, and requires only the OSGi R4 Compendium bundle as a prerequisite.
Using the HTTP Service
The main components provided by the Apache Felix HTTP Service bundle are:
...
Code Block |
---|
public class Activator implements BundleActivator { public void start(BundleContext context) throws Exception { ServiceReference sRef = context.getServiceReference(HttpService.class.getName()); if (sRef != null) { HttpService service = (HttpService) context.getService(sRef); HttpContext myHttpContext = new MyHttpContext()); service.registerResources("/static", "/etc/www", myHttpContext); } } |
Configuration Properties
The service can both be configured using OSGi environment properties and using Configuration Admin. The service PID for this service is "org.apache.felix.http"
. If you use both methods, Configuration Admin takes precedence. The following properties can be used (some legacy property names still exist but are not documented here on purpose):
...