cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r636586 [1/3] - in /incubator/cxf/trunk: distribution/src/main/release/samples/jax_rs/basic/src/demo/jaxrs/server/ distribution/src/main/release/samples/jax_rs/basic_https/src/demo/jaxrs/server/ distribution/src/main/release/samples/jax_rs/...
Date Thu, 13 Mar 2008 00:20:47 GMT
Author: dkulp
Date: Wed Mar 12 17:20:41 2008
New Revision: 636586

URL: http://svn.apache.org/viewvc?rev=636586&view=rev
Log:
[CXF-1472] Update to 0.6 jaxrs.   Patch from Sergey B. applied

Added:
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AcceptTypeQueryHandler.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/NewCookieHeaderProvider.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ResponseBuilderImpl.java
      - copied, changed from r636320, incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BuilderImpl.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RuntimeDelegateImpl.java
      - copied, changed from r636320, incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SecurityContextImpl.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SystemQueryHandler.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/resources/META-INF/services/javax.ws.rs.ext.RuntimeDelegate
      - copied, changed from r636320, incubator/cxf/trunk/rt/frontend/jaxrs/src/main/resources/META-INF/services/javax.ws.rs.ext.ProviderFactory
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/CacheControlHeaderProviderTest.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/NewCookieHeaderProviderTest.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
      - copied, changed from r636320, incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImplTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/RequestImplTest.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ResponseBuilderImplTest.java
      - copied, changed from r636320, incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BuilderImplTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/RuntimeDelegateImplTest.java
      - copied, changed from r636320, incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImplTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/VariantListBuilderImplTest.java   (with props)
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStoreTemplates.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/Books.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_atom_book_json.txt   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/resources/expected_atom_books_json.txt   (with props)
Removed:
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BuilderImpl.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/resources/META-INF/services/javax.ws.rs.ext.ProviderFactory
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BuilderImplTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImplTest.java
Modified:
    incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/basic/src/demo/jaxrs/server/CustomerService.java
    incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/basic/src/demo/jaxrs/server/Order.java
    incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/basic_https/src/demo/jaxrs/server/CustomerService.java
    incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/content_negotiation/src/demo/jaxrs/server/CustomerService.java
    incubator/cxf/trunk/rt/frontend/jaxrs/pom.xml
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/CacheControlHeaderProvider.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/CookieHeaderProvider.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/EntityTagHeaderProvider.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingReaderProvider.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/HttpHeadersImpl.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MediaTypeHeaderProvider.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestImpl.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/UriBuilderImpl.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/VariantListBuilderImpl.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBeanTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSUtilsTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/ClassResourceInfoTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomEntryProviderTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomFeedProviderTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/CookieHeaderProviderTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/EntityTagHeaderProviderTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/MediaTypeHeaderProviderTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/Book.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookNoSubResource.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStore.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStoreNoSubResource.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomClientBookTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BadgerFishProvider.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/Book.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/PetStore.java

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/basic/src/demo/jaxrs/server/CustomerService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/basic/src/demo/jaxrs/server/CustomerService.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/basic/src/demo/jaxrs/server/CustomerService.java (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/basic/src/demo/jaxrs/server/CustomerService.java Wed Mar 12 17:20:41 2008
@@ -26,7 +26,7 @@
 import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
-import javax.ws.rs.UriParam;
+import javax.ws.rs.PathParam;
 import javax.ws.rs.core.Response;
 
 @Path("/customerservice/")
@@ -41,7 +41,7 @@
 
     @GET
     @Path("/customers/{id}/")
-    public Customer getCustomer(@UriParam("id") String id) {
+    public Customer getCustomer(@PathParam("id") String id) {
         System.out.println("----invoking getCustomer, Customer id is: " + id);
         long idNumber = Long.parseLong(id);
         Customer c = customers.get(idNumber);
@@ -77,7 +77,7 @@
 
     @DELETE
     @Path("/customers/{id}/")
-    public Response deleteCustomer(@UriParam("id") String id) {
+    public Response deleteCustomer(@PathParam("id") String id) {
         System.out.println("----invoking deleteCustomer, Customer id is: " + id);
         long idNumber = Long.parseLong(id);
         Customer c = customers.get(idNumber);
@@ -94,7 +94,7 @@
     }
 
     @Path("/orders/{orderId}/")
-    public Order getOrder(@UriParam("orderId") String orderId) {
+    public Order getOrder(@PathParam("orderId") String orderId) {
         System.out.println("----invoking getOrder, Order id is: " + orderId);
         long idNumber = Long.parseLong(orderId);
         Order c = orders.get(idNumber);

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/basic/src/demo/jaxrs/server/Order.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/basic/src/demo/jaxrs/server/Order.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/basic/src/demo/jaxrs/server/Order.java (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/basic/src/demo/jaxrs/server/Order.java Wed Mar 12 17:20:41 2008
@@ -22,6 +22,7 @@
 import java.util.Map;
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
 import javax.ws.rs.UriParam;
 
 import javax.xml.bind.annotation.XmlRootElement;
@@ -54,7 +55,7 @@
 
     @GET
     @Path("products/{productId}/")
-    public Product getProduct(@UriParam("productId")int productId) {
+    public Product getProduct(@PathParam("productId")int productId) {
         System.out.println("----invoking getProduct with id: " + productId);
         Product p = products.get(new Long(productId));
         return p;

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/basic_https/src/demo/jaxrs/server/CustomerService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/basic_https/src/demo/jaxrs/server/CustomerService.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/basic_https/src/demo/jaxrs/server/CustomerService.java (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/basic_https/src/demo/jaxrs/server/CustomerService.java Wed Mar 12 17:20:41 2008
@@ -26,7 +26,7 @@
 import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
-import javax.ws.rs.UriParam;
+import javax.ws.rs.PathParam;
 import javax.ws.rs.core.Response;
 
 @Path("/customerservice/")
@@ -40,7 +40,7 @@
 
     @GET
     @Path("/customers/{id}/")
-    public Customer getCustomer(@UriParam("id") String id) {
+    public Customer getCustomer(@PathParam("id") String id) {
         System.out.println("----invoking getCustomer, Customer id is: " + id);
         long idNumber = Long.parseLong(id);
         Customer c = customers.get(idNumber);
@@ -76,7 +76,7 @@
 
     @DELETE
     @Path("/customers/{id}/")
-    public Response deleteCustomer(@UriParam("id") String id) {
+    public Response deleteCustomer(@PathParam("id") String id) {
         System.out.println("----invoking deleteCustomer, Customer id is: " + id);
         long idNumber = Long.parseLong(id);
         Customer c = customers.get(idNumber);

Modified: incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/content_negotiation/src/demo/jaxrs/server/CustomerService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/content_negotiation/src/demo/jaxrs/server/CustomerService.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/content_negotiation/src/demo/jaxrs/server/CustomerService.java (original)
+++ incubator/cxf/trunk/distribution/src/main/release/samples/jax_rs/content_negotiation/src/demo/jaxrs/server/CustomerService.java Wed Mar 12 17:20:41 2008
@@ -23,7 +23,7 @@
 
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
-import javax.ws.rs.UriParam;
+import javax.ws.rs.PathParam;
 
 
 @Path("/customerservice/")
@@ -37,7 +37,7 @@
 
     @GET
     @Path("/customers/{id}/")
-    public Customer getCustomer(@UriParam("id") String id) {
+    public Customer getCustomer(@PathParam("id") String id) {
         System.out.println("----invoking getCustomer, Customer id is: " + id);
         long idNumber = Long.parseLong(id);
         Customer c = customers.get(idNumber);

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/pom.xml?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/pom.xml (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/pom.xml Wed Mar 12 17:20:41 2008
@@ -65,7 +65,7 @@
         <dependency>
             <groupId>javax.ws.rs</groupId>
             <artifactId>jsr311-api</artifactId>
-            <version>0.5</version>
+            <version>0.6</version>
         </dependency>
         <dependency>
             <groupId>jaxen</groupId>
@@ -79,6 +79,17 @@
             <groupId>org.apache.abdera</groupId>
             <artifactId>abdera-parser</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.abdera</groupId>
+            <artifactId>abdera-extensions-json</artifactId>
+            <version>0.3.0-incubating</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.abdera</groupId>
+                    <artifactId>abdera-client</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency> 
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-servlet_2.5_spec</artifactId>

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java Wed Mar 12 17:20:41 2008
@@ -23,8 +23,6 @@
 import java.util.Arrays;
 import java.util.List;
 
-import javax.ws.rs.ext.ProviderFactory;
-
 import org.apache.cxf.BusException;
 import org.apache.cxf.binding.BindingConfiguration;
 import org.apache.cxf.binding.BindingFactory;
@@ -37,7 +35,7 @@
 import org.apache.cxf.endpoint.ServerImpl;
 import org.apache.cxf.feature.AbstractFeature;
 import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
-import org.apache.cxf.jaxrs.provider.ProviderFactoryImpl;
+import org.apache.cxf.jaxrs.provider.ProviderFactory;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.factory.ServiceConstructionException;
 import org.apache.cxf.service.invoker.Invoker;
@@ -92,8 +90,7 @@
                 ep.getService().setInvoker(invoker);
             }
             if (entityProviders != null) {
-                ProviderFactoryImpl providerFactoryImpl = (ProviderFactoryImpl)ProviderFactory.getInstance();
-                providerFactoryImpl.setUserEntityProviders(entityProviders); 
+                ProviderFactory.getInstance().setUserEntityProviders(entityProviders); 
             }
             
             if (start) {

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java Wed Mar 12 17:20:41 2008
@@ -152,8 +152,10 @@
     protected ClassResourceInfo createClassResourceInfo(final Class<?> c, boolean root) {
         ClassResourceInfo cri  = new ClassResourceInfo(c, root);
 
-        URITemplate t = URITemplate.createTemplate(null, c.getAnnotation(Path.class));
-        cri.setURITemplate(t);
+        if (root) {
+            URITemplate t = URITemplate.createTemplate(cri, c.getAnnotation(Path.class));
+            cri.setURITemplate(t);
+        }
         
         MethodDispatcher md = createOperation(cri);
         cri.setMethodDispatcher(md);

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java Wed Mar 12 17:20:41 2008
@@ -37,23 +37,25 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
 
 import javax.ws.rs.ConsumeMime;
 import javax.ws.rs.HeaderParam;
 import javax.ws.rs.HttpMethod;
 import javax.ws.rs.MatrixParam;
+import javax.ws.rs.PathParam;
 import javax.ws.rs.ProduceMime;
 import javax.ws.rs.QueryParam;
-import javax.ws.rs.UriParam;
-import javax.ws.rs.core.HttpContext;
+import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.PathSegment;
 import javax.ws.rs.core.Request;
+import javax.ws.rs.core.SecurityContext;
 import javax.ws.rs.core.UriInfo;
 import javax.ws.rs.ext.MessageBodyReader;
-import javax.ws.rs.ext.ProviderFactory;
 
 import org.apache.cxf.common.util.PrimitiveUtils;
 import org.apache.cxf.common.util.StringUtils;
@@ -63,7 +65,9 @@
 import org.apache.cxf.jaxrs.model.URITemplate;
 import org.apache.cxf.jaxrs.provider.HttpHeadersImpl;
 import org.apache.cxf.jaxrs.provider.PathSegmentImpl;
+import org.apache.cxf.jaxrs.provider.ProviderFactory;
 import org.apache.cxf.jaxrs.provider.RequestImpl;
+import org.apache.cxf.jaxrs.provider.SecurityContextImpl;
 import org.apache.cxf.jaxrs.provider.UriInfoImpl;
 import org.apache.cxf.message.Message;
 
@@ -122,11 +126,13 @@
         
         for (ClassResourceInfo resource : resources) {
             URITemplate uriTemplate = resource.getURITemplate();
-            if (uriTemplate.match(path, values)) {
-                String subResourcePath = values.getFirst(URITemplate.RIGHT_HAND_VALUE);
-                OperationResourceInfo ori = findTargetMethod(resource, subResourcePath, httpMethod, values,
+            MultivaluedMap<String, String> map = new MetadataMap<String, String>();
+            if (uriTemplate.match(path, map)) {
+                String subResourcePath = map.getFirst(URITemplate.RIGHT_HAND_VALUE);
+                OperationResourceInfo ori = findTargetMethod(resource, subResourcePath, httpMethod, map,
                                                              requestContentType, acceptContentTypes);
                 if (ori != null) {
+                    values.putAll(map);
                     return ori;
                 }
             }
@@ -140,23 +146,38 @@
                                                          MultivaluedMap<String, String> values, 
                                                          String requestContentType, 
                                                          String acceptContentTypes) {
-        List<OperationResourceInfo> candidateList = new ArrayList<OperationResourceInfo>();
+        SortedMap<OperationResourceInfo, MultivaluedMap<String, String>> candidateList = 
+            new TreeMap<OperationResourceInfo, MultivaluedMap<String, String>>(
+                new OperationResourceInfoComparator());
         MediaType requestType = requestContentType == null 
                                 ? ALL_TYPES : MediaType.parse(requestContentType);
         List<MediaType> acceptTypes = JAXRSUtils.sortMediaTypes(acceptContentTypes);
+       
         for (MediaType acceptType : acceptTypes) {
             for (OperationResourceInfo ori : resource.getMethodDispatcher().getOperationResourceInfos()) {
+                
                 URITemplate uriTemplate = ori.getURITemplate();
-                if ((uriTemplate != null && uriTemplate.match(path, values))
-                    && (ori.isSubResourceLocator() || (ori.getHttpMethod() != null && ori.getHttpMethod()
-                        .equalsIgnoreCase(httpMethod)))
-                        && matchMimeTypes(requestType, acceptType, ori)) {
-                    candidateList.add(ori);
+                MultivaluedMap<String, String> map = new MetadataMap<String, String>();
+                map.putAll(values);
+                if (uriTemplate != null && uriTemplate.match(path, map)) {
+                    if (ori.isSubResourceLocator() && matchMimeTypes(requestType, acceptType, ori)) {
+                        candidateList.put(ori, map);
+                    } else if (ori.getHttpMethod().equalsIgnoreCase(httpMethod)
+                               && matchMimeTypes(requestType, acceptType, ori)) {
+                        String finalGroup = map.getFirst(URITemplate.RIGHT_HAND_VALUE);
+                        if (finalGroup == null || StringUtils.isEmpty(finalGroup)
+                            || finalGroup.equals("/")) {
+                            candidateList.put(ori, map);    
+                        }
+                    }
                 }
             }
             if (!candidateList.isEmpty()) {
-                Collections.sort(candidateList, new OperationResourceInfoComparator());
-                return candidateList.get(0);
+                Map.Entry<OperationResourceInfo, MultivaluedMap<String, String>> firstEntry = 
+                    candidateList.entrySet().iterator().next();
+                values.clear();
+                values.putAll(firstEntry.getValue());
+                return firstEntry.getKey();
             }
         }
 
@@ -289,11 +310,11 @@
                                          is, 
                                          MediaType.parse(contentType),
                                          ori.getConsumeTypes());
-        } else if (parameterAnnotations[0].annotationType() == HttpContext.class
+        } else if (parameterAnnotations[0].annotationType() == Context.class
                    && ori.getClassResourceInfo().isRoot()) {
             return createHttpContextValue(message, parameterClass, ori);
-        } else if (parameterAnnotations[0].annotationType() == UriParam.class) {
-            return readFromUriParam((UriParam)parameterAnnotations[0], parameterClass, parameterType,
+        } else if (parameterAnnotations[0].annotationType() == PathParam.class) {
+            return readFromUriParam((PathParam)parameterAnnotations[0], parameterClass, parameterType,
                                       parameterAnnotations, path, values);
         }  
         
@@ -311,9 +332,17 @@
         return result;
     }
     
-    // TODO:
-    private static Object processMatrixParam(Message m, String value, String defaultValue) {
-        return null;
+    private static Object processMatrixParam(Message m, String key, String defaultValue) {
+        List<PathSegment> segments = JAXRSUtils.getPathSegments(
+                                      (String)m.get(Message.PATH_INFO), true);
+        String value = null;
+        if (segments.size() > 0) {
+            MultivaluedMap<String, String> params = 
+                segments.get(segments.size() - 1).getMatrixParameters();
+            value = params.getFirst(key);
+        }
+        
+        return value == null ? defaultValue : value;
     }
     
     public static MultivaluedMap<String, String> getMatrixParams(String path, boolean decode) {
@@ -350,11 +379,14 @@
         if (Request.class.isAssignableFrom(clazz)) {
             return new RequestImpl(m);
         }
+        if (SecurityContext.class.isAssignableFrom(clazz)) {
+            return new SecurityContextImpl(m);
+        }
         
         return null;
     }
 
-    private static Object readFromUriParam(UriParam uriParamAnnotation,
+    private static Object readFromUriParam(PathParam uriParamAnnotation,
                                            Class<?> parameter,
                                            Type parameterType,
                                            Annotation[] parameterAnnotations,
@@ -403,9 +435,9 @@
         if (!StringUtils.isEmpty(query)) {            
             List<String> parts = Arrays.asList(query.split(sep));
             for (String part : parts) {
-                String[] keyValue = part.split("=");
-                queries.add(keyValue[0], 
-                            decode ? uriDecode(keyValue[1]) : keyValue[1]);
+                String[] values = part.split("=");
+                queries.add(values[0], values.length == 1 ? "" 
+                    : decode ? uriDecode(values[1]) : values[1]);
             }
         }
         return queries;

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java Wed Mar 12 17:20:41 2008
@@ -31,6 +31,8 @@
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.model.URITemplate;
+import org.apache.cxf.jaxrs.provider.ProviderFactory;
+import org.apache.cxf.jaxrs.provider.SystemQueryHandler;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
@@ -55,11 +57,6 @@
         if (requestContentType == null) {
             requestContentType = "*/*";
         }
-        String acceptContentTypes = (String)message.get(Message.ACCEPT_CONTENT_TYPE);
-        if (acceptContentTypes == null) {
-            acceptContentTypes = "*/*";
-        }
-        message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes);
         
         if (address.startsWith("http")) {
             int idx = address.indexOf('/', 7);
@@ -80,12 +77,28 @@
         }
         message.put(RELATIVE_PATH, path);
         
+        
+        //TODO : make sure we do this parsing ony once, not expensove though
+        MultivaluedMap<String, String> queries = 
+            JAXRSUtils.getStructuredParams((String)message.get(Message.QUERY_STRING), 
+                                            "&", true);
+        SystemQueryHandler sqh = ProviderFactory.getInstance().getQueryHandler(queries);
+        if (sqh != null) {
+            // TODO : if Response != null then make sure no invocations happen
+            sqh.handleSystemQuery(message, queries);
+        }
+        
+        String acceptContentTypes = (String)message.get(Message.ACCEPT_CONTENT_TYPE);
+        if (acceptContentTypes == null) {
+            acceptContentTypes = "*/*";
+        }
+        message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes);
+        
         LOG.fine("Request path is: " + path);
         LOG.fine("Request HTTP method is: " + httpMethod);
         LOG.fine("Request contentType is: " + requestContentType);
         LOG.fine("Accept contentType is: " + acceptContentTypes);
-
-
+        
         //1. Matching target resource classes and method
         Service service = message.getExchange().get(Service.class);
         List<ClassResourceInfo> resources = ((JAXRSServiceImpl)service).getClassResourceInfos();

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java Wed Mar 12 17:20:41 2008
@@ -28,12 +28,12 @@
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.ext.MessageBodyWriter;
-import javax.ws.rs.ext.ProviderFactory;
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
 import org.apache.cxf.jaxrs.JAXRSUtils;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
+import org.apache.cxf.jaxrs.provider.ProviderFactory;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageContentsList;

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java Wed Mar 12 17:20:41 2008
@@ -24,7 +24,7 @@
 import java.util.Collections;
 import java.util.List;
 
-import javax.ws.rs.core.HttpContext;
+import javax.ws.rs.core.Context;
 
 import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
 
@@ -100,7 +100,7 @@
         Field[] fields = resourceClass.getDeclaredFields();
         
         for (Field f : fields) {
-            HttpContext context = f.getAnnotation(HttpContext.class);
+            Context context = f.getAnnotation(Context.class);
             if (context != null) {
                 httpContexts.add(f);               
             }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java Wed Mar 12 17:20:41 2008
@@ -107,7 +107,6 @@
     }
 
     public boolean match(String uri, MultivaluedMap<String, String> templateVariableToValue) {
-        //templateVariableToValue.clear();
 
         if (uri == null) {
             return (templateRegexPattern == null) ? true : false;
@@ -125,19 +124,18 @@
         // Assign the matched template values to template variables
         int i = 1;
         for (String name : templateVariables) {
-            String previousValue = templateVariableToValue.getFirst(name);
-            String currentValue = m.group(i++);
-
-            if (previousValue != null && !previousValue.equals(currentValue)) {
-                return false;
+            String value = m.group(i++);
+            if (templateVariableToValue.getFirst(name) != null) {
+                continue;
             }
 
-            templateVariableToValue.putSingle(name, currentValue);
+            templateVariableToValue.putSingle(name, value);
         }
 
         // The right hand side value, might be used to further resolve sub-resources.
         if (regexSuffix != null) {
-            templateVariableToValue.putSingle(RIGHT_HAND_VALUE, m.group(i));
+            String finalGroup = m.group(i);
+            templateVariableToValue.putSingle(RIGHT_HAND_VALUE, finalGroup == null ? "/" : finalGroup);
         }
 
         return true;
@@ -147,22 +145,17 @@
                                              Path path) {
         
         if (path == null) {
-            return cri == null ? new URITemplate("/", URITemplate.UNLIMITED_REGEX_SUFFIX)
-                               : cri.getURITemplate();
+            return new URITemplate("/", URITemplate.UNLIMITED_REGEX_SUFFIX);
         }
         
-        String prefix = cri != null && !cri.isRoot() ? cri.getURITemplate().getValue() : "/";
-        if (!prefix.endsWith("/")) {
-            prefix += "/";
-        }                
         String pathValue = path.value();
-        if (pathValue.startsWith("/")) {
-            pathValue = pathValue.length() == 1 ? "" : pathValue.substring(1);
+        if (!pathValue.startsWith("/")) {
+            pathValue = "/" + pathValue;
         }
-                
+        
         String suffixPattern = (path.limited())
             ? URITemplate.LIMITED_REGEX_SUFFIX : URITemplate.UNLIMITED_REGEX_SUFFIX;
         
-        return new URITemplate(prefix + pathValue, suffixPattern);
+        return new URITemplate(pathValue, suffixPattern);
     }
 }

Added: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AcceptTypeQueryHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AcceptTypeQueryHandler.java?rev=636586&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AcceptTypeQueryHandler.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AcceptTypeQueryHandler.java Wed Mar 12 17:20:41 2008
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs.provider;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+
+import org.apache.cxf.message.Message;
+
+public class AcceptTypeQueryHandler implements SystemQueryHandler {
+
+    private static final String CONTENT_QUERY = "_contentType";
+    private static final Map<String, String> SHORTCUTS;
+    static {
+        SHORTCUTS = new HashMap<String, String>();
+        SHORTCUTS.put("json", "application/json");
+        SHORTCUTS.put("text", "text/*");
+        SHORTCUTS.put("xml", "application/xml");
+        // more to come
+    }
+    
+    public Response handleSystemQuery(Message m, MultivaluedMap<String, String> queries) {
+        
+        String type = queries.getFirst(CONTENT_QUERY);
+        if (type != null) {
+            if (SHORTCUTS.containsKey(type)) {
+                type = SHORTCUTS.get(type);
+            }
+            String types = (String)m.get(Message.ACCEPT_CONTENT_TYPE);
+            types = types == null ? type : types + ',' + type;
+            m.getExchange().put(Message.ACCEPT_CONTENT_TYPE, types);
+            m.put(Message.ACCEPT_CONTENT_TYPE, type);
+        }
+        
+        return null;
+    }
+
+    public boolean supports(MultivaluedMap<String, String> queries) {
+        return queries.getFirst(CONTENT_QUERY) != null;
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AcceptTypeQueryHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AcceptTypeQueryHandler.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java Wed Mar 12 17:20:41 2008
@@ -34,14 +34,16 @@
 import org.apache.abdera.Abdera;
 import org.apache.abdera.model.Document;
 import org.apache.abdera.model.Entry;
+import org.apache.abdera.writer.Writer;
 
-@ProduceMime("application/atom+xml")
-@ConsumeMime("application/atom+xml")
+@ProduceMime({"application/atom+xml", "application/atom+xml;type=entry", "application/json" })
+@ConsumeMime({"application/atom+xml", "application/atom+xml;type=entry" })
 @Provider
 public class AtomEntryProvider 
     implements MessageBodyReader<Entry>, MessageBodyWriter<Entry> {
 
     private static final Abdera ATOM_ENGINE = new Abdera();
+    private static final String JSON_TYPE = "application/json";
     
     public Entry readFrom(Class<Entry> clazz, MediaType mt, 
                           MultivaluedMap <String, String> headers, InputStream is)
@@ -61,7 +63,12 @@
     public void writeTo(Entry entry, MediaType mt, 
                         MultivaluedMap<String, Object> headers, OutputStream os)
         throws IOException {
-        entry.writeTo(os);
+        if (JSON_TYPE.equals(mt.toString())) {
+            Writer w = ATOM_ENGINE.getWriterFactory().getWriter("json");
+            entry.writeTo(w, os);   
+        } else {
+            entry.writeTo(os);
+        }
     }
  
     public long getSize(Entry entry) {

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java Wed Mar 12 17:20:41 2008
@@ -34,13 +34,15 @@
 import org.apache.abdera.Abdera;
 import org.apache.abdera.model.Document;
 import org.apache.abdera.model.Feed;
+import org.apache.abdera.writer.Writer;
 
-@ProduceMime("application/atom+xml")
-@ConsumeMime("application/atom+xml")
+@ProduceMime({"application/atom+xml", "application/atom+xml;type=feed", "application/json" })
+@ConsumeMime({"application/atom+xml", "application/atom+xml;type=feed" })
 @Provider
 public class AtomFeedProvider 
     implements MessageBodyWriter<Feed>, MessageBodyReader<Feed> {
 
+    private static final String JSON_TYPE = "application/json";
     private static final Abdera ATOM_ENGINE = new Abdera();
         
     public boolean isWriteable(Class<?> type) {
@@ -50,7 +52,12 @@
     public void writeTo(Feed feed, MediaType mt, 
                         MultivaluedMap<String, Object> headers, OutputStream os)
         throws IOException {
-        feed.writeTo(os);
+        if (JSON_TYPE.equals(mt.toString())) {
+            Writer w = ATOM_ENGINE.getWriterFactory().getWriter("json");
+            feed.writeTo(w, os);   
+        } else {
+            feed.writeTo(os);
+        }
     }
     
     public long getSize(Feed feed) {

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/CacheControlHeaderProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/CacheControlHeaderProvider.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/CacheControlHeaderProvider.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/CacheControlHeaderProvider.java Wed Mar 12 17:20:41 2008
@@ -19,26 +19,141 @@
 
 package org.apache.cxf.jaxrs.provider;
 
-import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 
 import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.ext.HeaderProvider;
-import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
 
-@Provider
-public class CacheControlHeaderProvider implements HeaderProvider<CacheControl> {
+public class CacheControlHeaderProvider implements HeaderDelegate<CacheControl> {
+    
+    private static final String PUBLIC = "public";
+    private static final String PRIVATE = "private";
+    private static final String NO_CACHE = "no-cache";
+    private static final String NO_STORE = "no-store";
+    private static final String NO_TRANSFORM = "no-transform";
+    private static final String MUST_REVALIDATE = "must-revalidate";
+    private static final String PROXY_REVALIDATE = "proxy-revalidate";
+    private static final String MAX_AGE = "max-age";
+    private static final String SMAX_AGE = "s-maxage";
 
-    public CacheControl fromString(String header) throws ParseException {
-        return new CacheControl();
+    public CacheControl fromString(String c) {
+        boolean isPublic = true;
+        boolean isPrivate = false;
+        List<String> privateFields = new ArrayList<String>();
+        boolean noCache = false;
+        List<String> noCacheFields = new ArrayList<String>();
+        boolean noStore = false;
+        boolean noTransform = false;
+        boolean mustRevalidate = false;
+        boolean proxyRevalidate = false;
+        int maxAge = -1;
+        int sMaxAge = -1;
+       
+        
+        String[] tokens = c.split(";");
+        for (String token : tokens) {
+            if (token.startsWith(MAX_AGE)) {
+                maxAge = Integer.parseInt(token.substring(MAX_AGE.length() + 1));
+            } else if (token.startsWith(SMAX_AGE)) {
+                sMaxAge = Integer.parseInt(token.substring(SMAX_AGE.length() + 1));
+            } else if (token.startsWith(PUBLIC)) {
+                // ignore
+            } else if (token.startsWith(NO_STORE)) {
+                noStore = true;
+            } else if (token.startsWith(NO_TRANSFORM)) {
+                noTransform = true;
+            } else if (token.startsWith(MUST_REVALIDATE)) {
+                mustRevalidate = true;
+            } else if (token.startsWith(PROXY_REVALIDATE)) {
+                proxyRevalidate = true;
+            } else if (token.startsWith(PRIVATE)) {
+                isPublic = false;
+                isPrivate = true;
+                addFields(privateFields, token);
+            }  else if (token.startsWith(NO_CACHE)) {
+                noCache = true;
+                addFields(noCacheFields, token);
+            }
+        }
+        
+        CacheControl cc = new CacheControl();
+        cc.setMaxAge(maxAge);
+        cc.setSMaxAge(sMaxAge);
+        cc.setPublic(isPublic);
+        cc.setPrivate(isPrivate);
+        cc.getPrivateFields().addAll(privateFields);
+        cc.setMustRevalidate(mustRevalidate);
+        cc.setProxyRevalidate(proxyRevalidate);
+        cc.setNoCache(noCache);
+        cc.getNoCacheFields().addAll(noCacheFields);
+        cc.setNoStore(noStore);
+        cc.setNoTransform(noTransform);
+        
+        return cc;
     }
 
-    public boolean supports(Class<?> type) {
-        return CacheControl.class.isAssignableFrom(type);
+    public String toString(CacheControl c) {
+        StringBuilder sb = new StringBuilder();
+        if (c.isPublic()) {
+            sb.append(PUBLIC).append(';');
+        } else {
+            sb.append(PRIVATE).append('=');
+            for (Iterator<String> it = c.getPrivateFields().iterator(); it.hasNext();) {
+                sb.append('\"').append(it.next()).append('\"');
+                if (it.hasNext()) {
+                    sb.append(',');
+                }
+            }
+            sb.append(';');
+        }
+        if (c.isNoCache()) {
+            sb.append(NO_CACHE).append('=');
+            for (Iterator<String> it = c.getNoCacheFields().iterator(); it.hasNext();) {
+                sb.append('\"').append(it.next()).append('\"');
+                if (it.hasNext()) {
+                    sb.append(',');
+                }
+            }
+            sb.append(';');
+        }
+        if (c.isNoStore()) {
+            sb.append(NO_STORE).append(';');
+        }
+        if (c.isNoTransform()) {
+            sb.append(NO_TRANSFORM).append(';');
+        }
+        if (c.isMustRevalidate()) {
+            sb.append(MUST_REVALIDATE).append(';');
+        }
+        if (c.isProxyRevalidate()) {
+            sb.append(PROXY_REVALIDATE).append(';');
+        }
+        if (c.getMaxAge() != -1) {
+            sb.append(MAX_AGE).append('=').append(c.getMaxAge()).append(';');
+        }
+        if (c.getSMaxAge() != -1) {
+            sb.append(SMAX_AGE).append('=').append(c.getSMaxAge()).append(';');
+        }
+        String s = sb.toString();
+        return s.endsWith(";") ? s.substring(0, s.length() - 1) : s; 
     }
-
-    public String toString(CacheControl header) {
-        // TODO Auto-generated method stub
-        return null;
+    
+    private static void addFields(List<String> fields, String token) {
+        String f = null;
+        int i = token.indexOf('=');
+        if (i != -1) {
+            f = i == token.length()  + 1 ? "" : token.substring(i + 1);
+            if (f.length() < 2 || !f.startsWith("\"") || !f.endsWith("\"")) {
+                f = "";
+            } else {
+                f = f.length() == 2 ? "" : f.substring(1, f.length() - 1);
+            }
+        }
+        if (f != null) {
+            fields.add(f);
+        }
     }
 
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/CookieHeaderProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/CookieHeaderProvider.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/CookieHeaderProvider.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/CookieHeaderProvider.java Wed Mar 12 17:20:41 2008
@@ -18,18 +18,16 @@
  */
 package org.apache.cxf.jaxrs.provider;
 
-import java.text.ParseException;
-
 import javax.ws.rs.core.Cookie;
-import javax.ws.rs.ext.HeaderProvider;
+import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
 
-public class CookieHeaderProvider implements HeaderProvider<Cookie> {
+public class CookieHeaderProvider implements HeaderDelegate<Cookie> {
 
     private static final String VERSION = "$Version";
     private static final String PATH = "$Path";
     private static final String DOMAIN = "$Domain";
     
-    public Cookie fromString(String c) throws ParseException {
+    public Cookie fromString(String c) {
         
         int version = -1;
         String name = null;
@@ -37,7 +35,7 @@
         String path = null;
         String domain = null;
         
-        // ignore the fact the possible version may be seperated by ','        
+        // ignore the fact the possible version may be seperated by ','
         String[] tokens = c.split(";");
         for (String token : tokens) {
             if (token.startsWith(VERSION)) {
@@ -55,19 +53,17 @@
             }
         }
         
-        if (name == null) {
-            throw new ParseException("No Cookie name can be found : " + c, 0);
+        if (name == null || value == null) {
+            throw new IllegalArgumentException("Cookie is malformed : " + c);
         }
         
         return new Cookie(name, value, path, domain, version);
     }
 
-    public boolean supports(Class<?> type) {
-        return Cookie.class.isAssignableFrom(type);
-    }
-
+    
     public String toString(Cookie c) {
         StringBuilder sb = new StringBuilder();
+        
         if (c.getVersion() != -1) {
             sb.append(VERSION).append('=').append(c.getVersion()).append(';');
         }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/EntityTagHeaderProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/EntityTagHeaderProvider.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/EntityTagHeaderProvider.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/EntityTagHeaderProvider.java Wed Mar 12 17:20:41 2008
@@ -19,32 +19,32 @@
 
 package org.apache.cxf.jaxrs.provider;
 
-import java.text.ParseException;
-
 import javax.ws.rs.core.EntityTag;
-import javax.ws.rs.ext.HeaderProvider;
-import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
 
-@Provider
-public class EntityTagHeaderProvider implements HeaderProvider<EntityTag> {
+public class EntityTagHeaderProvider implements HeaderDelegate<EntityTag> {
 
     private static final String WEAK_PREFIX = "W/";
     
-    public EntityTag fromString(String header) throws ParseException {
+    public EntityTag fromString(String header) {
+        String tag = null;
+        boolean weak =  false;
         int i = header.indexOf(WEAK_PREFIX);
         if (i != -1) {
+            weak = true;
             if (i + 2 < header.length()) {
-                return new EntityTag(header.substring(i + 2), true);
+                tag = header.substring(i + 2);
             } else {
-                return new EntityTag("", true);
+                return new EntityTag("", weak);
             }
-        } 
-        
-        return new EntityTag(header);
-    }
-
-    public boolean supports(Class type) {
-        return EntityTag.class.isAssignableFrom(type);
+        }  else {
+            tag = header;
+        }
+        if (tag.length() < 2 || !tag.startsWith("\"") || !tag.endsWith("\"")) {
+            throw new IllegalArgumentException("Misformatted ETag : " + header);
+        }
+        tag = tag.length() == 2 ? "" : tag.substring(1, tag.length() - 1); 
+        return new EntityTag(tag, weak);
     }
 
     public String toString(EntityTag tag) {
@@ -52,7 +52,7 @@
         if (tag.isWeak()) {
             sb.append(WEAK_PREFIX);
         }
-        sb.append(tag.getValue());
+        sb.append("\"").append(tag.getValue()).append("\"");
         return sb.toString();
     }
 

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingReaderProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingReaderProvider.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingReaderProvider.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingReaderProvider.java Wed Mar 12 17:20:41 2008
@@ -30,11 +30,13 @@
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
 
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.jaxrs.MetadataMap;
 
 @ConsumeMime("application/x-www-form-urlencoded")
+@Provider
 public final class FormEncodingReaderProvider implements MessageBodyReader<Object> {
 
     public boolean isReadable(Class<?> type) {

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/HttpHeadersImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/HttpHeadersImpl.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/HttpHeadersImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/HttpHeadersImpl.java Wed Mar 12 17:20:41 2008
@@ -20,7 +20,7 @@
 package org.apache.cxf.jaxrs.provider;
 
 
-import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -49,11 +49,12 @@
         return JAXRSUtils.parseMediaTypes((String)m.get(Message.ACCEPT_CONTENT_TYPE));
     }
 
-    public List<Cookie> getCookies() {
+    public Map<String, Cookie> getCookies() {
         List<String> cs = headers.get("Cookie");
-        List<Cookie> cl = new ArrayList<Cookie>(); 
+        Map<String, Cookie> cl = new HashMap<String, Cookie>(); 
         for (String c : cs) {
-            cl.add(Cookie.parse(c));
+            Cookie cookie = Cookie.parse(c);
+            cl.put(cookie.getName(), cookie);
         }
         return cl;
     }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MediaTypeHeaderProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MediaTypeHeaderProvider.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MediaTypeHeaderProvider.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MediaTypeHeaderProvider.java Wed Mar 12 17:20:41 2008
@@ -19,20 +19,17 @@
 
 package org.apache.cxf.jaxrs.provider;
 
-import java.text.ParseException;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.StringTokenizer;
 
 import javax.ws.rs.core.MediaType;
-import javax.ws.rs.ext.HeaderProvider;
-import javax.ws.rs.ext.Provider;
+import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
 
-@Provider
-public class MediaTypeHeaderProvider implements HeaderProvider<MediaType> {
+public class MediaTypeHeaderProvider implements HeaderDelegate<MediaType> {
 
-    public MediaType fromString(String mType) throws ParseException {
+    public MediaType fromString(String mType) {
         
         if (mType.equals(MediaType.MEDIA_TYPE_WILDCARD) || mType.startsWith("*;")) {
             return new MediaType("*", "*");
@@ -40,7 +37,7 @@
         
         int i = mType.indexOf('/');
         if (i == -1) {
-            throw new ParseException("Media type separator is missing", 0);
+            throw new IllegalArgumentException("Media type separator is missing");
         }
         
         int paramsStart = mType.indexOf(';', i + 1);
@@ -60,7 +57,7 @@
                 String token = st.nextToken();
                 int equalSign = token.indexOf('=');
                 if (equalSign == -1) {
-                    throw new ParseException("Wrong media type  parameter, seperator is missing", 0);
+                    throw new IllegalArgumentException("Wrong media type  parameter, seperator is missing");
                 }
                 parameters.put(token.substring(0, equalSign).trim().toLowerCase(), 
                                token.substring(equalSign + 1).trim().toLowerCase());
@@ -71,10 +68,6 @@
         return new MediaType(type.trim().toLowerCase(), 
                              subtype.trim().toLowerCase(), 
                              parameters);
-    }
-
-    public boolean supports(Class<?> clazz) {
-        return MediaType.class.isAssignableFrom(clazz);
     }
 
     public String toString(MediaType type) {

Added: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/NewCookieHeaderProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/NewCookieHeaderProvider.java?rev=636586&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/NewCookieHeaderProvider.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/NewCookieHeaderProvider.java Wed Mar 12 17:20:41 2008
@@ -0,0 +1,96 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.jaxrs.provider;
+
+import javax.ws.rs.core.NewCookie;
+import javax.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
+
+public class NewCookieHeaderProvider implements HeaderDelegate<NewCookie> {
+
+    private static final String VERSION = "Version";
+    private static final String PATH = "Path";
+    private static final String DOMAIN = "Domain";
+    private static final String MAX_AGE = "Max-Age";
+    private static final String COMMENT = "Comment";
+    private static final String SECURE = "Secure";
+    
+    public NewCookie fromString(String c) {
+        
+        String name = null;
+        String value = null;
+        String path = null;
+        String domain = null;
+        String comment = null;
+        int maxAge = -1;
+        boolean isSecure = false;
+        
+        String[] tokens = c.split(";");
+        for (String token : tokens) {
+            if (token.startsWith(VERSION)) {
+                // should we throw an exception if it's not == 1 ?
+            } else if (token.startsWith(MAX_AGE)) {
+                maxAge = Integer.parseInt(token.substring(MAX_AGE.length() + 1));
+            } else if (token.startsWith(PATH)) {
+                path = token.substring(PATH.length() + 1);
+            } else if (token.startsWith(DOMAIN)) {
+                domain = token.substring(DOMAIN.length() + 1);
+            } else if (token.startsWith(COMMENT)) {
+                comment = token.substring(COMMENT.length() + 1);
+            } else if (token.startsWith(SECURE)) {
+                isSecure = true;
+            } else {
+                int i = token.indexOf('=');
+                if (i != -1) {
+                    name = token.substring(0, i);
+                    value = i == token.length()  + 1 ? "" : token.substring(i + 1);
+                }
+            }
+        }
+        
+        if (name == null || value == null) {
+            throw new IllegalArgumentException("Set-Cookie is malformed : " + c);
+        }
+        
+        return new NewCookie(name, value, path, domain, comment, maxAge, isSecure);
+    }
+
+    public String toString(NewCookie value) {
+        StringBuilder sb = new StringBuilder();
+        sb.append(value.getName()).append('=').append(value.getValue());
+        if (value.getComment() != null) {
+            sb.append(';').append(COMMENT).append('=').append(value.getComment());
+        }
+        if (value.getDomain() != null) {
+            sb.append(';').append(DOMAIN).append('=').append(value.getDomain());
+        }
+        if (value.getMaxAge() != -1) {
+            sb.append(';').append(MAX_AGE).append('=').append(value.getMaxAge());
+        }
+        if (value.getPath() != null) {
+            sb.append(';').append(PATH).append('=').append(value.getPath());
+        }
+        if (value.isSecure()) {
+            sb.append(';').append(SECURE);
+        }
+        sb.append(';').append(VERSION).append('=').append(1);
+        return sb.toString();
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/NewCookieHeaderProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/NewCookieHeaderProvider.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=636586&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java (added)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java Wed Mar 12 17:20:41 2008
@@ -0,0 +1,321 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+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.ProduceMime;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+
+import org.apache.cxf.jaxrs.JAXRSUtils;
+
+public final class ProviderFactory {
+    
+    private static final ProviderFactory PF = new ProviderFactory();
+    
+    private List<MessageBodyReader> defaultMessageReaders = new ArrayList<MessageBodyReader>();
+    private List<MessageBodyWriter> defaultMessageWriters = new ArrayList<MessageBodyWriter>();
+    private List<MessageBodyReader> userMessageReaders = new ArrayList<MessageBodyReader>();
+    private List<MessageBodyWriter> userMessageWriters = new ArrayList<MessageBodyWriter>();
+    private List<SystemQueryHandler> queryHandlers = new ArrayList<SystemQueryHandler>();
+    
+    private ProviderFactory() {
+        // TODO : this needs to be done differently,
+        // we need to use cxf-jaxrs-extensions
+        setProviders(defaultMessageReaders,
+                     defaultMessageWriters,
+                     new JSONProvider(),
+                     new BinaryDataProvider(),
+                     new JAXBElementProvider(),
+                     new StringProvider(),
+                     new SourceProvider(),
+                     new AtomFeedProvider(),
+                     new AtomEntryProvider(),
+                     new FormEncodingReaderProvider());
+        
+        queryHandlers.add(new AcceptTypeQueryHandler());
+    }
+    
+    public static ProviderFactory getInstance() {
+        return PF;
+    }
+
+    public <T> MessageBodyReader<T> createMessageBodyReader(Class<T> bodyType, MediaType mediaType) {
+        // Try user provided providers
+        MessageBodyReader<T> mr = chooseMessageReader(userMessageReaders, 
+                                                      bodyType,
+                                                      mediaType);
+        
+        //If none found try the default ones
+        if (mr == null) {
+            mr = chooseMessageReader(defaultMessageReaders,
+                                     bodyType,
+                                     mediaType);
+        }     
+        
+        return mr;
+    }
+    
+    public SystemQueryHandler getQueryHandler(MultivaluedMap<String, String> query) {
+        
+        for (SystemQueryHandler h : queryHandlers) {
+            if (h.supports(query)) {
+                return h;
+            }
+        }
+        
+        return null;
+    }
+
+    public <T> MessageBodyWriter<T> createMessageBodyWriter(Class<T> bodyType, MediaType mediaType) {
+        // Try user provided providers
+        MessageBodyWriter<T> mw = chooseMessageWriter(userMessageWriters,
+                                                      bodyType,
+                                                      mediaType);
+        
+        //If none found try the default ones
+        if (mw == null) {
+            mw = chooseMessageWriter(defaultMessageWriters,
+                                     bodyType,
+                                     mediaType);
+        }     
+        
+        return mw;
+    }
+    
+       
+    private void setProviders(List<MessageBodyReader> readers, 
+                              List<MessageBodyWriter> writers, 
+                              Object... providers) {
+        
+        for (Object o : providers) {
+            if (MessageBodyReader.class.isAssignableFrom(o.getClass())) {
+                readers.add((MessageBodyReader)o); 
+            }
+            
+            if (MessageBodyWriter.class.isAssignableFrom(o.getClass())) {
+                writers.add((MessageBodyWriter)o); 
+            }
+        }
+        
+        sortReaders(readers);
+        sortWriters(writers);
+    }
+    
+    /*
+     * sorts the available providers according to the media types they declare
+     * support for. Sorting of media types follows the general rule: x/y < * x < *,
+     * i.e. a provider that 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.
+     */    
+    private void sortReaders(List<MessageBodyReader> entityProviders) {
+        Collections.sort(entityProviders, new MessageBodyReaderComparator());
+    }
+    
+    private void sortWriters(List<MessageBodyWriter> entityProviders) {
+        Collections.sort(entityProviders, new MessageBodyWriterComparator());
+    }
+    
+        
+    
+    /**
+     * Choose the first body reader provider that matches the requestedMimeType 
+     * for a sorted list of Entity providers
+     * Returns null if none is found.
+     * @param <T>
+     * @param messageBodyReaders
+     * @param type
+     * @param requestedMimeType
+     * @return
+     */
+    private <T> MessageBodyReader<T> chooseMessageReader(
+        List<MessageBodyReader> readers, Class<T> type, MediaType mediaType) {
+        for (MessageBodyReader<T> ep : readers) {
+            
+            if (!ep.isReadable(type)) {
+                continue;
+            }
+            
+            List<MediaType> supportedMediaTypes =
+                JAXRSUtils.getConsumeTypes(ep.getClass().getAnnotation(ConsumeMime.class));
+            
+            List<MediaType> availableMimeTypes = 
+                JAXRSUtils.intersectMimeTypes(Collections.singletonList(mediaType),
+                                              supportedMediaTypes);
+
+            if (availableMimeTypes.size() != 0) {
+                return ep;
+            }
+        }     
+        
+        return null;
+        
+    }
+    
+        
+    /**
+     * Choose the first body writer provider that matches the requestedMimeType 
+     * for a sorted list of Entity providers
+     * Returns null if none is found.
+     * @param <T>
+     * @param messageBodyWriters
+     * @param type
+     * @param requestedMimeType
+     * @return
+     */
+    private <T> MessageBodyWriter<T> chooseMessageWriter(
+        List<MessageBodyWriter> writers, Class<T> type, MediaType mediaType) {
+        for (MessageBodyWriter<T> ep : writers) {
+            if (!ep.isWriteable(type)) {
+                continue;
+            }
+            List<MediaType> supportedMediaTypes =
+                JAXRSUtils.getProduceTypes(ep.getClass().getAnnotation(ProduceMime.class));
+            
+            List<MediaType> availableMimeTypes = 
+                JAXRSUtils.intersectMimeTypes(Collections.singletonList(mediaType),
+                                              supportedMediaTypes);
+
+            if (availableMimeTypes.size() != 0) {
+                return ep;
+            }
+        }     
+        
+        return null;
+        
+    }
+    
+    //TODO : also scan for the @Provider annotated implementations    
+    public boolean registerUserEntityProvider(Object o) {
+        setProviders(userMessageReaders, userMessageWriters, o);
+        return true;
+    }
+    
+    public boolean deregisterUserEntityProvider(Object o) {
+        boolean result = false;
+        if (o instanceof MessageBodyReader) {
+            result = userMessageReaders.remove(o);
+        }
+        return o instanceof MessageBodyReader 
+               ? result && userMessageWriters.remove(o) : result;
+                                               
+    }
+    
+    public List<MessageBodyReader> getDefaultMessageReaders() {
+        return defaultMessageReaders;
+    }
+
+    public List<MessageBodyWriter> getDefaultMessageWriters() {
+        return defaultMessageWriters;
+    }
+    
+    public List<MessageBodyReader> getUserMessageReaders() {
+        return userMessageReaders;
+    }
+    
+    public List<MessageBodyWriter> getUserMessageWriters() {
+        return userMessageWriters;
+    }
+    
+    public void clearUserMessageProviders() {
+        userMessageReaders.clear();
+        userMessageWriters.clear();
+    }
+
+    /**
+     * Use for injection of entityProviders
+     * @param entityProviders the entityProviders to set
+     */
+    public void setUserEntityProviders(List<?> userProviders) {
+        setProviders(userMessageReaders,
+                     userMessageWriters,
+                     userProviders.toArray());
+    }
+
+    private static class MessageBodyReaderComparator 
+        implements Comparator<MessageBodyReader> {
+        
+        public int compare(MessageBodyReader e1, MessageBodyReader e2) {
+            ConsumeMime c = e1.getClass().getAnnotation(ConsumeMime.class);
+            String[] mimeType1 = {"*/*"};
+            if (c != null) {
+                mimeType1 = c.value();               
+            }
+            
+            ConsumeMime c2 = e2.getClass().getAnnotation(ConsumeMime.class);
+            String[] mimeType2 = {"*/*"};
+            if (c2 != null) {
+                mimeType2 = c2.value();               
+            }
+    
+            return compareString(mimeType1[0], mimeType2[0]);
+            
+        }
+
+        private int compareString(String str1, String str2) {
+            if (!str1.startsWith("*/") && str2.startsWith("*/")) {
+                return -1;
+            } else if (str1.startsWith("*/") && !str2.startsWith("*/")) {
+                return 1;
+            } 
+            
+            return str1.compareTo(str2);
+        }
+    }
+    
+    private static class MessageBodyWriterComparator 
+        implements Comparator<MessageBodyWriter> {
+        
+        public int compare(MessageBodyWriter e1, MessageBodyWriter e2) {
+            ProduceMime c = e1.getClass().getAnnotation(ProduceMime.class);
+            String[] mimeType1 = {"*/*"};
+            if (c != null) {
+                mimeType1 = c.value();               
+            }
+            
+            ProduceMime c2 = e2.getClass().getAnnotation(ProduceMime.class);
+            String[] mimeType2 = {"*/*"};
+            if (c2 != null) {
+                mimeType2 = c2.value();               
+            }
+    
+            return compareString(mimeType1[0], mimeType2[0]);
+            
+        }
+        
+        private int compareString(String str1, String str2) {
+            if (!str1.startsWith("*/") && str2.startsWith("*/")) {
+                return -1;
+            } else if (str1.startsWith("*/") && !str2.startsWith("*/")) {
+                return 1;
+            } 
+            
+            return str1.compareTo(str2);
+        }
+    }
+}

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestImpl.java?rev=636586&r1=636585&r2=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestImpl.java Wed Mar 12 17:20:41 2008
@@ -21,59 +21,87 @@
 
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 import javax.ws.rs.core.EntityTag;
 import javax.ws.rs.core.Request;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
 import javax.ws.rs.core.Variant;
 
 import org.apache.cxf.message.Message;
 
 /**
- * This is actually a complete no-op implementation, null is a valid response,
- * by default all the precondions are met.
+ * TODO : deal with InvalidStateExceptions
  *
  */
 
 public class RequestImpl implements Request {
     
+    private final Message m;
+    
     public RequestImpl(Message m) {
-        // complete
+        this.m = m;
     }
 
-    public Response evaluatePreconditions(EntityTag eTag) {
-        // TODO Auto-generated method stub
-        return null;
-    }
+    
 
-    public Response evaluatePreconditions(Date lastModified) {
+    public Variant selectVariant(List<Variant> vars) throws IllegalArgumentException {
         // TODO Auto-generated method stub
         return null;
     }
 
-    public Response evaluatePreconditions(EntityTag eTag, Variant variant) {
-        // TODO Auto-generated method stub
-        return null;
-    }
 
-    public Response evaluatePreconditions(Date lastModified, Variant variant) {
-        // TODO Auto-generated method stub
-        return null;
-    }
 
-    public Response evaluatePreconditions(Date lastModified, EntityTag eTag) {
-        // TODO Auto-generated method stub
-        return null;
+    public ResponseBuilder evaluatePreconditions(EntityTag eTag) {
+        String ifMatch = getHeaderValue("If-Match");
+        
+        if (ifMatch == null || ifMatch.equals("*")) {
+            return null;
+        }
+        
+        try {
+            EntityTag requestTag = EntityTag.parse(ifMatch);
+            if (requestTag.equals(eTag) && !requestTag.isWeak()) {
+                return null;
+            }
+        } catch (IllegalArgumentException ex) {
+            // ignore
+        }
+        
+        return Response.status(412).tag(eTag);
     }
 
-    public Response evaluatePreconditions(Date lastModified, EntityTag eTag, Variant variant) {
-        // TODO Auto-generated method stub
+
+
+    public ResponseBuilder evaluatePreconditions(Date lastModified) {
+        // TODO : these dates wreck my head
         return null;
     }
 
-    public Variant selectVariant(List<Variant> arg0) throws IllegalArgumentException {
-        // TODO Auto-generated method stub
-        return null;
+
+
+    public ResponseBuilder evaluatePreconditions(Date lastModified, EntityTag eTag) {
+        ResponseBuilder rb = evaluatePreconditions(eTag);
+        if (rb != null) {
+            return rb;
+        }
+        return evaluatePreconditions(lastModified);
+                
+    }
+    
+    @SuppressWarnings("unchecked")
+    private String getHeaderValue(String name) {
+        Map<String, List<String>> headers = 
+            (Map<String, List<String>>)m.get(Message.PROTOCOL_HEADERS);
+        if (headers == null) {
+            return null;
+        }
+        List<String> values = headers.get(name);
+        if (values == null || values.size() == 0) {
+            return null;
+        }
+        return values.get(0);
     }
 
 }

Copied: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ResponseBuilderImpl.java (from r636320, incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BuilderImpl.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ResponseBuilderImpl.java?p2=incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ResponseBuilderImpl.java&p1=incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BuilderImpl.java&r1=636320&r2=636586&rev=636586&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BuilderImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ResponseBuilderImpl.java Wed Mar 12 17:20:41 2008
@@ -29,21 +29,26 @@
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.NewCookie;
 import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Builder;
+import javax.ws.rs.core.Response.ResponseBuilder;
 import javax.ws.rs.core.Variant;
-import javax.ws.rs.ext.HeaderProvider;
-import javax.ws.rs.ext.ProviderFactory;
 
 import org.apache.cxf.jaxrs.MetadataMap;
 
-public final class BuilderImpl extends Builder {
+public final class ResponseBuilderImpl extends ResponseBuilder {
     private int status = 200;
     private Object entity;
     private MultivaluedMap<String, Object> metadata = new MetadataMap<String, Object>();
 
-    public BuilderImpl() {
+    public ResponseBuilderImpl() {
     }
 
+    private ResponseBuilderImpl(ResponseBuilderImpl copy) {
+        status = copy.status;
+        if (entity != null) {
+            entity = copy.entity;
+            metadata.putAll(copy.metadata);
+        }
+    }
        
     public Response build() {
         ResponseImpl r = new ResponseImpl(status, entity);
@@ -54,88 +59,112 @@
         return r;
     }
 
-    public Response.Builder status(int s) {
+    public ResponseBuilder status(int s) {
         status = s;
         return this;
     }
 
-    public Response.Builder entity(Object e) {
+    public ResponseBuilder entity(Object e) {
         entity = e;
         return this;
     }
 
-    public Response.Builder type(MediaType type) {
+    public ResponseBuilder type(MediaType type) {
         return type(type.toString());
     }
 
-    public Response.Builder type(String type) {
+    public ResponseBuilder type(String type) {
         metadata.putSingle("Content-Type", type);
         return this;
     }
 
-    public Response.Builder language(String language) {
-        return null;
+    public ResponseBuilder language(String language) {
+        metadata.putSingle("Content-Language", language.toString());
+        return this;
     }
 
-    public Response.Builder location(URI location) {
+    public ResponseBuilder location(URI location) {
         metadata.putSingle("Location", location.toString());
         return this;
     }
 
-    public Response.Builder contentLocation(URI location) {
+    public ResponseBuilder contentLocation(URI location) {
         metadata.putSingle("Content-Location", location.toString());
         return this;
     }
 
-    public Response.Builder tag(EntityTag tag) {
+    public ResponseBuilder tag(EntityTag tag) {
         return tag(tag.toString());
     }
 
-    public Response.Builder tag(String tag) {
+    public ResponseBuilder tag(String tag) {
         metadata.putSingle("ETag", tag.toString());
         return this;
     }
 
-    public Response.Builder lastModified(Date lastModified) {
+    public ResponseBuilder lastModified(Date lastModified) {
         metadata.putSingle("Last-Modified", lastModified.toString());
         return this;
     }
 
-    public Response.Builder cacheControl(CacheControl cacheControl) {
+    public ResponseBuilder cacheControl(CacheControl cacheControl) {
         metadata.putSingle("Cache-Control", cacheControl.toString());
         return this;
     }
 
-    public Response.Builder cookie(NewCookie cookie) {
-        metadata.putSingle("Cookie", cookie.toString());
+    public ResponseBuilder cookie(NewCookie cookie) {
+        metadata.putSingle("Set-Cookie", cookie.toString());
         return this;
     }
-
+    
+    @Override
+    public ResponseBuilder cookie(NewCookie... cookies) {
+        for (NewCookie cookie : cookies) {
+            metadata.add("Set-Cookie", cookie.toString());
+        }
+        return this;
+    }
+    
     @SuppressWarnings("unchecked")
-    public Response.Builder header(String name, Object value) {
-        HeaderProvider hp = 
-            ProviderFactory.getInstance().createHeaderProvider(value.getClass());
-        metadata.putSingle(name, hp.toString(value));
+    public ResponseBuilder header(String name, Object value) {
+        metadata.add(name, value.toString());
         return this;
     }
 
     
     @Override
-    public Response.Builder variant(Variant variant) {
-        // TODO Auto-generated method stub
-        return null;
+    public ResponseBuilder variant(Variant variant) {
+        if (variant.getMediaType() != null) {
+            type(variant.getMediaType());
+        }
+        if (variant.getLanguage() != null) {
+            language(variant.getLanguage());
+        }
+        if (variant.getEncoding() != null) {
+            metadata.putSingle("Content-Encoding", variant.getEncoding());
+        }
+        return this;
     }
 
 
     @Override
-    public Builder variants(List<Variant> variants) {
-        // TODO Auto-generated method stub
-        return null;
+    public ResponseBuilder variants(List<Variant> variants) {
+        throw new UnsupportedOperationException("Only a single variant option is supported");
     }
     
+//  CHECKSTYLE:OFF
+    @Override
+    public ResponseBuilder clone() {
+        return new ResponseBuilderImpl(this);
+    }
+//  CHECKSTYLE:ON
+
+    
     private void reset() {
         metadata.clear();
         entity = null;
         status = 200;
     }
+
+    
 }



Mime
View raw message