cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r808488 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/ rt/frontend/jaxrs/src/main/java/org/apa...
Date Thu, 27 Aug 2009 16:17:50 GMT
Author: sergeyb
Date: Thu Aug 27 16:17:42 2009
New Revision: 808488

URL: http://svn.apache.org/viewvc?rev=808488&view=rev
Log:
JAXRS : improving the no-annotations feature

Added:
    cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources.xml   (with props)
    cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources2.xml   (with
props)
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/model/ClassResourceInfo.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserOperation.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserResource.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources.xml
    cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml
    cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.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=808488&r1=808487&r2=808488&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
Thu Aug 27 16:17:42 2009
@@ -126,6 +126,17 @@
     
     public void setResourceClasses(List<Class> classes) {
         for (Class resourceClass : classes) {
+            
+            ClassResourceInfo cri = getCreatedFromModel(resourceClass);
+            if (cri != null) {
+                if (!InjectionUtils.isConcreteClass(cri.getServiceClass())) {
+                    cri = new ClassResourceInfo(cri);
+                    cri.setResourceClass(resourceClass);
+                    classResourceInfos.add(cri);
+                }
+                continue;
+            }
+            
             createResourceInfo(resourceClass, true);
         }
     }
@@ -134,7 +145,7 @@
         Map<String, UserResource> map = userResourcesAsMap(resources);
         for (UserResource ur : resources) {
             if (ur.getPath() != null) {
-                ClassResourceInfo cri = ResourceUtils.createClassResourceInfo(map, ur, true);
+                ClassResourceInfo cri = ResourceUtils.createClassResourceInfo(map, ur, true,
enableStatic);
                 if (cri != null) {
                     classResourceInfos.add(cri);
                 }
@@ -144,7 +155,8 @@
     
     public void setUserResourcesWithServiceClass(List<UserResource> resources, Class<?>
sClass) {
         Map<String, UserResource> map = userResourcesAsMap(resources);
-        ClassResourceInfo cri = ResourceUtils.createServiceClassResourceInfo(map, sClass,
true);
+        ClassResourceInfo cri = ResourceUtils.createServiceClassResourceInfo(
+            map, map.get(sClass.getName()), sClass, true, enableStatic);
         if (cri != null) {
             classResourceInfos.add(cri);
         }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java?rev=808488&r1=808487&r2=808488&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
Thu Aug 27 16:17:42 2009
@@ -33,10 +33,12 @@
 import javax.ws.rs.Consumes;
 import javax.ws.rs.Path;
 import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
 
 import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
 import org.apache.cxf.jaxrs.utils.AnnotationUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
 
 public class ClassResourceInfo extends AbstractResourceInfo {
@@ -51,6 +53,8 @@
     private List<Method> paramMethods;
     private boolean enableStatic;
     private boolean createdFromModel; 
+    private String consumesTypes;
+    private String producesTypes;
     
     public ClassResourceInfo(Class<?> theResourceClass) {
         this(theResourceClass, false);
@@ -106,6 +110,14 @@
         this.createdFromModel = createdFromModel;
     }
     
+    public ClassResourceInfo(Class<?> theResourceClass, Class<?> c, 
+                             boolean theRoot, boolean enableStatic,  boolean createdFromModel,
+                             String consumesTypes, String producesTypes) {
+        this(theResourceClass, theResourceClass, theRoot, enableStatic, createdFromModel);
+        this.consumesTypes = consumesTypes;
+        this.producesTypes = producesTypes;
+    }
+    
     public ClassResourceInfo findResource(Class<?> typedClass, Class<?> instanceClass)
{
         instanceClass = enableStatic ? typedClass : instanceClass;
         SubresourceKey key = new SubresourceKey(typedClass, instanceClass);
@@ -214,12 +226,20 @@
         resourceProvider = rp;
     }
     
-    public Produces getProduceMime() {
-        return (Produces)AnnotationUtils.getClassAnnotation(getServiceClass(), Produces.class);
+    public List<MediaType> getProduceMime() {
+        if (producesTypes != null) {
+            return JAXRSUtils.parseMediaTypes(producesTypes);
+        }
+        return JAXRSUtils.getProduceTypes(
+             (Produces)AnnotationUtils.getClassAnnotation(getServiceClass(), Produces.class));
     }
     
-    public Consumes getConsumeMime() {
-        return (Consumes)AnnotationUtils.getClassAnnotation(getServiceClass(), Consumes.class);
+    public List<MediaType> getConsumeMime() {
+        if (consumesTypes != null) {
+            return JAXRSUtils.parseMediaTypes(consumesTypes);
+        }
+        return JAXRSUtils.getConsumeTypes(
+             (Consumes)AnnotationUtils.getClassAnnotation(getServiceClass(), Consumes.class));
     }
     
     public Path getPath() {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java?rev=808488&r1=808487&r2=808488&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
Thu Aug 27 16:17:42 2009
@@ -68,7 +68,7 @@
             parameters = ResourceUtils.getParameters(mAnnotated);
         }
         classResourceInfo = cri;
-        checkMediaTypes();
+        checkMediaTypes(null, null);
         checkEncoded();
         checkDefaultParameterValue();
     }
@@ -85,8 +85,7 @@
         classResourceInfo = cri;
         uriTemplate = template;
         httpMethod = httpVerb;
-        consumeMimes = JAXRSUtils.sortMediaTypes(consumeMediaTypes);
-        produceMimes = JAXRSUtils.sortMediaTypes(produceMediaTypes);
+        checkMediaTypes(consumeMediaTypes, produceMediaTypes);
         parameters = params;
     }
 
@@ -141,23 +140,29 @@
         return consumeMimes;
     }
     
-    private void checkMediaTypes() {
-        Consumes cm = 
-            (Consumes)AnnotationUtils.getMethodAnnotation(annotatedMethod, Consumes.class);
-        if (cm != null) {
-            consumeMimes = JAXRSUtils.sortMediaTypes(JAXRSUtils.getMediaTypes(cm.value()));
-        } else if (classResourceInfo != null) {
-            consumeMimes = JAXRSUtils.sortMediaTypes(
-                               JAXRSUtils.getConsumeTypes(classResourceInfo.getConsumeMime()));
-        }
-        
-        Produces pm = 
-            (Produces)AnnotationUtils.getMethodAnnotation(annotatedMethod, Produces.class);
-        if (pm != null) {
-            produceMimes = JAXRSUtils.sortMediaTypes(JAXRSUtils.getMediaTypes(pm.value()));
-        } else if (classResourceInfo != null) {
-            produceMimes = JAXRSUtils.sortMediaTypes(
-                               JAXRSUtils.getProduceTypes(classResourceInfo.getProduceMime()));
+    private void checkMediaTypes(String consumeMediaTypes,
+                                 String produceMediaTypes) {
+        if (consumeMediaTypes != null) {
+            consumeMimes = JAXRSUtils.sortMediaTypes(consumeMediaTypes);
+        } else {
+            Consumes cm = 
+                (Consumes)AnnotationUtils.getMethodAnnotation(annotatedMethod, Consumes.class);
+            if (cm != null) {
+                consumeMimes = JAXRSUtils.sortMediaTypes(JAXRSUtils.getMediaTypes(cm.value()));
+            } else if (classResourceInfo != null) {
+                consumeMimes = JAXRSUtils.sortMediaTypes(classResourceInfo.getConsumeMime());
+            }
+        }
+        if (produceMediaTypes != null) {
+            produceMimes = JAXRSUtils.sortMediaTypes(produceMediaTypes);
+        } else {
+            Produces pm = 
+                (Produces)AnnotationUtils.getMethodAnnotation(annotatedMethod, Produces.class);
+            if (pm != null) {
+                produceMimes = JAXRSUtils.sortMediaTypes(JAXRSUtils.getMediaTypes(pm.value()));
+            } else if (classResourceInfo != null) {
+                produceMimes = JAXRSUtils.sortMediaTypes(classResourceInfo.getProduceMime());
+            }
         }
     }
     

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserOperation.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserOperation.java?rev=808488&r1=808487&r2=808488&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserOperation.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserOperation.java
Thu Aug 27 16:17:42 2009
@@ -21,8 +21,6 @@
 import java.util.Collections;
 import java.util.List;
 
-import javax.ws.rs.core.MediaType;
-
 import org.apache.cxf.helpers.CastUtils;
 
 public class UserOperation {
@@ -73,11 +71,11 @@
     }
     
     public String getConsumes() {
-        return consumesTypes == null ? MediaType.APPLICATION_XML : consumesTypes;
+        return consumesTypes;
     }
     
     public String getProduces() {
-        return producesTypes == null ? MediaType.APPLICATION_XML : producesTypes;
+        return producesTypes;
     }
     
     public void setConsumes(String types) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserResource.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserResource.java?rev=808488&r1=808487&r2=808488&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserResource.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserResource.java
Thu Aug 27 16:17:42 2009
@@ -29,6 +29,8 @@
 
     private String className; 
     private String pathValue;
+    private String consumesTypes;
+    private String producesTypes;
     private List<UserOperation> opers; 
     
     public UserResource() {
@@ -48,6 +50,26 @@
         this.opers = ops;
     }
     
+    public String getConsumes() {
+        return consumesTypes;
+    }
+    
+    public String getProduces() {
+        return producesTypes;
+    }
+    
+    public void setConsumes(String types) {
+        if (!"".equals(types)) {
+            consumesTypes = types;
+        }
+    }
+    
+    public void setProduces(String types) {
+        if (!"".equals(types)) {
+            producesTypes = types;
+        }
+    }
+    
     public String getName() {
         return className;
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java?rev=808488&r1=808487&r2=808488&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
Thu Aug 27 16:17:42 2009
@@ -36,7 +36,7 @@
 import javax.ws.rs.core.Application;
 import javax.ws.rs.ext.Provider;
 
-import org.apache.commons.lang.ClassUtils;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
 import org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider;
@@ -49,6 +49,7 @@
 
     private static final Logger LOG = LogUtils.getL7dLogger(CXFNonSpringJaxrsServlet.class);
     
+    private static final String USER_MODEL_PARAM = "user.model";
     private static final String SERVICE_ADDRESS_PARAM = "jaxrs.address";
     private static final String SERVICE_CLASSES_PARAM = "jaxrs.serviceClasses";
     private static final String PROVIDERS_PARAM = "jaxrs.providers";
@@ -68,18 +69,24 @@
             return;
         }
         
+        JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
+        
         String address = servletConfig.getInitParameter(SERVICE_ADDRESS_PARAM);
         if (address == null) {
             address = "/";
         }
-        List<Class> resourceClasses = getServiceClasses(servletConfig);
+        bean.setAddress(address);
+        String modelRef = servletConfig.getInitParameter(USER_MODEL_PARAM);
+        if (modelRef != null) {
+            bean.setModelRef(modelRef.trim());
+        }
+        
+        List<Class> resourceClasses = getServiceClasses(servletConfig, modelRef !=
null);
         Map<Class, ResourceProvider> resourceProviders = 
             getResourceProviders(servletConfig, resourceClasses);
         
         List<?> providers = getProviders(servletConfig);
-        
-        JAXRSServerFactoryBean bean = new JAXRSServerFactoryBean();
-        bean.setAddress(address);
+                
         bean.setResourceClasses(resourceClasses);
         bean.setProviders(providers);
         for (Map.Entry<Class, ResourceProvider> entry : resourceProviders.entrySet())
{
@@ -88,9 +95,13 @@
         bean.create();
     }
 
-    protected List<Class> getServiceClasses(ServletConfig servletConfig) throws ServletException
{
+    protected List<Class> getServiceClasses(ServletConfig servletConfig,
+                                            boolean modelAvailable) throws ServletException
{
         String serviceBeans = servletConfig.getInitParameter(SERVICE_CLASSES_PARAM);
         if (serviceBeans == null) {
+            if (modelAvailable) {
+                return Collections.emptyList();
+            }
             throw new ServletException("At least one resource class should be specified");
         }
         String[] classNames = serviceBeans.split(" ");
@@ -229,7 +240,7 @@
     
     private Class<?> loadClass(String cName, String classType) throws ServletException
{
         try {
-            return ClassUtils.getClass(CXFNonSpringJaxrsServlet.class.getClassLoader(), cName.trim());
+            return ClassLoaderUtils.loadClass(cName.trim(), CXFNonSpringJaxrsServlet.class);
         } catch (ClassNotFoundException ex) {
             throw new ServletException("No " + classType + " class " + cName.trim() + " can
be found", ex); 
         }

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=808488&r1=808487&r2=808488&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
Thu Aug 27 16:17:42 2009
@@ -59,7 +59,6 @@
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.MethodDispatcher;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
@@ -82,58 +81,21 @@
     }
     
     public static ClassResourceInfo createClassResourceInfo(
-        Map<String, UserResource> resources, UserResource model, boolean isRoot) {
-        if (model.getName() == null) {
-            return null;
-        }
+        Map<String, UserResource> resources, UserResource model, boolean isRoot, boolean
enableStatic) {
+        
         Class<?> sClass = loadClass(model.getName());
-        ClassResourceInfo cri  = new ClassResourceInfo(sClass, sClass, isRoot, true, true);
-        if (InjectionUtils.isConcreteClass(cri.getServiceClass())) {
-            try {
-                cri.setResourceProvider(new SingletonResourceProvider(sClass.newInstance()));
-            } catch (Exception ex) {
-                throw new RuntimeException("Resource class " + model.getName() + " can not
be created");
-            }
-        }
-        URITemplate t = URITemplate.createTemplate(model.getPath());
-        cri.setURITemplate(t);
-        MethodDispatcher md = new MethodDispatcher();
-        Map<String, UserOperation> ops = model.getOperationsAsMap();
-        for (Method m : cri.getServiceClass().getMethods()) {
-            UserOperation op = ops.get(m.getName());
-            if (op == null || op.getName() == null) {
-                continue;
-            }
-            OperationResourceInfo ori = 
-                new OperationResourceInfo(m, cri, URITemplate.createTemplate(op.getPath()),
-                                          op.getVerb(), op.getConsumes(), op.getProduces(),
-                                          op.getParameters());
-            String rClassName = m.getReturnType().getName();
-            if (op.getVerb() == null) {
-                if (resources.containsKey(rClassName)) {
-                    ClassResourceInfo subCri = rClassName.equals(model.getName()) ? cri 
-                        : createClassResourceInfo(resources, resources.get(rClassName), false);
-                    if (subCri != null) {
-                        cri.addSubClassResourceInfo(subCri);
-                        md.bind(ori, m);
-                    }
-                }
-            } else {
-                md.bind(ori, m);
-            }
-        }
-        cri.setMethodDispatcher(md);
-        return checkMethodDispatcher(cri) ? cri : null;
-
+        return createServiceClassResourceInfo(resources, model, sClass, isRoot, enableStatic);
     }
     
     public static ClassResourceInfo createServiceClassResourceInfo(
-        Map<String, UserResource> resources, Class<?> sClass, boolean isRoot)
{
-        UserResource model = resources.get(sClass.getName());
+        Map<String, UserResource> resources, UserResource model, 
+        Class<?> sClass, boolean isRoot, boolean enableStatic) {
         if (model == null) {
             throw new RuntimeException("Resource class " + sClass.getName() + " has no model
info");
         }
-        ClassResourceInfo cri  = new ClassResourceInfo(sClass, sClass, isRoot, true, true);
+        ClassResourceInfo cri = 
+            new ClassResourceInfo(sClass, sClass, isRoot, enableStatic, true,
+                                  model.getConsumes(), model.getProduces());
         URITemplate t = URITemplate.createTemplate(model.getPath());
         cri.setURITemplate(t);
         MethodDispatcher md = new MethodDispatcher();
@@ -151,7 +113,8 @@
             if (op.getVerb() == null) {
                 if (resources.containsKey(rClassName)) {
                     ClassResourceInfo subCri = rClassName.equals(model.getName()) ? cri 
-                        : createServiceClassResourceInfo(resources, m.getReturnType(), false);
+                        : createServiceClassResourceInfo(resources, resources.get(rClassName),
+                                                         m.getReturnType(), false, enableStatic);
                     if (subCri != null) {
                         cri.addSubClassResourceInfo(subCri);
                         md.bind(ori, m);
@@ -450,6 +413,8 @@
         UserResource resource = new UserResource();
         resource.setName(e.getAttribute("name"));
         resource.setPath(e.getAttribute("path"));
+        resource.setConsumes(e.getAttribute("consumes"));
+        resource.setProduces(e.getAttribute("produces"));
         List<Element> operEls = 
             DOMUtils.findAllElementsByTagNameNS(e, 
                  "http://cxf.apache.org/jaxrs", "operation");
@@ -476,7 +441,7 @@
             Element paramEl = paramEls.get(i);
             Parameter p = new Parameter(paramEl.getAttribute("type"), i, paramEl.getAttribute("name"));
             p.setEncoded(Boolean.valueOf(paramEl.getAttribute("encoded")));
-            p.setDefaultValue(paramEl.getAttribute("default"));
+            p.setDefaultValue(paramEl.getAttribute("defaultValue"));
             params.add(p);
         }
         op.setParameters(params);

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd?rev=808488&r1=808487&r2=808488&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd Thu Aug 27 16:17:42 2009
@@ -22,7 +22,8 @@
   xmlns:beans="http://www.springframework.org/schema/beans"
   xmlns:cxf-beans="http://cxf.apache.org/configuration/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  targetNamespace="http://cxf.apache.org/jaxrs" 
+  targetNamespace="http://cxf.apache.org/jaxrs"
+  xmlns:tns="http://cxf.apache.org/jaxrs" 
   elementFormDefault="qualified"
   attributeFormDefault="unqualified"  >
 
@@ -105,6 +106,8 @@
       <xsd:element name="schemaLocation" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
     </xsd:sequence>
   </xsd:complexType>
+
+  <xsd:element name="model" type="tns:model"/>
   
   <xsd:complexType name="model">
     <xsd:sequence>
@@ -117,7 +120,22 @@
                          <xsd:element name="param" minOccurs="0" maxOccurs="unbounded">
                            <xsd:complexType>
                               <xsd:attribute name="name" type="xsd:string"/>
-                              <xsd:attribute name="type" type="xsd:string"/>
+                              <xsd:attribute name="type">
+                                 <xsd:simpleType>
+                                   <xsd:restriction base="xsd:string">
+                                     <xsd:enumeration value="PATH"/>
+                                     <xsd:enumeration value="QUERY"/>
+                                     <xsd:enumeration value="MATRIX"/>
+                                     <xsd:enumeration value="HEADER"/>
+                                     <xsd:enumeration value="COOKIE"/>
+                                     <xsd:enumeration value="FORM"/>
+                                     <xsd:enumeration value="CONTEXT"/>
+                                     <xsd:enumeration value="REQUEST_BODY"/>
+                                   </xsd:restriction>
+                                 </xsd:simpleType>
+                              </xsd:attribute>
+                              <xsd:attribute name="defaultValue" type="xsd:string"/>
+                              <xsd:attribute name="encoded" type="xsd:boolean"/>
                            </xsd:complexType>
                          </xsd:element>
                       </xsd:sequence>
@@ -131,6 +149,8 @@
              </xsd:sequence>
              <xsd:attribute name="name" type="xsd:string"/>
              <xsd:attribute name="path" type="xsd:string"/>
+             <xsd:attribute name="consumes" type="xsd:string"/>
+             <xsd:attribute name="produces" type="xsd:string"/>
          </xsd:complexType>
       </xsd:element>   
     </xsd:sequence>

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java?rev=808488&r1=808487&r2=808488&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
Thu Aug 27 16:17:42 2009
@@ -141,25 +141,25 @@
     @Test
     public void testGetProduce() {
         ClassResourceInfo c = new ClassResourceInfo(TestClass.class);
-        assertEquals("test/bar", c.getProduceMime().value()[0]);
+        assertEquals("test/bar", c.getProduceMime().get(0).toString());
         
         c = new ClassResourceInfo(TestClass1.class);
-        assertEquals("test/bar", c.getProduceMime().value()[0]);
+        assertEquals("test/bar", c.getProduceMime().get(0).toString());
         
         c = new ClassResourceInfo(TestClass2.class);
-        assertEquals("test/bar", c.getProduceMime().value()[0]);
+        assertEquals("test/bar", c.getProduceMime().get(0).toString());
     }
     
     @Test
     public void testGetConsume() {
         ClassResourceInfo c = new ClassResourceInfo(TestClass.class);
-        assertEquals("test/foo", c.getConsumeMime().value()[0]);
+        assertEquals("test/foo", c.getConsumeMime().get(0).toString());
         
         c = new ClassResourceInfo(TestClass1.class);
-        assertEquals("test/foo", c.getConsumeMime().value()[0]);
+        assertEquals("test/foo", c.getConsumeMime().get(0).toString());
         
         c = new ClassResourceInfo(TestClass2.class);
-        assertEquals("test/foo", c.getConsumeMime().value()[0]);
+        assertEquals("test/foo", c.getConsumeMime().get(0).toString());
     }
     
     @Test

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java?rev=808488&r1=808487&r2=808488&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java
Thu Aug 27 16:17:42 2009
@@ -67,7 +67,7 @@
         
         Map<String, UserResource> resources = new HashMap<String, UserResource>();
         resources.put(ur.getName(), ur);
-        ClassResourceInfo cri = ResourceUtils.createClassResourceInfo(resources, ur, true);
+        ClassResourceInfo cri = ResourceUtils.createClassResourceInfo(resources, ur, true,
true);
         assertNotNull(cri);
         assertEquals("/hashmap", cri.getURITemplate().getValue());
         Method method = 

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java?rev=808488&r1=808487&r2=808488&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
(original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
Thu Aug 27 16:17:42 2009
@@ -49,6 +49,30 @@
     }
     
     @Test
+    public void testGetBook123UserModel() throws Exception {
+        getAndCompareAsStrings("http://localhost:9080/usermodel/bookstore/books/123",
+                               "resources/expected_get_book123.txt",
+                               "application/xml", 200);
+        
+    }
+    
+    @Test
+    public void testGetChapterUserModel() throws Exception {
+        
+        getAndCompareAsStrings("http://localhost:9080/usermodel/bookstore/books/123/chapter",
+                               "resources/expected_get_chapter1_utf.txt",
+                               "application/xml", 200);
+    }
+    
+    @Test
+    public void testGetBook123UserModelInterface() throws Exception {
+        getAndCompareAsStrings("http://localhost:9080/usermodel2/bookstore2/books/123",
+                               "resources/expected_get_book123.txt",
+                               "application/xml", 200);
+        
+    }
+    
+    @Test
     public void testGetBook123ApplicationSingleton() throws Exception {
         getAndCompareAsStrings("http://localhost:9080/application/bookstore/books/123",
                                "resources/expected_get_book123.txt",

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources.xml?rev=808488&r1=808487&r2=808488&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources.xml
(original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources.xml
Thu Aug 27 16:17:42 2009
@@ -1,7 +1,8 @@
 <model xmlns="http://cxf.apache.org/jaxrs">
- <resource name="org.apache.cxf.systest.jaxrs.BookStoreNoAnnotations" path="bookstore">
+ <resource name="org.apache.cxf.systest.jaxrs.BookStoreNoAnnotations" 
+    path="bookstore" producesTypes="application/xml" consumesTypes="application/xml">
     <operation name="getBook" verb="GET" path="/books/{id}">
-       <param name="id" type="PATH"/>
+       <param name="id" type="PATH" encoded="false"/>
     </operation>
     <operation name="getBookChapter" path="/books/{id}/chapter">
         <param name="id" type="PATH"/>

Added: cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources.xml?rev=808488&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources.xml (added)
+++ cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources.xml Thu Aug 27
16:17:42 2009
@@ -0,0 +1,14 @@
+<model xmlns="http://cxf.apache.org/jaxrs">
+ <resource name="org.apache.cxf.systest.jaxrs.BookStoreNoAnnotations" 
+    path="bookstore" producesTypes="application/xml" consumesTypes="application/xml">
+    <operation name="getBook" verb="GET" path="/books/{id}">
+       <param name="id" type="PATH" encoded="false"/>
+    </operation>
+    <operation name="getBookChapter" path="/books/{id}/chapter">
+        <param name="id" type="PATH"/>
+    </operation> 
+ </resource>
+ <resource name="org.apache.cxf.systest.jaxrs.ChapterNoAnnotations">
+    <operation name="getItself" verb="GET"/>
+ </resource>
+</model>
\ No newline at end of file

Propchange: cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources2.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources2.xml?rev=808488&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources2.xml (added)
+++ cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources2.xml Thu Aug
27 16:17:42 2009
@@ -0,0 +1,13 @@
+<model xmlns="http://cxf.apache.org/jaxrs">
+ <resource name="org.apache.cxf.systest.jaxrs.BookStoreNoAnnotationsInterface" path="bookstore2">
+    <operation name="getBook" verb="GET" path="/books/{id}">
+       <param name="id" type="PATH"/>
+    </operation>
+    <operation name="getBookChapter" path="/books/{id}/chapter">
+        <param name="id" type="PATH"/>
+    </operation> 
+ </resource>
+ <resource name="org.apache.cxf.systest.jaxrs.ChapterNoAnnotations">
+    <operation name="getItself" verb="GET"/>
+ </resource>
+</model>
\ No newline at end of file

Propchange: cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources2.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources2.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources2.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml?rev=808488&r1=808487&r2=808488&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml (original)
+++ cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml Thu Aug 27 16:17:42
2009
@@ -24,7 +24,6 @@
 -->
 <!-- START SNIPPET: webxml -->
 <web-app>
-	
 	<servlet>
 		<servlet-name>CXFServlet</servlet-name>
 		<display-name>CXF Servlet</display-name>
@@ -52,8 +51,42 @@
 		</init-param>
 		<load-on-startup>1</load-on-startup>
 	</servlet>
-    
 
+    <servlet>
+		<servlet-name>CXFServlet3</servlet-name>
+		<display-name>CXF Servlet3</display-name>
+		<servlet-class>
+			org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet
+		</servlet-class>
+		<init-param>
+		      <param-name>user.model</param-name>
+		      <param-value>
+		           classpath:/WEB-INF/resources.xml
+		      </param-value>    
+		</init-param>
+		<load-on-startup>1</load-on-startup>
+	</servlet>
+
+    <servlet>
+		<servlet-name>CXFServlet4</servlet-name>
+		<display-name>CXF Servlet4</display-name>
+		<servlet-class>
+			org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet
+		</servlet-class>
+		<init-param>
+		      <param-name>user.model</param-name>
+		      <param-value>
+		           classpath:/WEB-INF/resources2.xml
+		      </param-value>    
+		</init-param>
+		<init-param>
+		      <param-name>jaxrs.serviceClasses</param-name>
+		      <param-value>
+		           org.apache.cxf.systest.jaxrs.BookStoreNoAnnotationsImpl
+		      </param-value>    
+		</init-param>
+		<load-on-startup>1</load-on-startup>
+	</servlet>
 	<servlet-mapping>
 		<servlet-name>CXFServlet</servlet-name>
 		<url-pattern>/singleton/*</url-pattern>
@@ -63,5 +96,16 @@
 		<servlet-name>CXFServlet2</servlet-name>
 		<url-pattern>/application/*</url-pattern>
 	</servlet-mapping>
+
+	<servlet-mapping>
+		<servlet-name>CXFServlet3</servlet-name>
+		<url-pattern>/usermodel/*</url-pattern>
+	</servlet-mapping>
+
+	<servlet-mapping>
+		<servlet-name>CXFServlet4</servlet-name>
+		<url-pattern>/usermodel2/*</url-pattern>
+	</servlet-mapping>
+	
 </web-app>
 <!-- END SNIPPET: webxml -->
\ No newline at end of file

Modified: cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml?rev=808488&r1=808487&r2=808488&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml (original)
+++ cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml Thu Aug 27 16:17:42
2009
@@ -48,7 +48,6 @@
     </jaxrs:serviceBeans>
     <jaxrs:providers>
       <ref bean="exceptionMapper"/>
-      <ref bean="exceptionMapper2"/>
     </jaxrs:providers>		   
   </jaxrs:server>
   <bean id="bookstore" class="org.apache.cxf.systest.jaxrs.BookStore"/>
@@ -56,7 +55,6 @@
   <bean id="exceptionMapper" class="org.apache.cxf.systest.jaxrs.BookExceptionMapper">
       <property name="toHandle" value="true"/>
   </bean>   
-  <bean id="exceptionMapper2" class="org.apache.cxf.systest.jaxrs.BookExceptionMapper"/>
 
   <jaxrs:server id="bookservice2" address="/2"
     modelRef="classpath:/org/apache/cxf/systest/jaxrs/resources/resources.xml">
     <jaxrs:serviceBeans>



Mime
View raw message