import org.osgi.service.component.annotations.*;
@Component
@Service
public class MyService {
public String getMessage() {
return "Hello, OSGi!";
}
}
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.4.0</version>
</dependency>
</dependencies>
http.service.path=/api
http.service.port=8080
import org.apache.felix.http.api.*;
import org.osgi.framework.*;
public class HttpServiceExample {
public void start(BundleContext context) {
HttpService httpService = new HttpServiceFactory().createHttpService();
httpService.registerServlet("/api/*", new MyServlet(), null, null);
httpService.start();
}
}