See https://github.com/everit-org/osgi-remote-jersey/tree/v1.0.2
- Go to tests directory
- Edit pom.xml and change the jetty.port in felixtest environment to a port you like
- run "mvn install" on tests
- go to target/eosgi-dist/felixtest/bin
- run runConsole.bat (or runConsole.sh on linux)
- open localhost:port/system/console and see what is installed (basically all of the maven dependencies of the tests project)
The solution works on felix and equinox as well.
Update based on the question (without an extender):
You can implement the same logic as the extender does. In short:
ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig.register(myJAXRSAnnotatedObjectOrClassType);
Servlet servletContainer = new ServletContainer(resourceConfig);
// register the newly created servlet instance to the server
You can register that servlet in several ways:
- via HTTPService
- with whiteboard pattern
- By creating a wab and
- Creating an own Servlet that wraps the jersey servletContainer instance
- Configure a new servlet in the web.xml that has the type ServletContainer
You can call resourceConfig.register multiple times. In this way, you can register many JARS annotated classes under one servlet instance.
With resourceConfig.register you can not only register JAXRS annotated classes, but also any component that Jersey knows about. For example, if you want to add JSON parsing feature, you can use:
resourceConfig.register(JacksonFeature.class);