cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1372127 - in /cxf/branches/2.6.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/ rt/frontend/jaxrs/src/main/resources/schemas/ rt/frontend/jaxrs/src/main/reso...
Date Sun, 12 Aug 2012 15:20:40 GMT
Author: sergeyb
Date: Sun Aug 12 15:20:40 2012
New Revision: 1372127

URL: http://svn.apache.org/viewvc?rev=1372127&view=rev
Log:
Merged revisions 1372124 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1372124 | sergeyb | 2012-08-12 18:08:37 +0300 (Sun, 12 Aug 2012) | 1 line
  
  Get WADLGenerator support publishedEndpointUrl property, same was as for JAX-WS
........

Modified:
    cxf/branches/2.6.x-fixes/   (props changed)
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
    cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
    cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1372124

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java?rev=1372127&r1=1372126&r2=1372127&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
Sun Aug 12 15:20:40 2012
@@ -39,6 +39,7 @@ import org.apache.cxf.binding.BindingFac
 import org.apache.cxf.binding.BindingFactoryManager;
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.databinding.DataBinding;
 import org.apache.cxf.databinding.PropertiesAwareDataBinding;
 import org.apache.cxf.endpoint.AbstractEndpointFactory;
@@ -150,6 +151,11 @@ public class AbstractJAXRSFactoryBean ex
 
         BindingInfo bindingInfo = createBindingInfo();
         ei.setBinding(bindingInfo);
+        
+        if (!StringUtils.isEmpty(publishedEndpointUrl)) {
+            ei.setProperty("publishedEndpointUrl", publishedEndpointUrl);
+        }
+        
         serviceFactory.sendEvent(FactoryBeanListener.Event.ENDPOINTINFO_CREATED, ei);
 
         return ei;

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=1372127&r1=1372126&r2=1372127&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
Sun Aug 12 15:20:40 2012
@@ -104,6 +104,7 @@ import org.apache.cxf.jaxrs.utils.Resour
 import org.apache.cxf.jaxrs.utils.schemas.SchemaHandler;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.staxutils.DelegatingXMLStreamWriter;
 import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.ws.commons.schema.XmlSchema;
@@ -210,7 +211,7 @@ public class WadlGenerator implements Re
         sbGrammars.append("<grammars>");
 
         StringBuilder sbResources = new StringBuilder();
-        sbResources.append("<resources base=\"").append(getBaseURI(ui)).append("\">");
+        sbResources.append("<resources base=\"").append(getBaseURI(m, ui)).append("\">");
 
         List<ClassResourceInfo> cris = getResourcesList(m, resource);
 
@@ -268,8 +269,14 @@ public class WadlGenerator implements Re
         }
     }
     
-    private String getBaseURI(UriInfo ui) {
-        return ui.getBaseUri().toString();
+    private String getBaseURI(Message m, UriInfo ui) {
+        EndpointInfo ei = m.getExchange().get(Endpoint.class).getEndpointInfo();
+        String publishedEndpointUrl = (String)ei.getProperty("publishedEndpointUrl");
+        if (publishedEndpointUrl == null) {
+            return ui.getBaseUri().toString();
+        } else {
+            return publishedEndpointUrl;
+        }
     }
     
     private void handleGrammars(StringBuilder sbApp, StringBuilder sbGrammars,
@@ -860,7 +867,7 @@ public class WadlGenerator implements Re
                                                                                  WadlGenerator.WADL_NS,

                                                                                  "resources");
                         if (resourceEls.size() == 1) {
-                            DOMUtils.setAttribute(resourceEls.get(0), "base", getBaseURI(ui));
+                            DOMUtils.setAttribute(resourceEls.get(0), "base", getBaseURI(m,
ui));
                             return Response.ok().type(mt).entity(new DOMSource(appEl)).build();
                         }
                         

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd?rev=1372127&r1=1372126&r2=1372127&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd
Sun Aug 12 15:20:40 2012
@@ -66,6 +66,7 @@
           <xsd:attribute name="beanNames" type="xsd:string"/>
           <xsd:attribute name="serviceName" type="xsd:QName"/>
           <xsd:attribute name="docLocation" type="xsd:string"/>
+          <xsd:attribute name="publishedEndpointUrl" type="xsd:string"/>
         </xsd:extension>
       </xsd:complexContent>
     </xsd:complexType>

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd?rev=1372127&r1=1372126&r2=1372127&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd (original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd Sun Aug
12 15:20:40 2012
@@ -66,6 +66,7 @@
           <xsd:attribute name="beanNames" type="xsd:string"/>
           <xsd:attribute name="serviceName" type="xsd:QName"/>
           <xsd:attribute name="docLocation" type="xsd:string"/>
+          <xsd:attribute name="publishedEndpointUrl" type="xsd:string"/>
         </xsd:extension>
       </xsd:complexContent>
     </xsd:complexType>

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java?rev=1372127&r1=1372126&r2=1372127&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java
Sun Aug 12 15:20:40 2012
@@ -40,6 +40,7 @@ import org.apache.cxf.message.ExchangeIm
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.servlet.ServletDestination;
 import org.easymock.EasyMock;
@@ -129,6 +130,8 @@ public class RequestPreprocessorTest ext
         epr.setAddress(baseAddress);
         d.getEndpointInfo();
         EasyMock.expectLastCall().andReturn(epr).anyTimes();
+        endp.getEndpointInfo();
+        EasyMock.expectLastCall().andReturn(epr).anyTimes();
         m.put(Message.REQUEST_URI, pathInfo);
         m.put(Message.QUERY_STRING, query);
         m.put(Message.HTTP_REQUEST_METHOD, method);
@@ -137,6 +140,11 @@ public class RequestPreprocessorTest ext
             headers.put("X-HTTP-Method-Override", Collections.singletonList(methodHeader));
  
         }
         m.put(Message.PROTOCOL_HEADERS, headers);
+        BindingInfo bi = control.createMock(BindingInfo.class);
+        epr.setBinding(bi);
+        bi.getProperties();
+        EasyMock.expectLastCall().andReturn(Collections.emptyMap()).anyTimes();
+        
         control.replay();
         return m;
     }

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java?rev=1372127&r1=1372126&r2=1372127&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
Sun Aug 12 15:20:40 2012
@@ -40,6 +40,7 @@ import org.w3c.dom.Element;
 
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.common.xmlschema.XmlSchemaConstants;
+import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.jaxrs.JAXRSServiceImpl;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
@@ -49,6 +50,7 @@ import org.apache.cxf.message.ExchangeIm
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.servlet.ServletDestination;
 import org.easymock.EasyMock;
@@ -738,15 +740,22 @@ public class WadlGeneratorTest extends A
         Message m = new MessageImpl();
         Exchange e = new ExchangeImpl();
         e.put(Service.class, new JAXRSServiceImpl(cris));
-        
+        Endpoint endpoint = control.createMock(Endpoint.class);
+        e.put(Endpoint.class, endpoint);
         m.setExchange(e);
         control.reset();
         ServletDestination d = control.createMock(ServletDestination.class);
-        EndpointInfo epr = new EndpointInfo(); 
+        EndpointInfo epr = new EndpointInfo();
         epr.setAddress(baseAddress);
         d.getEndpointInfo();
         EasyMock.expectLastCall().andReturn(epr).anyTimes();
+        endpoint.getEndpointInfo();
+        EasyMock.expectLastCall().andReturn(epr).anyTimes();
         e.setDestination(d);
+        BindingInfo bi = control.createMock(BindingInfo.class);
+        epr.setBinding(bi);
+        bi.getProperties();
+        EasyMock.expectLastCall().andReturn(Collections.emptyMap()).anyTimes();
         m.put(Message.REQUEST_URI, pathInfo);
         m.put(Message.QUERY_STRING, query);
         m.put(Message.HTTP_REQUEST_METHOD, "GET");

Modified: cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java?rev=1372127&r1=1372126&r2=1372127&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
(original)
+++ cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
Sun Aug 12 15:20:40 2012
@@ -105,6 +105,22 @@ public class JAXRSClientServerResourceCr
         checkPetStoreInfo(resourceEls.get(0));
     }
     
+    @Test
+    public void testWadlPublishedEndpointUrl() throws Exception {
+        String requestURI = "http://localhost:" + PORT + "/webapp/resources2";
+        WebClient client = WebClient.create(requestURI + "?_wadl&_type=xml");
+        Document doc = DOMUtils.readXml(new InputStreamReader(client.get(InputStream.class),
"UTF-8"));
+        Element root = doc.getDocumentElement();
+        assertEquals(WadlGenerator.WADL_NS, root.getNamespaceURI());
+        assertEquals("application", root.getLocalName());
+        List<Element> resourcesEls = DOMUtils.getChildrenWithName(root, 
+                                                                  WadlGenerator.WADL_NS,
"resources");
+        assertEquals(1, resourcesEls.size());
+        Element resourcesEl =  resourcesEls.get(0);
+        assertEquals("http://proxy", resourcesEl.getAttribute("base"));
+        
+    }
+    
     
     private void checkBookStoreInfo(Element resource) {
         assertEquals("/bookstore", resource.getAttribute("path"));

Modified: cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml?rev=1372127&r1=1372126&r2=1372127&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
(original)
+++ cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
Sun Aug 12 15:20:40 2012
@@ -48,4 +48,12 @@ http://cxf.apache.org/schemas/jaxrs.xsd"
     <bean id="exceptionMapper2" class="org.apache.cxf.systest.jaxrs.RuntimeExceptionMapper"/>
     <bean id="plainTextProvider" class="org.apache.cxf.systest.jaxrs.StringTextWriter"/>
     
+    <jaxrs:server id="bookservice2"
+                  address="/resources2"
+                  publishedEndpointUrl="http://proxy">
+        <jaxrs:serviceBeans>
+            <ref bean="bookstore"/>
+        </jaxrs:serviceBeans>
+    </jaxrs:server>
+    
 </beans>



Mime
View raw message