cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r703524 - in /cxf/branches/2.1.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/resources/schemas/ rt/frontend/jaxrs/src/test/java/or...
Date Fri, 10 Oct 2008 17:07:18 GMT
Author: dkulp
Date: Fri Oct 10 10:07:18 2008
New Revision: 703524

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

........
  r703513 | sergeyb | 2008-10-10 12:16:03 -0400 (Fri, 10 Oct 2008) | 1 line
  
  Initial support for schema validation and xsi:schemaLocation
........

Added:
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
      - copied unchanged from r703513, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/resources/
      - copied from r703513, cxf/trunk/rt/frontend/jaxrs/src/test/resources/
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/resources/test.xsd
      - copied unchanged from r703513, cxf/trunk/rt/frontend/jaxrs/src/test/resources/test.xsd
Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingReaderProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/StringProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Oct 10 10:07:18 2008
@@ -1 +1 @@
-/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501
+/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513

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

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java?rev=703524&r1=703523&r2=703524&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
Fri Oct 10 10:07:18 2008
@@ -67,6 +67,7 @@
     private List<?> entityProviders;
     private Map<Object, Object> languageMappings;
     private Map<Object, Object> extensionMappings;
+    private List<String> schemaLocations;
 
     public JAXRSServerFactoryBean() {
         this(new JAXRSServiceFactoryBean());
@@ -78,6 +79,10 @@
         setBindingId(JAXRSBindingFactory.JAXRS_BINDING_ID);
     }
     
+    public void setSchemaLocations(List<String> schemas) {
+        this.schemaLocations = schemas;    
+    }
+    
     public Server create() {
         try {
             Endpoint ep = createEndpoint();
@@ -96,7 +101,9 @@
             }
             ProviderFactory.getInstance().setRequestPreporcessor(
                 new RequestPreprocessor(languageMappings, extensionMappings));
-            
+            if (schemaLocations != null) {
+                ProviderFactory.getInstance().setSchemaLocations(schemaLocations);
+            }
             
             if (start) {
                 server.start();

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=703524&r1=703523&r2=703524&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
Fri Oct 10 10:07:18 2008
@@ -19,8 +19,16 @@
 
 package org.apache.cxf.jaxrs.provider;
 
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 import java.util.WeakHashMap;
 import java.util.logging.Logger;
@@ -30,13 +38,19 @@
 import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.MessageBodyReader;
 import javax.ws.rs.ext.MessageBodyWriter;
+import javax.xml.XMLConstants;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PackageUtils;
@@ -49,11 +63,13 @@
     private static final Logger LOG = LogUtils.getL7dLogger(AbstractJAXBProvider.class);
 
     private static final String CHARSET_PARAMETER = "charset"; 
-
+    private static final String CLASSPATH_PREFIX = "classpath:";
+        
     private static Map<String, JAXBContext> packageContexts = new WeakHashMap<String,
JAXBContext>();
     private static Map<Class<?>, JAXBContext> classContexts = new WeakHashMap<Class<?>,
JAXBContext>();
     
     @Context protected ContextResolver<JAXBContext> resolver;
+    private Schema schema;
     
     public boolean isWriteable(Class<?> type, Type genericType, Annotation[] anns)
{
         return isSupported(type, genericType, anns)
@@ -64,6 +80,10 @@
         return isSupported(type, genericType, annotations);
     }
 
+    public void setSchemas(List<String> locations) {
+        schema = createSchema(locations);    
+    }
+    
     public long getSize(Object o) {
         return -1;
     }
@@ -97,7 +117,7 @@
         synchronized (classContexts) {
             JAXBContext context = classContexts.get(type);
             if (context == null) {
-                context = JAXBContext.newInstance(type);
+                context = JAXBContext.newInstance(new Class[]{type});
                 classContexts.put(type, context);
             }
             return context;
@@ -148,6 +168,17 @@
         return objectFactoryForClass(InjectionUtils.getActualType(genericType));
     }
     
+    @SuppressWarnings("deprecation")
+    protected Unmarshaller createUnmarshaller(Class<?> cls, Type genericType) 
+        throws JAXBException {
+        JAXBContext context = getJAXBContext(cls, genericType);
+        Unmarshaller unmarshaller = context.createUnmarshaller();
+        if (schema != null) {
+            unmarshaller.setSchema(schema);
+        }
+        return unmarshaller;        
+    }
+    
     protected Marshaller createMarshaller(Object obj, Class<?> cls, Type genericType,
MediaType m)
         throws JAXBException {
         
@@ -187,4 +218,44 @@
         }
         return obj;
     }
+    
+    private Schema createSchema(List<String> locations) {
+        
+        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+        Schema s = null;
+        try {
+            List<Source> sources = new ArrayList<Source>();
+            for (String loc : locations) {
+                InputStream is = null;
+                if (loc.startsWith(CLASSPATH_PREFIX)) {
+                    String path = loc.substring(CLASSPATH_PREFIX.length() + 1);
+                    is = getClass().getClassLoader().getResourceAsStream(path);
+                    if (is == null) {
+                        LOG.warning("No schema resource " + loc + " is available on classpath");
+                        return null;
+                    }
+                } else {
+                    File f = new File(loc);
+                    if (!f.exists()) {
+                        LOG.warning("No schema resource " + loc + " is available on local
disk");
+                        return null;
+                    }
+                    is = new FileInputStream(f);
+                }
+                                
+                Reader r = new BufferedReader(
+                               new InputStreamReader(is, "UTF-8"));
+                sources.add(new StreamSource(r));
+            }
+            s = factory.newSchema(sources.toArray(new Source[]{}));
+        } catch (Exception ex) {
+            LOG.warning("Validation will be disabled, failed to create schema : " + ex.getMessage());
+        }
+        return s;
+        
+    }
+    
+    protected Schema getSchema() {
+        return schema;
+    }
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingReaderProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingReaderProvider.java?rev=703524&r1=703523&r2=703524&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingReaderProvider.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingReaderProvider.java
Fri Oct 10 10:07:18 2008
@@ -29,6 +29,7 @@
 import java.util.List;
 
 import javax.ws.rs.ConsumeMime;
+import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.MessageBodyReader;
@@ -62,10 +63,8 @@
 
             return params;
         } catch (Exception e) {
-            e.printStackTrace();
+            throw new WebApplicationException(e);
         }
-
-        return null;
     }
 
     public static void copy(final InputStream input, final OutputStream output, final int
bufferSize)

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=703524&r1=703523&r2=703524&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
Fri Oct 10 10:07:18 2008
@@ -25,11 +25,12 @@
 import java.io.OutputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
+import java.util.List;
 
+import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.Provider;
-import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
@@ -39,15 +40,23 @@
 @Provider
 public final class JAXBElementProvider extends AbstractJAXBProvider  {
     
+    private String jaxbSchemaLocation;
+    
+    public void setSchemas(List<String> locations) {
+        super.setSchemas(locations);
+    }
+    
+    public void setSchemaLocation(String schemaLocation) {
+        jaxbSchemaLocation = schemaLocation;
+    }
     
     public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations,
MediaType m, 
         MultivaluedMap<String, String> headers, InputStream is) 
         throws IOException {
         try {
             Class<?> theType = getActualType(type, genericType);
-            JAXBContext context = getJAXBContext(theType, genericType);
+            Unmarshaller unmarshaller = createUnmarshaller(theType, genericType);
             
-            Unmarshaller unmarshaller = context.createUnmarshaller();
             if (JAXBElement.class.isAssignableFrom(type)) {
                 return unmarshaller.unmarshal(new StreamSource(is), theType);
             } else {
@@ -55,10 +64,8 @@
             }
             
         } catch (JAXBException e) {
-            e.printStackTrace();         
+            throw new WebApplicationException(e);        
         }
-
-        return null;
     }
 
     
@@ -72,11 +79,13 @@
                 genericType = actualClass;
             }
             Marshaller ms = createMarshaller(actualObject, actualClass, genericType, m);
+            if (jaxbSchemaLocation != null) {
+                ms.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, jaxbSchemaLocation);
+            }
             ms.marshal(actualObject, os);
             
         } catch (JAXBException e) {
-            //TODO: better exception handling
-            e.printStackTrace();
+            throw new WebApplicationException(e);
         }
     }
 

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java?rev=703524&r1=703523&r2=703524&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
Fri Oct 10 10:07:18 2008
@@ -26,10 +26,12 @@
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.ws.rs.ConsumeMime;
 import javax.ws.rs.ProduceMime;
+import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.Provider;
@@ -53,6 +55,10 @@
     
     private Map<String, String> namespaceMap = new HashMap<String, String>();
     
+    public void setSchemas(List<String> locations) {
+        super.setSchemas(locations);
+    }
+    
     public void setNamespaceMap(Map<String, String> namespaceMap) {
         this.namespaceMap = namespaceMap;
     }
@@ -77,12 +83,10 @@
             return response;
             
         } catch (JAXBException e) {
-            e.printStackTrace();         
+            throw new WebApplicationException(e);         
         } catch (XMLStreamException e) {
-            e.printStackTrace();
+            throw new WebApplicationException(e);
         } 
-
-        return null;
     }
 
     public void writeTo(Object obj, Class<?> cls, Type genericType, Annotation[] anns,
 
@@ -103,9 +107,9 @@
             xsw.close();
             
         } catch (JAXBException e) {
-            e.printStackTrace();
+            throw new WebApplicationException(e);
         } catch (XMLStreamException e) {
-            e.printStackTrace();
+            throw new WebApplicationException(e);
         }
     }
 

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=703524&r1=703523&r2=703524&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
Fri Oct 10 10:07:18 2008
@@ -20,6 +20,7 @@
 package org.apache.cxf.jaxrs.provider;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
@@ -529,4 +530,22 @@
         requestHandlers.clear();
         responseHandlers.clear();
     }
+    
+    public void setSchemaLocations(List<String> schemas) {
+        setSchemasOnProviders(userMessageReaders, schemas);
+        setSchemasOnProviders(defaultMessageReaders, schemas);
+    }
+    
+    private void setSchemasOnProviders(List<ProviderInfo<MessageBodyReader>>
providers,
+                                       List<String> schemas) {
+        for (ProviderInfo<MessageBodyReader> r : providers) {
+            try {
+                Method m = r.getProvider().getClass().getMethod("setSchemas", 
+                                                     new Class[]{List.class});
+                m.invoke(r.getProvider(), new Object[]{schemas});
+            } catch (Exception ex) {
+                // ignore
+            }
+        }
+    }
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java?rev=703524&r1=703523&r2=703524&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
Fri Oct 10 10:07:18 2008
@@ -25,6 +25,7 @@
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 
+import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.MessageBodyReader;
@@ -89,6 +90,7 @@
             t.transform(source, result);
         } catch (TransformerException te) {
             te.printStackTrace();
+            throw new WebApplicationException(te);
         }
     }
     

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/StringProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/StringProvider.java?rev=703524&r1=703523&r2=703524&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/StringProvider.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/StringProvider.java
Fri Oct 10 10:07:18 2008
@@ -53,21 +53,12 @@
     public String readFrom(Class<String> clazz, Type genericType, Annotation[] annotations,
MediaType m, 
         MultivaluedMap<String, String> headers, InputStream is) 
         throws IOException  {
-        try {
-            return IOUtils.toString(is);
-        } catch (IOException e) {
-            // TODO: better exception handling
-        }
-        return null;
+        return IOUtils.toString(is);
     }
 
     public void writeTo(String obj, Class<?> clazz, Type genericType, Annotation[]
annotations,  
         MediaType m, MultivaluedMap<String, Object> headers, OutputStream os) throws
IOException {
-        try {
-            os.write(obj.getBytes());
-        } catch (IOException e) {
-            //TODO: better exception handling
-        }
+        os.write(obj.getBytes());
     }
 
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd?rev=703524&r1=703523&r2=703524&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd Fri Oct
10 10:07:18 2008
@@ -48,6 +48,7 @@
             <xsd:element name="providers" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="extensionMappings" type="xsd:anyType" minOccurs="0"/>
             <xsd:element name="languageMappings" type="xsd:anyType" minOccurs="0"/>
+            <xsd:element name="schemaLocations" type="schemasType" minOccurs="0"/>
           </xsd:all>
           <xsd:attributeGroup ref="cxf-beans:beanAttributes"/>
           <xsd:attribute name="address" type="xsd:string" />

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java?rev=703524&r1=703523&r2=703524&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
Fri Oct 10 10:07:18 2008
@@ -25,6 +25,7 @@
 import java.io.OutputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
@@ -37,6 +38,7 @@
 import javax.ws.rs.ext.MessageBodyWriter;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.validation.Schema;
 
 import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.Feed;
@@ -278,4 +280,17 @@
 
     }
     
+    @Test
+    public void testSetSchemasFromClasspath() {
+        JAXBElementProvider provider = new JAXBElementProvider();
+        ProviderFactory pf = ProviderFactory.getInstance();
+        pf.registerUserProvider(provider);
+        
+        List<String> locations = new ArrayList<String>();
+        locations.add("classpath:/test.xsd");
+        pf.setSchemaLocations(locations);
+        Schema s = provider.getSchema();
+        assertNotNull("schema can not be read from classpath", s);
+    }
+    
 }



Mime
View raw message