cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r790096 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ systests/src/test/resources/jaxrs/WEB-INF/
Date Wed, 01 Jul 2009 10:01:12 GMT
Author: sergeyb
Date: Wed Jul  1 10:01:12 2009
New Revision: 790096

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

........
  r790094 | sergeyb | 2009-07-01 10:55:21 +0100 (Wed, 01 Jul 2009) | 1 line
  
  JAX-RS : fixing issue with jaxrs:schemaLocations being ignored
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
    cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs/WEB-INF/beans.xml

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul  1 10:01:12 2009
@@ -1 +1 @@
-/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305,787323,787366,787849,788030,788060,788187,788444,788451,788703,788752,788774,788819-788820,789013,789371,789387,789420,789527-789530,789704-789705,789788,789811,789896-789901,790074
+/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305,787323,787366,787849,788030,788060,788187,788444,788451,788703,788752,788774,788819-788820,789013,789371,789387,789420,789527-789530,789704-789705,789788,789811,789896-789901,790074,790094

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

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=790096&r1=790095&r2=790096&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
Wed Jul  1 10:01:12 2009
@@ -549,15 +549,30 @@
     }
     
     public void setSchemaLocations(List<String> schemas) {
+        boolean schemasMethodAvailable = false;
         for (ProviderInfo<MessageBodyReader> r : messageReaders) {
             try {
                 Method m = r.getProvider().getClass().getMethod("setSchemas", 
                                                      new Class[]{List.class});
+                schemasMethodAvailable = true;
                 m.invoke(r.getProvider(), new Object[]{schemas});
             } catch (Exception ex) {
                 // ignore
             }
         }
+        if (!schemasMethodAvailable) {
+            for (ProviderInfo<MessageBodyReader> r : SHARED_FACTORY.messageReaders)
{
+                try {
+                    Method m = r.getProvider().getClass().getMethod("setSchemas", 
+                                                         new Class[]{List.class});
+                    Object provider = r.getProvider().getClass().newInstance();
+                    m.invoke(provider, new Object[]{schemas});
+                    registerUserProvider(provider);
+                } catch (Exception ex) {
+                    // ignore
+                }
+            }
+        }
     }
     
     private static class ExceptionMapperComparator implements 

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java?rev=790096&r1=790095&r2=790096&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
Wed Jul  1 10:01:12 2009
@@ -54,6 +54,7 @@
 import org.apache.cxf.jaxrs.ext.ParameterHandler;
 import org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper;
 import org.apache.cxf.jaxrs.model.ProviderInfo;
+import org.apache.cxf.jaxrs.resources.Book;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
@@ -81,6 +82,32 @@
     }
     
     @Test
+    public void testSchemaLocations() {
+        ProviderFactory pf = ProviderFactory.getInstance();
+        pf.setSchemaLocations(Collections.singletonList("classpath:/test.xsd"));
+        MessageBodyReader customJaxbReader = pf.createMessageBodyReader((Class<?>)Book.class,
null, null, 
+                                                              MediaType.TEXT_XML_TYPE, new
MessageImpl());
+        assertTrue(customJaxbReader instanceof JAXBElementProvider);
+        MessageBodyReader jaxbReader = ProviderFactory.getSharedInstance().createMessageBodyReader(
+            (Class<?>)Book.class, null, null, MediaType.TEXT_XML_TYPE, new MessageImpl());
+        assertTrue(jaxbReader instanceof JAXBElementProvider);
+        assertNotSame(jaxbReader, customJaxbReader);
+        
+        assertNull(((JAXBElementProvider)jaxbReader).getSchema());
+        assertNotNull(((JAXBElementProvider)customJaxbReader).getSchema());
+        
+        MessageBodyReader customJsonReader = pf.createMessageBodyReader((Class<?>)Book.class,
null, null, 
+                                                 MediaType.APPLICATION_JSON_TYPE, new MessageImpl());
+        assertTrue(customJsonReader instanceof JSONProvider);
+        MessageBodyReader jsonReader = ProviderFactory.getSharedInstance().createMessageBodyReader(
+            (Class<?>)Book.class, null, null, MediaType.APPLICATION_JSON_TYPE, new
MessageImpl());
+        assertTrue(jsonReader instanceof JSONProvider);
+        assertNotSame(jsonReader, customJsonReader);
+        assertNull(((JSONProvider)jsonReader).getSchema());
+        assertNotNull(((JSONProvider)customJsonReader).getSchema());
+    }
+    
+    @Test
     public void testGetFactoryInboundMessage() {
         ProviderFactory factory = ProviderFactory.getInstance();
         Message m = new MessageImpl();

Modified: cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs/WEB-INF/beans.xml?rev=790096&r1=790095&r2=790096&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs/WEB-INF/beans.xml (original)
+++ cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs/WEB-INF/beans.xml Wed Jul 
1 10:01:12 2009
@@ -28,13 +28,16 @@
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:util="http://www.springframework.org/schema/util"
   xmlns:jaxrs="http://cxf.apache.org/jaxrs"
+  xmlns:cxf="http://cxf.apache.org/core"
   xsi:schemaLocation="
 http://www.springframework.org/schema/beans 
 http://www.springframework.org/schema/beans/spring-beans.xsd
 http://www.springframework.org/schema/util 
 http://www.springframework.org/schema/util/spring-util-2.0.xsd
 http://cxf.apache.org/jaxrs
-http://cxf.apache.org/schemas/jaxrs.xsd">
+http://cxf.apache.org/schemas/jaxrs.xsd
+http://cxf.apache.org/core
+http://cxf.apache.org/schemas/core.xsd">
 
   <import resource="classpath:META-INF/cxf/cxf.xml" />
   <import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
@@ -51,7 +54,6 @@
        <ref bean="jaxbProvider"/>
        <ref bean="jsonProvider"/>
     </jaxrs:providers>
-    
   </jaxrs:server>
 
   <jaxrs:server id="bookservice2"
@@ -75,7 +77,9 @@
        <ref bean="jaxbProvider"/>
        <ref bean="jsonProvider"/>
     </jaxrs:providers> 
-    
+    <jaxrs:features>
+       <cxf:logging/>
+    </jaxrs:features>    
   </jaxrs:server>
   
   <jaxrs:server id="bookservice4"



Mime
View raw message