Reputation: 4799
I'm using the Apache Felix HTTP Jetty bundle. I can start the servlet container / HttpService and assign it to a port using the system property
org.osgi.service.http.port=8080
But I would like to have two such services, bound to two different ports, eg my application API should be served on 8080, but some static web pages should be served on port 80.
Edit: for that last question, the service comes with the port value set in a property org.osgi.service.http.port: 8080
Upvotes: 1
Views: 2874
Reputation: 665
Felix http.jetty 3.2.6 provides a ManagedServiceFactory, which makes it easy to create multiple http instances with different configurations.
Upvotes: 1
Reputation: 2010
I believe you can if the Apache Felix HTTP Jetty bundle exposes a ManagedServiceFactory. (EDIT: It does not)
How to support virtual hosts with OSGI HttpService
http://www.codeaffine.com/2011/10/05/raprwt-osgi-integration-ii/
If I understand, the magic is in here:
If you create and register a Configuration using the pid of the managed service factory, it will create a new instance of HttpService using a new Pid.
Upvotes: 0
Reputation: 5285
If you switch over to Pax-Web you'll be able to do something like it. Pax-Web supports Virtual Hosts, and let's you bind a certain application to a single connection. Some more details on how to use it you'll find at my two blog posts:
Bind web applications to specific http connectors - part 1
Bind web applications to specific http connectors - part 2
Upvotes: 2
Reputation: 15372
As far as I know this is not possible with the Http servers in OSGi I've worked with. Creating a little forwarder between the ports is of course quite easy to do in Java.
Upvotes: 0