I'm explicitly starting the Servers myself, so I know when they start. I am not trying to register an OSGi service. I'm trying to register with a service discovery service such as Consul when my server starts, so that I can let others know that my service is available and where (and perhaps register a health check). The "calculate a complete address" is the part I'm trying to figure out. It doesn't sound like there's a generic CXF way to do it, so I might have to resort to configuration options (like bind address, port, and path) to tell me the complete picture.
On Tue, May 23, 2017 at 10:07 AM Sergey Beryozkin <[email protected]> wrote: > Hi James, > > probably better to register ServerLifecycleListener > > ServerLifeCycleManager mgr = > bus.getExtension(ServerLifeCycleManager.class); > if (mgr != null) { > mgr.registerListener(listener); > } > > where on the startServer event it would calculate a complete address and > register with OSGI as needed > > The relative endpoint address should stay as is for it to be accessible > via the multiple servlets, etc > > Cheers, Sergey > On 23/05/17 14:46, James Carman wrote: > > That's what I figured. Just thought I'd check in with the experts. If I > > were to want to provide a patch, do you even think it's possible? > > > > On Tue, May 23, 2017 at 9:33 AM Sergey Beryozkin <[email protected]> > > wrote: > > > >> Right, if the endpoint address is relative (=> Servlet transport) then > >> CXF does not know until the runtime what the container host, port or > >> context is > >> > >> Sergey > >> > >> > >> On 23/05/17 14:02, James Carman wrote: > >>> I tried various attempts at getting what need: > >>> > >>> final Server server = sf.create(); > >>> > >>> if(server.getDestination() instanceof AbstractHTTPDestination) { > >>> AbstractHTTPDestination httpDestination = > >>> (AbstractHTTPDestination)server.getDestination(); > >>> LOGGER.info("publishedEndpointUrl: {}", > >>> httpDestination.getEndpointInfo().getProperty("publishedEndpointUrl")); > >>> LOGGER.info("AbstractHTTPDestination.getPath(): {}", > >>> httpDestination.getPath()); > >>> LOGGER.info("AbstractHTTPDestination.getServer().getRedirectURL(): > >> {}", > >>> httpDestination.getServer().getRedirectURL()); > >>> } > >>> > >> > LOGGER.info("server.getDestination().getAddress().getAddress().getValue(): > >>> {}", server.getDestination().getAddress().getAddress().getValue()); > >>> LOGGER.info("server.getEndpoint().getEndpointInfo().getAddress(): {}", > >>> server.getEndpoint().getEndpointInfo().getAddress()); > >>> > >>> > >>> Which only yielded: > >>> > >>> > >>> 2017-05-23T09:00:57,340 | INFO | pool-40-thread-1 | > >>> DefaultJaxrsServerFactory | 140 - org.microbule.core - 0.3.0.SNAPSHOT | > >>> publishedEndpointUrl: null > >>> 2017-05-23T09:00:57,340 | INFO | pool-40-thread-1 | > >>> DefaultJaxrsServerFactory | 140 - org.microbule.core - 0.3.0.SNAPSHOT | > >>> AbstractHTTPDestination.getPath(): /hello > >>> 2017-05-23T09:00:57,341 | INFO | pool-40-thread-1 | > >>> DefaultJaxrsServerFactory | 140 - org.microbule.core - 0.3.0.SNAPSHOT | > >>> AbstractHTTPDestination.getServer().getRedirectURL(): null > >>> 2017-05-23T09:00:57,342 | INFO | pool-40-thread-1 | > >>> DefaultJaxrsServerFactory | 140 - org.microbule.core - 0.3.0.SNAPSHOT | > >>> server.getDestination().getAddress().getAddress().getValue(): /hello > >>> 2017-05-23T09:00:57,342 | INFO | pool-40-thread-1 | > >>> DefaultJaxrsServerFactory | 140 - org.microbule.core - 0.3.0.SNAPSHOT | > >>> server.getEndpoint().getEndpointInfo().getAddress(): /hello > >>> > >>> > >>> On Tue, May 23, 2017 at 3:27 AM Dennis Kieselhorst <[email protected]> > >> wrote: > >>> > >>>>> Is there a way to ascertain the full address of a server created with > >>>>> JAXRSServerFactoryBean? For example, if I only set the address to > >>>> "/foo", > >>>>> is there any way to know that the full address is actually " > >>>>> http://10.1.1.1/cxf/foo"? > >>>> > >>>> You can get the Address from EndpointInfo or use the > >> publishedEndpointUrl > >>>> property. > >>>> > >>>> Regards > >>>> Dennis > >>>> > >>> > >> > > >
