cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r790194 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ rt/frontend/jaxrs/sr...
Date Wed, 01 Jul 2009 14:43:01 GMT
Author: sergeyb
Date: Wed Jul  1 14:43:00 2009
New Revision: 790194

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

........
  r790188 | sergeyb | 2009-07-01 15:37:32 +0100 (Wed, 01 Jul 2009) | 1 line
  
  JAXRS : support for ResourceManager lookups
........

Added:
    cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs/WEB-INF/model/
      - copied from r790188, cxf/trunk/systests/src/test/resources/jaxrs/WEB-INF/model/
    cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs/WEB-INF/model/resources.xml
      - copied unchanged from r790188, cxf/trunk/systests/src/test/resources/jaxrs/WEB-INF/model/resources.xml
    cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs/WEB-INF/schemas/
      - copied from r790188, cxf/trunk/systests/src/test/resources/jaxrs/WEB-INF/schemas/
    cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs/WEB-INF/schemas/bookid.xsd
      - copied unchanged from r790188, cxf/trunk/systests/src/test/resources/jaxrs/WEB-INF/schemas/bookid.xsd
    cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs/WEB-INF/templates/
      - copied from r790188, cxf/trunk/systests/src/test/resources/jaxrs/WEB-INF/templates/
    cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs/WEB-INF/templates/template.xsl
      - copied unchanged from r790188, cxf/trunk/systests/src/test/resources/jaxrs/WEB-INF/templates/template.xsl
Removed:
    cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/bookid.xsd
    cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/template.xsl
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/AbstractJAXRSFactoryBean.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractConfigurableProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
    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/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.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 14:43:00 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,790094,790134
+/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,790134,790188

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/AbstractJAXRSFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java?rev=790194&r1=790193&r2=790194&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
Wed Jul  1 14:43:00 2009
@@ -232,6 +232,7 @@
         if (entityProviders != null) {
             factory.setUserProviders(entityProviders); 
         }
+        factory.setBus(getBus());
         if (schemaLocations != null) {
             factory.setSchemaLocations(schemaLocations);
         }
@@ -252,14 +253,14 @@
     }
     
     public void setModelRef(String modelRef) {
-        List<UserResource> resources = ResourceUtils.getUserResources(modelRef);
+        List<UserResource> resources = ResourceUtils.getUserResources(modelRef, getBus());
         if (resources != null) {
             serviceFactory.setUserResources(resources);
         }
     }
     
     public void setModelRefWithServiceClass(String modelRef, Class<?> sClass) {
-        List<UserResource> resources = ResourceUtils.getUserResources(modelRef);
+        List<UserResource> resources = ResourceUtils.getUserResources(modelRef, getBus());
         if (resources != null) {
             serviceFactory.setUserResourcesWithServiceClass(resources, sClass);
         }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractConfigurableProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractConfigurableProvider.java?rev=790194&r1=790193&r2=790194&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractConfigurableProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractConfigurableProvider.java
Wed Jul  1 14:43:00 2009
@@ -21,11 +21,25 @@
 
 import java.util.List;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+
 public abstract class AbstractConfigurableProvider {
 
     private List<String> consumeMediaTypes;
     private List<String> produceMediaTypes;
     private boolean enableBuffering;
+    private Bus bus;
+    
+    public void setBus(Bus b) {
+        if (bus != null) {
+            bus = b;
+        }
+    }
+    
+    public Bus getBus() {
+        return bus != null ? bus : BusFactory.getThreadDefaultBus();
+    }
     
     public void setConsumeMediaTypes(List<String> types) {
         consumeMediaTypes = types;

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=790194&r1=790193&r2=790194&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
Wed Jul  1 14:43:00 2009
@@ -81,7 +81,7 @@
     }
 
     public void setSchemaLocations(List<String> locations) {
-        schema = SchemaHandler.createSchema(locations);    
+        schema = SchemaHandler.createSchema(locations, getBus());    
     }
     
     public void setSchema(Schema s) {

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=790194&r1=790193&r2=790194&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 14:43:00 2009
@@ -36,6 +36,7 @@
 import javax.ws.rs.ext.MessageBodyReader;
 import javax.ws.rs.ext.MessageBodyWriter;
 
+import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.jaxrs.client.ResponseExceptionMapper;
@@ -548,17 +549,32 @@
         responseExceptionMappers.clear();
     }
     
+    public void setBus(Bus bus) {
+        if (bus == null) {
+            return;
+        }
+        for (ProviderInfo<MessageBodyReader> r : messageReaders) {
+            injectProviderProperty(r.getProvider(), "setBus", Bus.class, bus);
+        }
+    }
+    
+    private boolean injectProviderProperty(Object provider, String mName, Class<?>
pClass, 
+                                        Object pValue) {
+        try {
+            Method m = provider.getClass().getMethod(mName, new Class[]{pClass});
+            m.invoke(provider, new Object[]{pValue});
+            return true;
+        } catch (Exception ex) {
+            // ignore
+        }
+        return false;
+    }
+    
     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
-            }
+            schemasMethodAvailable = injectProviderProperty(r.getProvider(), "setSchemas",

+                                                            List.class, schemas);
         }
         if (!schemasMethodAvailable) {
             for (ProviderInfo<MessageBodyReader> r : SHARED_FACTORY.messageReaders)
{

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java?rev=790194&r1=790193&r2=790194&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XSLTJaxbProvider.java
Wed Jul  1 14:43:00 2009
@@ -60,9 +60,9 @@
 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;
+import org.apache.cxf.jaxrs.utils.ResourceUtils;
 
 @Produces({"application/xml", "application/*+xml", "text/xml", "text/html" })
 @Consumes({"application/xml", "application/*+xml", "text/xml", "text/html" })
@@ -273,7 +273,7 @@
             InputStream is = null;
             if (loc.startsWith("classpath:")) {
                 String path = loc.substring("classpath:".length());
-                is = ClassLoaderUtils.getResourceAsStream(path, this.getClass());
+                is = ResourceUtils.getClasspathResourceStream(path, this.getClass(), this.getBus());
             } else {
                 File f = new File(loc);
                 if (f.exists()) {

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java?rev=790194&r1=790193&r2=790194&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
Wed Jul  1 14:43:00 2009
@@ -48,6 +48,8 @@
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
@@ -62,6 +64,7 @@
 import org.apache.cxf.jaxrs.model.URITemplate;
 import org.apache.cxf.jaxrs.model.UserOperation;
 import org.apache.cxf.jaxrs.model.UserResource;
+import org.apache.cxf.resource.ResourceManager;
 
 public final class ResourceUtils {
     
@@ -332,12 +335,13 @@
         }
     }
     
-    public static List<UserResource> getUserResources(String loc) {
+    
+    public static List<UserResource> getUserResources(String loc, Bus bus) {
         try {
             InputStream is = null;
             if (loc.startsWith("classpath:")) {
                 String path = loc.substring("classpath:".length());
-                is = ClassLoaderUtils.getResourceAsStream(path, ResourceUtils.class);
+                is = getClasspathResourceStream(path, ResourceUtils.class, bus);
             } else {
                 File f = new File(loc);
                 if (f.exists()) {
@@ -356,6 +360,21 @@
         return null;
     }
     
+    public static InputStream getClasspathResourceStream(String path, Class<?> callingClass,
Bus bus) {
+        InputStream is = ClassLoaderUtils.getResourceAsStream(path, callingClass);
+        if (is == null && bus != null) {
+            ResourceManager rm = bus.getExtension(ResourceManager.class);
+            if (rm != null) {
+                is = rm.getResourceAsStream(path);
+            }
+        }
+        return is;
+    }
+    
+    public static List<UserResource> getUserResources(String loc) {
+        return getUserResources(loc, BusFactory.getThreadDefaultBus());
+    }
+    
     public static List<UserResource> getUserResources(InputStream is) throws Exception
{
         Document doc = DOMUtils.readXml(new InputStreamReader(is, "UTF-8"));
         return getResourcesFromElement(doc.getDocumentElement());

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java?rev=790194&r1=790193&r2=790194&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/schemas/SchemaHandler.java
Wed Jul  1 14:43:00 2009
@@ -35,8 +35,10 @@
 import javax.xml.validation.Schema;
 import javax.xml.validation.SchemaFactory;
 
-import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.jaxrs.utils.ResourceUtils;
 
 public class SchemaHandler {
 
@@ -44,20 +46,25 @@
     private static final String CLASSPATH_PREFIX = "classpath:";
     
     private Schema schema;
+    private Bus bus;
     
     public SchemaHandler() {
         
     }
     
+    public void setBus(Bus b) {
+        bus = b;
+    }
+    
     public void setSchemas(List<String> locations) {
-        schema = createSchema(locations);
+        schema = createSchema(locations, bus == null ? BusFactory.getThreadDefaultBus() :
bus);
     }
     
     public Schema getSchema() {
         return schema;
     }
     
-    public static Schema createSchema(List<String> locations) {
+    public static Schema createSchema(List<String> locations, Bus bus) {
         
         SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
         Schema s = null;
@@ -67,7 +74,7 @@
                 InputStream is = null;
                 if (loc.startsWith(CLASSPATH_PREFIX)) {
                     String path = loc.substring(CLASSPATH_PREFIX.length());
-                    is = ClassLoaderUtils.getResourceAsStream(path, SchemaHandler.class);
+                    is = ResourceUtils.getClasspathResourceStream(path, SchemaHandler.class,
bus);
                     if (is == null) {
                         LOG.warning("No schema resource " + loc + " is available on classpath");
                         return null;

Modified: cxf/branches/2.2.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.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java?rev=790194&r1=790193&r2=790194&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
Wed Jul  1 14:43:00 2009
@@ -18,8 +18,6 @@
  */
 package org.apache.cxf.jaxrs.model.wadl;
 
-import java.io.File;
-import java.io.FileOutputStream;
 import java.io.StringReader;
 import java.util.ArrayList;
 import java.util.List;
@@ -82,14 +80,14 @@
         assertNotNull(r);
         assertEquals(WadlGenerator.WADL_TYPE.toString(),
                      r.getMetadata().getFirst(HttpHeaders.CONTENT_TYPE));
-        File f = new File("test.xml");
-        f.delete();
-        f.createNewFile();
-        System.out.println(f.getAbsolutePath());
-        FileOutputStream fos = new FileOutputStream(f);
-        fos.write(r.getEntity().toString().getBytes());
-        fos.flush();
-        fos.close();
+//        File f = new File("test.xml");
+//        f.delete();
+//        f.createNewFile();
+//        System.out.println(f.getAbsolutePath());
+//        FileOutputStream fos = new FileOutputStream(f);
+//        fos.write(r.getEntity().toString().getBytes());
+//        fos.flush();
+//        fos.close();
     }
     
     @Test

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=790194&r1=790193&r2=790194&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 14:43:00 2009
@@ -117,7 +117,7 @@
   </jaxrs:server> 
   
   <util:map id="outTemplates">
-      <entry key="application/xhtml+xml" value="classpath:/org/apache/cxf/systest/jaxrs/resources/template.xsl"/>
+      <entry key="application/xhtml+xml" value="classpath:/WEB-INF/templates/template.xsl"/>
       <entry key="application/xml" value="classpath:/org/apache/cxf/systest/jaxrs/resources/template2.xsl"/>
   </util:map>
   
@@ -134,7 +134,7 @@
   <bean id="uriResolver" class="org.apache.cxf.systest.jaxrs.URIResolverImpl"/>   
 
   
   <jaxrs:server id="bookservice6" address="/thebooks6" 
-     modelRef="classpath:/org/apache/cxf/systest/jaxrs/resources/resources.xml"/>
+     modelRef="classpath:/WEB-INF/model/resources.xml"/>
 
   <jaxrs:server id="bookservice7" address="/thebooks7">
     <jaxrs:model>
@@ -161,7 +161,7 @@
   </bean>
   
   <util:list id="theSchemas">
-    <value>classpath:/org/apache/cxf/systest/jaxrs/resources/bookid.xsd</value>
+    <value>classpath:/WEB-INF/schemas/bookid.xsd</value>
     <value>classpath:/org/apache/cxf/systest/jaxrs/resources/book.xsd</value>
   </util:list>
   



Mime
View raw message