cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r782603 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/ main/java/org/apache/cxf/jaxrs/provider/ main/java/org/apache/cxf/jaxrs/utils/ main/java/org/apache/cxf/jaxrs/utils/schemas/ test/java/org/apache/cxf/jaxrs/spring/
Date Mon, 08 Jun 2009 12:17:06 GMT
Author: sergeyb
Date: Mon Jun  8 12:17:06 2009
New Revision: 782603

URL: http://svn.apache.org/viewvc?rev=782603&view=rev
Log:
JAXRS: fixing the way resources like model, templates, schemas are loaded

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSClientFactoryBeanTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/clients.xml
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/resources.xml
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/servers.xml

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java?rev=782603&r1=782602&r2=782603&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
Mon Jun  8 12:17:06 2009
@@ -116,9 +116,11 @@
     }
     
     public void setResourceClass(Class cls) {
-        classResourceInfos.clear();
-        boolean isRoot = AnnotationUtils.getClassAnnotation(cls, Path.class) != null;
-        createResourceInfo(cls, isRoot);
+        if (getCreatedFromModel(cls) == null) {
+            classResourceInfos.clear();
+            boolean isRoot = AnnotationUtils.getClassAnnotation(cls, Path.class) != null;
+            createResourceInfo(cls, isRoot);
+        }
     }
     
     public void setResourceClasses(List<Class> classes) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java?rev=782603&r1=782602&r2=782603&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
Mon Jun  8 12:17:06 2009
@@ -60,6 +60,7 @@
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLFilter;
 
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.jaxrs.ext.MessageContext;
 
@@ -271,8 +272,8 @@
         try {
             InputStream is = null;
             if (loc.startsWith("classpath:")) {
-                String path = loc.substring("classpath:".length() + 1);
-                is = this.getClass().getClassLoader().getResourceAsStream(path);
+                String path = loc.substring("classpath:".length());
+                is = ClassLoaderUtils.getResourceAsStream(path, this.getClass());
             } else {
                 File f = new File(loc);
                 if (f.exists()) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java?rev=782603&r1=782602&r2=782603&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
Mon Jun  8 12:17:06 2009
@@ -295,7 +295,7 @@
             InputStream is = null;
             if (loc.startsWith("classpath:")) {
                 String path = loc.substring("classpath:".length());
-                is = ResourceUtils.class.getResourceAsStream(path);
+                is = ClassLoaderUtils.getResourceAsStream(path, ResourceUtils.class);
             } else {
                 File f = new File(loc);
                 if (f.exists()) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java?rev=782603&r1=782602&r2=782603&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
Mon Jun  8 12:17:06 2009
@@ -35,6 +35,7 @@
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.logging.LogUtils;
 
 public class SchemaHandler {
@@ -65,8 +66,8 @@
             for (String loc : locations) {
                 InputStream is = null;
                 if (loc.startsWith(CLASSPATH_PREFIX)) {
-                    String path = loc.substring(CLASSPATH_PREFIX.length() + 1);
-                    is = SchemaHandler.class.getClassLoader().getResourceAsStream(path);
+                    String path = loc.substring(CLASSPATH_PREFIX.length());
+                    is = ClassLoaderUtils.getResourceAsStream(path, SchemaHandler.class);
                     if (is == null) {
                         LOG.warning("No schema resource " + loc + " is available on classpath");
                         return null;

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSClientFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSClientFactoryBeanTest.java?rev=782603&r1=782602&r2=782603&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSClientFactoryBeanTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSClientFactoryBeanTest.java
Mon Jun  8 12:17:06 2009
@@ -49,6 +49,14 @@
         assertEquals("Get a wrong map size", cfb.getHeaders().size(), 1);
         assertEquals("Get a wrong username", cfb.getUsername(), "username");
         assertEquals("Get a wrong password", cfb.getPassword(), "password");
+        
+        bean = ctx.getBean("ModelClient.proxyFactory");
+        assertNotNull(bean);
+        cfb = (JAXRSClientFactoryBean) bean;
+        assertNotNull(cfb.getHeaders());
+        assertEquals("Get a wrong map size", cfb.getHeaders().size(), 1);
+        assertEquals("Get a wrong username", cfb.getUsername(), "username");
+        assertEquals("Get a wrong password", cfb.getPassword(), "password");
     }
 
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanTest.java?rev=782603&r1=782602&r2=782603&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanTest.java
Mon Jun  8 12:17:06 2009
@@ -17,14 +17,17 @@
  * under the License.
  */
 package org.apache.cxf.jaxrs.spring;
-import junit.framework.Assert;
 
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
 import org.apache.cxf.jaxrs.resources.BookStore;
+import org.apache.cxf.jaxrs.resources.BookStoreNoAnnotations;
 import org.apache.cxf.jaxrs.resources.BookStoreSubresourcesOnly;
+
 import org.junit.After;
+import org.junit.Assert;
 import org.junit.Test;
+
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 
@@ -60,7 +63,8 @@
         sfb = (JAXRSServerFactoryBean)ctx.getBean("moduleServer");
         assertNotNull("The resource classes should not be null", sfb.getResourceClasses());
         assertEquals("Get a wrong ResourceClasses size", 1, sfb.getResourceClasses().size());
-        
+        assertEquals("Get a wrong resource class", BookStoreNoAnnotations.class, 
+                     sfb.getResourceClasses().get(0));
         
     }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/clients.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/clients.xml?rev=782603&r1=782602&r2=782603&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/clients.xml (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/clients.xml Mon
Jun  8 12:17:06 2009
@@ -59,12 +59,16 @@
     </jaxrs:headers>
   </jaxrs:client>
   
-  <!-- current JAXRSClient doesn't support the modelRef 
-  <jaxrs:client id="ModuleClient" 
-    serviceClass="org.apache.cxf.jaxrs.resources.BookStoreNoAnnotations"
+  <jaxrs:client id="ModelClient" 
     modelRef="classpath:/org/apache/cxf/jaxrs/spring/resources.xml"
-    address="http://localhost:8080/simpleWithAddress">    
+    serviceClass="org.apache.cxf.jaxrs.resources.BookStoreNoAnnotations"
+    address="http://localhost:8080/simpleWithAddress"
+    username="username"
+    password="password">
+    <jaxrs:headers>
+       <entry key="Accept" value="text/xml"/>
+    </jaxrs:headers>    
   </jaxrs:client>
-  --> 
+  
    
   </beans>

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/resources.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/resources.xml?rev=782603&r1=782602&r2=782603&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/resources.xml (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/resources.xml Mon
Jun  8 12:17:06 2009
@@ -1,5 +1,5 @@
 <model xmlns="http://cxf.apache.org/jaxrs">
- <resource name="org.apache.cxf.jaxrs.resources.BookStore" path="bookstore">
+ <resource name="org.apache.cxf.jaxrs.resources.BookStoreNoAnnotations" path="bookstore">
     <operation name="getBook" verb="GET" path="/books/{id}">
        <param name="id" type="PATH"/>
     </operation>

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/servers.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/servers.xml?rev=782603&r1=782602&r2=782603&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/servers.xml (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/servers.xml Mon
Jun  8 12:17:06 2009
@@ -67,10 +67,6 @@
   <jaxrs:server id="moduleServer"
     modelRef="classpath:/org/apache/cxf/jaxrs/spring/resources.xml"
     address="http://localhost:8080/simpleWithAddress"
-    bus="cxf" >
-    <jaxrs:serviceBeans>
-       <bean class="org.apache.cxf.jaxrs.resources.BookStoreNoAnnotations"/>
-    </jaxrs:serviceBeans>        
-  </jaxrs:server>
+    bus="cxf"/>
   
 </beans>



Mime
View raw message