cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1372386 - in /cxf/branches/2.4.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 Mon, 13 Aug 2012 12:12:05 GMT
Author: sergeyb
Date: Mon Aug 13 12:12:05 2012
New Revision: 1372386

URL: http://svn.apache.org/viewvc?rev=1372386&view=rev
Log:
Merged revisions 1372133 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes

................
  r1372133 | sergeyb | 2012-08-12 18:42:44 +0300 (Sun, 12 Aug 2012) | 16 lines
  
  Merged revisions 1372127 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes
  
  ................
    r1372127 | sergeyb | 2012-08-12 18:20:40 +0300 (Sun, 12 Aug 2012) | 9 lines
    
    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.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
    cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
    cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/branches/2.5.x-fixes:r1372133
  Merged /cxf/trunk:r1372124
  Merged /cxf/branches/2.6.x-fixes:r1372127

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

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java?rev=1372386&r1=1372385&r2=1372386&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
Mon Aug 13 12:12:05 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;
@@ -153,6 +154,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.4.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.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=1372386&r1=1372385&r2=1372386&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
Mon Aug 13 12:12:05 2012
@@ -101,6 +101,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;
@@ -199,7 +200,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);
 
@@ -235,8 +236,14 @@ public class WadlGenerator implements Re
         return Response.ok().type(type).entity(sbMain.toString()).build();
     }
 
-    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,
@@ -785,14 +792,14 @@ public class WadlGenerator implements Re
                                                                                 "grammars");
                         if (grammarEls.size() == 1) {
                             handleSchemaRefs(DOMUtils.getChildrenWithName(grammarEls.get(0),

-                                WadlGenerator.WADL_NS, "include"), "href", loc, "", ui);
+                                WadlGenerator.WADL_NS, "include"), "href", loc, "", m, ui);
                         }
                         
                         List<Element> resourceEls = DOMUtils.getChildrenWithName(appEl,

                                                                                  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();
                         }
                         
@@ -815,9 +822,9 @@ public class WadlGenerator implements Re
                 if (is != null) {
                     Element docEl = DOMUtils.readXml(is).getDocumentElement();
                     handleSchemaRefs(DOMUtils.getChildrenWithName(docEl, 
-                        XmlSchemaConstants.XSD_NAMESPACE_URI, "import"), "schemaLocation",
loc, href, ui);
+                        XmlSchemaConstants.XSD_NAMESPACE_URI, "import"), "schemaLocation",
loc, href, m, ui);
                     handleSchemaRefs(DOMUtils.getChildrenWithName(docEl, 
-                        XmlSchemaConstants.XSD_NAMESPACE_URI, "include"), "schemaLocation",
loc, href, ui);
+                        XmlSchemaConstants.XSD_NAMESPACE_URI, "include"), "schemaLocation",
loc, href, m, ui);
                     return Response.ok().type(MediaType.APPLICATION_XML_TYPE).entity(
                         new DOMSource(docEl)).build();
                 }
@@ -830,7 +837,8 @@ public class WadlGenerator implements Re
     }
 
     private void handleSchemaRefs(List<Element> schemaRefEls, String attrName, 
-                                  String parentDocLoc, String parentRef, UriInfo ui) {
+                                  String parentDocLoc, String parentRef, 
+                                  Message m, UriInfo ui) {
         int index = parentDocLoc.lastIndexOf('/');
         parentDocLoc = index == -1 ? parentDocLoc : parentDocLoc.substring(0, index + 1);
         
@@ -841,7 +849,7 @@ public class WadlGenerator implements Re
             String href = schemaRefEl.getAttribute(attrName);
             String actualRef = parentRef + href;
             schemaLocationMap.put(actualRef, parentDocLoc + href);    
-            DOMUtils.setAttribute(schemaRefEl, attrName, getBaseURI(ui) + "/" + actualRef);
+            DOMUtils.setAttribute(schemaRefEl, attrName, getBaseURI(m, ui) + "/" + actualRef);
         }
     }
 

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd?rev=1372386&r1=1372385&r2=1372386&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/blueprint/jaxrs.xsd
Mon Aug 13 12:12:05 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.4.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd?rev=1372386&r1=1372385&r2=1372386&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd (original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd Mon Aug
13 12:12:05 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.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java?rev=1372386&r1=1372385&r2=1372386&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/RequestPreprocessorTest.java
Mon Aug 13 12:12:05 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.4.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.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java?rev=1372386&r1=1372385&r2=1372386&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
Mon Aug 13 12:12:05 2012
@@ -39,6 +39,7 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 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;
@@ -48,6 +49,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;
@@ -667,15 +669,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.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java?rev=1372386&r1=1372385&r2=1372386&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
(original)
+++ cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
Mon Aug 13 12:12:05 2012
@@ -159,7 +159,21 @@ public class JAXRSClientServerResourceCr
         assertEquals(1, clsFiles.size());
         assertTrue(checkContains(clsFiles, "org.apache.cxf.systest.jaxrs.PetStore.class"));
     }
-    
+    @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 boolean checkContains(List<File> clsFiles, String name) {
         
         for (File f : clsFiles) {

Modified: cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml?rev=1372386&r1=1372385&r2=1372386&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
(original)
+++ cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
Mon Aug 13 12:12:05 2012
@@ -49,4 +49,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