Pax-Web retrieving Jetty connector info

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Pax-Web retrieving Jetty connector info

Alex Soto

I am wondering how I can retrieve at runtime the connection information. That is, scheme, host, port, virtual host, etc. 
I am setting up Pax-Web to use a specific Jetty connector, which is configured externally, like this:

  <service interface="org.ops4j.pax.web.service.whiteboard.HttpContextMapping">
<entry key="">

<bean class="org.ops4j.pax.web.extender.whiteboard.runtime.DefaultHttpContextMapping">
<property name="httpContextId" value="internalAPIContext" />
<property name="path" value="#{context.path}#{api.root.path}" />
<property name="parameters">
<entry key="httpContext.virtualhosts" value=""/>
<entry key="httpContext.connectors" value="internalAPIConnector"/>

The use case is that my rest service need to return full URLs, with scheme, host, port, etc.  so I don’t want to hard code this, but extract it dynamically.
In the log file I see something like this:

2020-02-05T13:09:26,308 | INFO  | paxweb-config-1-thread-2 | AbstractConnector                | 239 - org.eclipse.jetty.util - 9.4.22.v20191022 | Stopped internalAPIConnector@6c6781c7{HTTP/1.1,[http/1.1]}{}

Which suggest this information is known by Pax-Web.
Is it possible to query this at runtime?

Best regards,
Alex soto