cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: Getting Full Address of Server?
Date Tue, 23 May 2017 14:06:55 GMT
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 <sberyozkin@gmail.com>
> 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 <deki@apache.org>
>> 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
>>>>
>>>
>>
> 

Mime
View raw message