cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glen Mazza <glen.ma...@verizon.net>
Subject Re: svn commit: r576867 - in /incubator/cxf/branches/jliu: rt/frontend/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ systests/src/test/java/org/apache/cxf/systest/jaxrs/
Date Thu, 20 Sep 2007 01:53:17 GMT
Am Dienstag, den 18.09.2007, 12:37 +0000 schrieb jliu@apache.org:
> Author: jliu
> Date: Tue Sep 18 05:37:56 2007
> New Revision: 576867
> 
> Modified:
> incubator/cxf/branches/jliu/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=576867&r1=576866&r2=576867&view=diff
> ==============================================================================
> --- incubator/cxf/branches/jliu/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
(original)
> +++ incubator/cxf/branches/jliu/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
Tue Sep 18 05:37:56 2007
> @@ -22,6 +22,7 @@
>  import java.io.IOException;
>  import java.io.OutputStream;
>  
> +import javax.ws.rs.ProduceMime;
>  import javax.ws.rs.core.Response;
>  import javax.ws.rs.ext.EntityProvider;
>  import javax.ws.rs.ext.ProviderFactory;
> @@ -81,7 +82,16 @@
>              EntityProvider provider = ProviderFactory.getInstance().createEntityProvider(targetType);
>  
>              try {
> +                //TODO: decide the output media type based on resource method/resource
class/provider
> +                ProduceMime c = provider.getClass().getAnnotation(ProduceMime.class);
> +                String[] mineType = {"*/*"};

mimeType.

> +                if (c != null) {
> +                    mineType = c.value();               
> +                }
> +                message.put(Message.CONTENT_TYPE, mineType[0]);
> +                
>                  provider.writeTo(responseObj, null, out);
> +
>              } catch (IOException e) {
>                  e.printStackTrace();
>              }        
> 
> Modified: incubator/cxf/branches/jliu/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java
> URL: http://svn.apache.org/viewvc/incubator/cxf/branches/jliu/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java?rev=576867&r1=576866&r2=576867&view=diff
> ==============================================================================
> --- incubator/cxf/branches/jliu/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java
(original)
> +++ incubator/cxf/branches/jliu/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java
Tue Sep 18 05:37:56 2007
> @@ -20,8 +20,11 @@
>  package org.apache.cxf.jaxrs.provider;
>  
>  import java.util.ArrayList;
> +import java.util.Collections;
> +import java.util.Comparator;
>  import java.util.List;
>  
> +import javax.ws.rs.ConsumeMime;
>  import javax.ws.rs.core.Response.Builder;
>  import javax.ws.rs.ext.EntityProvider;
>  import javax.ws.rs.ext.HeaderProvider;
> @@ -37,7 +40,9 @@
>      public ProviderFactoryImpl() {
>          //TODO: search for EntityProviders from classpath or config file.
>          entityProviders.add(new JAXBElementProvider());
> -        //sort();
> +        entityProviders.add(new JSONProvider());
> +
> +        sort();
>      }
>      
>      public <T> T createInstance(Class<T> type) {
> @@ -75,8 +80,33 @@
>       * explicitly lists a media types is sorted before a provider that lists *. 
>       * Quality parameter values are also used such that x/y;q=1.0 < x/y;q=0.7.
>       */    
> -    protected void sort() {
> +    private void sort() {
> +        Collections.sort(entityProviders, new EntityProviderComparator());
> +    }
> +    
> +    
> +    private static class EntityProviderComparator implements Comparator<EntityProvider>
{
> +        public int compare(EntityProvider e1, EntityProvider e2) {
> +            ConsumeMime c = e1.getClass().getAnnotation(ConsumeMime.class);
> +            String[] mineType1 = {"*/*"};

also here

> +            if (c != null) {
> +                mineType1 = c.value();               
> +            }
> +            
> +            ConsumeMime c2 = e2.getClass().getAnnotation(ConsumeMime.class);
> +            String[] mineType2 = {"*/*"};

also here

Glen



Mime
View raw message