package com.example.httpbundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class HTTPBundleActivator implements BundleActivator {
private HttpService httpService;
public void start(BundleContext context) throws Exception {
httpService = (HttpService) context.getService(context.getServiceReference(HttpService.class.getName()));
if (httpService != null) {
httpService.registerServlet("/hello", new HelloWorldServlet(), null, null);
}
}
public void stop(BundleContext context) throws Exception {
if (httpService != null) {
httpService.unregister("/hello");
}
}
}
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: com.example.httpbundle
Bundle-Version: 1.0.0
Import-Package: org.osgi.framework, javax.servlet, javax.servlet.http
Export-Package: com.example.httpbundle
Bundle-Activator: com.example.httpbundle.HTTPBundleActivator
java -jar bin/felix.jar
install file:/path/to/your/bundle.jar
start <bundle_id>