cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: svn commit: r1539911 - in /cxf/trunk: parent/ rt/frontend/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/swagger/
Date Fri, 08 Nov 2013 07:34:42 GMT

On Nov 8, 2013, at 8:24 AM, Freeman Fang <freeman.fang@gmail.com> wrote:

> Hi Dan,
> 
> Thanks for the reminder.
> 
> And for the
> 
>> Where did the "http://localhost:8181/cxf” value come from?
> 
> It's the default cxf context when use in OSGi container
> Do you mean we should get those default value(8181 and /cxf) from the OSGi configAdmin?


I would leave it as just “/foo” or whatever the endpoint address is.  I’d rather have
a value that is always contextually correct than one that would only be correct in ServiceMix.

Either that or wrapper/subclass the providers they provide with a provider that would grab
the full URI from the CXF message at request time so it’s always correct.  Not sure if swagger
can support that or not.


Dan


> -------------
> Freeman(Yue) Fang
> 
> Red Hat, Inc. 
> FuseSource is now part of Red Hat
> Web: http://fusesource.com | http://www.redhat.com/
> Twitter: freemanfang
> Blog: http://freemanfang.blogspot.com
> http://blog.sina.com.cn/u/1473905042
> weibo: @Freeman小屋
> 
> 
> 
> On 2013-11-8, at 下午2:51, Daniel Kulp wrote:
> 
>> Freeman,
>> 
>> I have some problems with this commit….  inline….
>> 
>> 
>> 
>> On Nov 8, 2013, at 4:30 AM, ffang@apache.org wrote:
>> 
>>> 
>>> 
>>> Modified: cxf/trunk/rt/frontend/jaxrs/pom.xml
>>> URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/pom.xml?rev=1539911&r1=1539910&r2=1539911&view=diff
>>> ==============================================================================
>>> --- cxf/trunk/rt/frontend/jaxrs/pom.xml (original)
>>> +++ cxf/trunk/rt/frontend/jaxrs/pom.xml Fri Nov  8 03:30:41 2013
>>> @@ -36,6 +36,7 @@
>>>            javax.servlet*;version="${cxf.osgi.javax.servlet.version}",
>>>            org.apache.aries*;version="${cxf.aries.version.range}",
>>>            org.springframework*;resolution:="optional";version="${cxf.osgi.spring.version}",
>>> +            com.wordnik.swagger.jaxrs*;resolution:="optional";version="[1.3.0,
1.4.0)",
>>>            javax.ws.rs.client;version="[2.0,3)",
>>>            javax.ws.rs*;version="[1.0,3)",
>>>        </cxf.osgi.import>
>>> @@ -158,6 +159,10 @@
>>>                </exclusion>
>>>            </exclusions>
>>>        </dependency> 
>>> +        <dependency>
>>> +            <groupId>com.wordnik</groupId>
>>> +            <artifactId>swagger-jaxrs_2.10</artifactId>
>>> +        </dependency>
>>>    </dependencies>
>>> 
>> 
>> The dependency should likely be marked optional as well.   
>> 
>> 
>> 
>> 
>>> Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
>>> URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java?rev=1539911&r1=1539910&r2=1539911&view=diff
>>> ==============================================================================
>>> --- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
(original)
>>> +++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
Fri Nov  8 03:30:41 2013
>>> @@ -110,6 +110,7 @@ public class AbstractJAXRSFactoryBean ex
>>>        super.setBus(bus);
>>>        checkBindingFactory(bus);
>>>        serviceFactory.setBus(bus);
>>> +        bus.setProperty(JAXRSServiceFactoryBean.class.getName(), serviceFactory);
>>>    }
>> 
>> I’m -1 to this….    We can have multiple ServiceFactories being initialized at
once on the bus.  This is not thread safe at all.  In particular, if using the API’s to
create many clients at once from various threads, this would cause all kinds of potential
problems.
>> 
>> 
>>>    /*
>>> @@ -204,6 +205,7 @@ public class AbstractJAXRSFactoryBean ex
>>>     */
>>>    public void setServiceFactory(JAXRSServiceFactoryBean serviceFactory) {
>>>        this.serviceFactory = serviceFactory;
>>> +        getBus().setProperty(JAXRSServiceFactoryBean.class.getName(), serviceFactory);
>>>    }
>> 
>> Likewise.
>> 
>> If something is needed in the Feature, make sure it’s saved on the Server object
or, preferably, on the Endpoint.
>> 
>> 
>>>    protected Endpoint createEndpoint() throws BusException, EndpointException
{
>> 
>> Likely in this call someplace or the createEndpointInfo method.   
>> 
>> 
>>> 
>>> Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerFeature.java
>>> URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerFeature.java?rev=1539911&view=auto
>>> ==============================================================================
>>> --- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerFeature.java
(added)
>>> +++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/swagger/SwaggerFeature.java
Fri Nov  8 03:30:41 2013
>>> @@ -0,0 +1,142 @@
>> 
>> 
>> snip…...
>> 
>>> +    
>>> +    private void calulateDefaultBasePath(Server server) {
>>> +        String address = server.getEndpoint().getEndpointInfo().getAddress();
>>> +        if (getBasePath() == null || getBasePath().length() == 0) {
>>> +            if (address.startsWith("http")) {
>>> +                setBasePath(address + "/api-docs");
>>> +            } else {
>>> +                setBasePath("http://localhost:8181/cxf" + address + "/api-docs");
>>> +            }
>>> +        }
>>> +    }
>> 
>> Where did the "http://localhost:8181/cxf” value come from?
>> 
>> 
>> -- 
>> Daniel Kulp
>> dkulp@apache.org - http://dankulp.com/blog
>> Talend Community Coder - http://coders.talend.com
>> 
> 

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message