cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin" <sbery...@progress.com>
Subject Re: svn commit: r808545 -
Date Thu, 27 Aug 2009 17:23:41 GMT
Dan, thanks a million for merging all the jaxrs-related updates back to 2.2.x...I was planning
to do it, I even updated cxf 2.2.x 
this morning :-)

cheers, Sergey
----- Original Message ----- 
From: <dkulp@apache.org>
To: <commits@cxf.apache.org>
Sent: Thursday, August 27, 2009 6:18 PM
Subject: svn commit: r808545 - 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/model/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/

rt/frontend/jaxrs/src...


> Author: dkulp
> Date: Thu Aug 27 17:18:01 2009
> New Revision: 808545
>
> URL: http://svn.apache.org/viewvc?rev=808545&view=rev
> Log:
> Merged revisions 808488 via svnmerge from
> https://svn.apache.org/repos/asf/cxf/trunk
>
> ........
>  r808488 | sergeyb | 2009-08-27 12:17:42 -0400 (Thu, 27 Aug 2009) | 1 line
>
>  JAXRS : improving the no-annotations feature
> ........
>
> Added:
>    cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources.xml
>      - copied unchanged from r808488, cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources.xml
>    cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources2.xml
>      - copied unchanged from r808488, cxf/trunk/systests/src/test/resources/jaxrs_non_spring/WEB-INF/resources2.xml
> 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/JAXRSServiceFactoryBean.java
>    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
>    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
>    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserOperation.java
>    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserResource.java
>    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.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/resources/schemas/jaxrs.xsd
>    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
>    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java
>    cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
>    cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources.xml
>    cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml
>    cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml
>
> Propchange: cxf/branches/2.2.x-fixes/
> ------------------------------------------------------------------------------
> --- svn:mergeinfo (original)
> +++ svn:mergeinfo Thu Aug 27 17:18:01 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,790188,790294,790553,790637-790644,790868,791301,791354,791538,791753,791947,792007,792096,792183,792261-792265,792271,792604,792683-792685,792975,792985,793059,793570,794297,794396,794680,794728,794771,794778-794780,794892,795044,795104,795160,795583,795907,796022-796023,796352,796593,796741,796780,796994-796997,797117,797159,797192,797194,797231-797233,797442,797505,797517,797534,797581-797583,797587,797640,797651,797699,797882-797883,798344-798346,798363,798461,798479,798533,798551,798557,798561-798562,798570,798573,79!
 858
> 4,798654,798748-798749,798816,798891,798929-798930,799245,799267,799439,799448,799637,799723-799724,799792,800453,800497-800498,801380-801381,801447,801962,802892,803056,803129,803419,803460,803493,803689,804002,804175,804276,805784,805907,805909,806020-806021,806023,806405-806406,806576,806602-806604,806620,806627,806631,806633,806638,806687,806876,806922,806979-806982,807181,807205,807295,807748,807807,808035,808069,808085,808107,808464
> +/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,790294,790553,790637-790644,790868,791301,791354,791538,791753,791947,792007,792096,792183,792261-792265,792271,792604,792683-792685,792975,792985,793059,793570,794297,794396,794680,794728,794771,794778-794780,794892,795044,795104,795160,795583,795907,796022-796023,796352,796593,796741,796780,796994-796997,797117,797159,797192,797194,797231-797233,797442,797505,797517,797534,797581-797583,797587,797640,797651,797699,797882-797883,798344-798346,798363,798461,798479,798533,798551,798557,798561-798562,798570,798573,79!
 858
> 4,798654,798748-798749,798816,798891,798929-798930,799245,799267,799439,799448,799637,799723-799724,799792,800453,800497-800498,801380-801381,801447,801962,802892,803056,803129,803419,803460,803493,803689,804002,804175,804276,805784,805907,805909,806020-806021,806023,806405-806406,806576,806602-806604,806620,806627,806631,806633,806638,806687,806876,806922,806979-806982,807181,807205,807295,807748,807807,808035,808069,808085,808107,808464,808488
>
> 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/JAXRSServiceFactoryBean.java
> URL: 
> http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java?rev=808545&r1=808544&r2=808545&view=diff
> ==============================================================================
> --- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
(original)
> +++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
Thu Aug 27 17:18:01 
> 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/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
> URL: 
> http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java?rev=808545&r1=808544&r2=808545&view=diff
> ==============================================================================
> --- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
(original)
> +++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
Thu Aug 27 17:18:01 
> 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/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
> URL: 
> http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java?rev=808545&r1=808544&r2=808545&view=diff
> ==============================================================================
> --- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
(original)
> +++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
Thu Aug 27 
> 17:18:01 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/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserOperation.java
> URL: 
> http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserOperation.java?rev=808545&r1=808544&r2=808545&view=diff
> ==============================================================================
> --- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserOperation.java
(original)
> +++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserOperation.java
Thu Aug 27 17:18:01 
> 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/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserResource.java
> URL: 
> http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserResource.java?rev=808545&r1=808544&r2=808545&view=diff
> ==============================================================================
> --- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserResource.java
(original)
> +++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/UserResource.java
Thu Aug 27 17:18:01 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/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
> URL: 
> http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java?rev=808545&r1=808544&r2=808545&view=diff
> ==============================================================================
> --- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
(original)
> +++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
Thu Aug 27 
> 17:18:01 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/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=808545&r1=808544&r2=808545&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
Thu Aug 27 17:18:01 
> 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/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
> URL: 
> http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd?rev=808545&r1=808544&r2=808545&view=diff
> ==============================================================================
> --- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd (original)
> +++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd Thu
Aug 27 17:18:01 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/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
> URL: 
> http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java?rev=808545&r1=808544&r2=808545&view=diff
> ==============================================================================
> --- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
(original)
> +++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
Thu Aug 27 
> 17:18:01 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/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java
> URL: 
> http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java?rev=808545&r1=808544&r2=808545&view=diff
> ==============================================================================
> --- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java
(original)
> +++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/ResourceUtilsTest.java
Thu Aug 27 17:18:01 
> 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/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
> URL: 
> http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java?rev=808545&r1=808544&r2=808545&view=diff
> ==============================================================================
> --- cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java

> (original)
> +++ cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerNonSpringBookTest.java
Thu Aug 
> 27 17:18:01 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/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources.xml
> URL: 
> http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources.xml?rev=808545&r1=808544&r2=808545&view=diff
> ==============================================================================
> --- cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources.xml
(original)
> +++ cxf/branches/2.2.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources.xml
Thu Aug 27 17:18:01 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"/>
>
> Modified: cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml
> URL: 
> http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml?rev=808545&r1=808544&r2=808545&view=diff
> ==============================================================================
> --- cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml
(original)
> +++ cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml
Thu Aug 27 17:18:01 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/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml
> URL: 
> http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml?rev=808545&r1=808544&r2=808545&view=diff
> ==============================================================================
> --- cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml
(original)
> +++ cxf/branches/2.2.x-fixes/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml
Thu Aug 27 17:18:01 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