cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r785734 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/interceptor/ main/java/org/apache/cxf/jaxrs/model/wadl/ main/java/org/apache/cxf/jaxrs/provider/ test/java/org/apache/cxf/jaxrs/model/wadl/
Date Wed, 17 Jun 2009 17:17:44 GMT
Author: sergeyb
Date: Wed Jun 17 17:17:44 2009
New Revision: 785734

URL: http://svn.apache.org/viewvc?rev=785734&view=rev
Log:
JAXRS: retrieval of wadl, just to facilitate DOSGI testing, wadl support is still primitive

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=785734&r1=785733&r2=785734&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
Wed Jun 17 17:17:44 2009
@@ -126,10 +126,11 @@
         String httpMethod = (String)message.get(Message.HTTP_REQUEST_METHOD);
         OperationResourceInfo ori = null;     
         
+        boolean operChecked = false;
         List<ProviderInfo<RequestHandler>> shs = ProviderFactory.getInstance(message).getRequestHandlers();
         for (ProviderInfo<RequestHandler> sh : shs) {
             String newAcceptTypes = (String)message.get(Message.ACCEPT_CONTENT_TYPE);
-            if (!acceptTypes.equals(newAcceptTypes) || ori == null) {
+            if (!acceptTypes.equals(newAcceptTypes) || (ori == null && !operChecked))
{
                 acceptTypes = newAcceptTypes;
                 acceptContentTypes = JAXRSUtils.sortMediaTypes(newAcceptTypes);
                 message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes);
@@ -143,17 +144,11 @@
                     ori = JAXRSUtils.findTargetMethod(resource, 
                         values.getFirst(URITemplate.FINAL_MATCH_GROUP), httpMethod, values,

                         requestContentType, acceptContentTypes);
+                    message.getExchange().put(OperationResourceInfo.class, ori);
                 } catch (WebApplicationException ex) {
-                    if (ex.getResponse() != null && ex.getResponse().getStatus()
== 405 
-                        && "OPTIONS".equalsIgnoreCase(httpMethod)) {
-                        Response response = JAXRSUtils.createResponseBuilder(resource, 200,
true).build();
-                        message.getExchange().put(Response.class, response);
-                        return;
-                    } else {
-                        throw ex;
-                    }
+                    operChecked = true;
                 }
-                message.getExchange().put(OperationResourceInfo.class, ori);
+                
             }
             Response response = sh.getProvider().handleRequest(message, resource);
             if (response != null) {
@@ -173,9 +168,20 @@
                                                           rawPath, 
                                                           values);
             }
-            ori = JAXRSUtils.findTargetMethod(resource, values.getFirst(URITemplate.FINAL_MATCH_GROUP),

-                                              httpMethod, values, requestContentType, acceptContentTypes);
-            message.getExchange().put(OperationResourceInfo.class, ori);
+            try {                
+                ori = JAXRSUtils.findTargetMethod(resource, values.getFirst(URITemplate.FINAL_MATCH_GROUP),

+                                            httpMethod, values, requestContentType, acceptContentTypes);
+                message.getExchange().put(OperationResourceInfo.class, ori);
+            } catch (WebApplicationException ex) {
+                if (ex.getResponse() != null && ex.getResponse().getStatus() == 405

+                    && "OPTIONS".equalsIgnoreCase(httpMethod)) {
+                    Response response = JAXRSUtils.createResponseBuilder(resource, 200, true).build();
+                    message.getExchange().put(Response.class, response);
+                    return;
+                } else {
+                    throw ex;
+                }
+            }
         }
 
         

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=785734&r1=785733&r2=785734&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
Wed Jun 17 17:17:44 2009
@@ -134,7 +134,7 @@
         int status = response.getStatus();
         Object responseObj = response.getEntity();
         if (status == 200 && !isResponseNull(responseObj) && firstTry 
-            && JAXRSUtils.headMethodPossible(ori.getHttpMethod(), 
+            && ori != null && JAXRSUtils.headMethodPossible(ori.getHttpMethod(),

                 (String)message.getExchange().getInMessage().get(Message.HTTP_REQUEST_METHOD)))
{
             LOG.info(new org.apache.cxf.common.i18n.Message("HEAD_WITHOUT_ENTITY", BUNDLE).toString());
             responseObj = null;

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=785734&r1=785733&r2=785734&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
Wed Jun 17 17:17:44 2009
@@ -49,6 +49,10 @@
     
     public Response handleRequest(Message m, ClassResourceInfo resource) {
         
+        if (!"GET".equals(m.get(Message.HTTP_REQUEST_METHOD))) {
+            return null;
+        }
+        
         UriInfo ui = new UriInfoImpl(m);
         if (!ui.getQueryParameters().containsKey(WADL_QUERY)) {
             return null;

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=785734&r1=785733&r2=785734&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
Wed Jun 17 17:17:44 2009
@@ -46,6 +46,7 @@
 import org.apache.cxf.jaxrs.impl.RequestPreprocessor;
 import org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper;
 import org.apache.cxf.jaxrs.model.ProviderInfo;
+import org.apache.cxf.jaxrs.model.wadl.WadlGenerator;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Message;
@@ -77,7 +78,8 @@
                                     new PrimitiveTextProvider(),
                                     new MultipartProvider(),
                                     new WebApplicationExceptionMapper(),
-                                    new SystemQueryHandler());
+                                    new SystemQueryHandler(),
+                                    new WadlGenerator());
     }
     
     private List<ProviderInfo<MessageBodyReader>> messageReaders = 

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java?rev=785734&r1=785733&r2=785734&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
Wed Jun 17 17:17:44 2009
@@ -87,6 +87,7 @@
         EasyMock.expectLastCall().andReturn(epr).anyTimes();
         m.put(Message.REQUEST_URI, pathInfo);
         m.put(Message.QUERY_STRING, query);
+        m.put(Message.HTTP_REQUEST_METHOD, "GET");
         control.replay();
         return m;
     }



Mime
View raw message