cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r904445 - in /cxf/branches/2.2.x-fixes: ./ api/src/main/java/org/apache/cxf/message/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ rt/frontend/jaxrs/src/main/java/org/apac...
Date Fri, 29 Jan 2010 10:08:43 GMT
Author: sergeyb
Date: Fri Jan 29 10:08:35 2010
New Revision: 904445

URL: http://svn.apache.org/viewvc?rev=904445&view=rev
Log:
Merged revisions 904195 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r904195 | sergeyb | 2010-01-28 18:12:00 +0000 (Thu, 28 Jan 2010) | 1 line
  
  JAXRS : support for oneway invocations
........

Added:
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/Oneway.java
      - copied unchanged from r904195, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/Oneway.java
Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/message/Message.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:904195

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/message/Message.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/message/Message.java?rev=904445&r1=904444&r2=904445&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/message/Message.java (original)
+++ cxf/branches/2.2.x-fixes/api/src/main/java/org/apache/cxf/message/Message.java Fri Jan
29 10:08:35 2010
@@ -67,7 +67,7 @@
      */
     String DECOUPLED_CHANNEL_MESSAGE = "decoupled.channel.message";
     String PARTIAL_RESPONSE_MESSAGE = "org.apache.cxf.partial.response";
-    String ONE_WAY_MESSAGE = "OnewayMessage";
+    String ONE_WAY_REQUEST = "OnewayRequest";
     
     String PROTOCOL_HEADERS = Message.class.getName() + ".PROTOCOL_HEADERS";
     String RESPONSE_CODE = Message.class.getName() + ".RESPONSE_CODE";

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java?rev=904445&r1=904444&r2=904445&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
Fri Jan 29 10:08:35 2010
@@ -81,6 +81,9 @@
         try {
             return invoke(exchange, request, serviceObject);
         } finally {
+            if (exchange.isOneWay()) {
+                ProviderFactory.getInstance(exchange.getInMessage()).clearThreadLocalProxies();
+            }
             if (!isServiceObjectRequestScope(exchange.getInMessage())) {
                 provider.releaseInstance(exchange.getInMessage(), serviceObject);
             } else {

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=904445&r1=904444&r2=904445&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
Fri Jan 29 10:08:35 2010
@@ -557,7 +557,7 @@
         exchange.put(Bus.class, cfg.getBus());
         exchange.put(MessageObserver.class, new ClientMessageObserver(cfg));
         exchange.put(Endpoint.class, cfg.getConduitSelector().getEndpoint());
-        exchange.setOneWay(false);
+        exchange.setOneWay("true".equals(headers.getFirst(Message.ONE_WAY_REQUEST)));
         m.setExchange(exchange);
         
         PhaseInterceptorChain chain = setupOutInterceptorChain(cfg);

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=904445&r1=904444&r2=904445&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
Fri Jan 29 10:08:35 2010
@@ -403,6 +403,7 @@
                           MultivaluedMap<ParameterType, Parameter> types,
                           List<Object> pathParams) throws Throwable {
         Message outMessage = createMessage(ori.getHttpMethod(), headers, uri);
+        outMessage.getExchange().setOneWay(ori.isOneway());
         if (pathParams.size() != 0) { 
             List<String> vars = ori.getURITemplate().getVariables();
             MultivaluedMap<String, String> templatesMap =  new MetadataMap<String,
String>(vars.size());

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=904445&r1=904444&r2=904445&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
Fri Jan 29 10:08:35 2010
@@ -173,7 +173,7 @@
                     ori = JAXRSUtils.findTargetMethod(resource, 
                         message, httpMethod, values, 
                         requestContentType, acceptContentTypes, false);
-                    setMessageProperties(message, ori, values, resources.size());
+                    setExchangeProperties(message, ori, values, resources.size());
                 } catch (WebApplicationException ex) {
                     operChecked = true;
                 }
@@ -203,7 +203,7 @@
             try {                
                 ori = JAXRSUtils.findTargetMethod(resource, message, 
                                             httpMethod, values, requestContentType, acceptContentTypes,
true);
-                setMessageProperties(message, ori, values, resources.size());
+                setExchangeProperties(message, ori, values, resources.size());
             } catch (WebApplicationException ex) {
                 if (ex.getResponse() != null && ex.getResponse().getStatus() == 405

                     && "OPTIONS".equalsIgnoreCase(httpMethod)) {
@@ -224,14 +224,14 @@
 
             LOG.fine("Found operation: " + ori.getMethodToInvoke().getName());
         }
-        setMessageProperties(message, ori, values, resources.size());  
+        setExchangeProperties(message, ori, values, resources.size());  
       
         //Process parameters
         List<Object> params = JAXRSUtils.processParameters(ori, values, message);
         message.setContent(List.class, params);
     }
     
-    private void setMessageProperties(Message message, OperationResourceInfo ori, 
+    private void setExchangeProperties(Message message, OperationResourceInfo ori, 
                                       MultivaluedMap<String, String> values,
                                       int numberOfResources) {
         message.getExchange().put(OperationResourceInfo.class, ori);
@@ -244,7 +244,8 @@
         }
         message.getExchange().put("org.apache.cxf.resource.operation.name", plainOperationName);
         
-        message.getExchange().setOneWay(
-            MessageUtils.isTrue(HttpUtils.getProtocolHeader(message, Message.ONE_WAY_MESSAGE,
null)));
+        boolean oneway = ori.isOneway() 
+            || MessageUtils.isTrue(HttpUtils.getProtocolHeader(message, Message.ONE_WAY_REQUEST,
null));
+        message.getExchange().setOneWay(oneway);
     }
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java?rev=904445&r1=904444&r2=904445&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
Fri Jan 29 10:08:35 2010
@@ -28,6 +28,7 @@
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 
+import org.apache.cxf.jaxrs.ext.Oneway;
 import org.apache.cxf.jaxrs.utils.AnnotationUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
@@ -43,6 +44,7 @@
     private boolean encoded;
     private String defaultParamValue;
     private List<Parameter> parameters;
+    private boolean oneway; 
 
     public OperationResourceInfo(Method mInvoke, ClassResourceInfo cri) {
         this(mInvoke, mInvoke, cri);
@@ -58,6 +60,7 @@
         this.encoded = ori.encoded;
         this.defaultParamValue = ori.defaultParamValue;
         this.parameters = ori.parameters;
+        this.oneway = ori.oneway;
         this.classResourceInfo = cri;
     }
     
@@ -71,6 +74,7 @@
         checkMediaTypes(null, null);
         checkEncoded();
         checkDefaultParameterValue();
+        checkOneway();
     }
     
     public OperationResourceInfo(Method m, 
@@ -89,6 +93,16 @@
         parameters = params;
     }
 
+    private void checkOneway() {
+        if (annotatedMethod != null) {
+            oneway = AnnotationUtils.getAnnotation(annotatedMethod.getAnnotations(), Oneway.class)
!= null;
+        }
+    }
+
+    public boolean isOneway() {
+        return oneway;
+    }
+    
     public List<Parameter> getParameters() {
         return parameters;
     }

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=904445&r1=904444&r2=904445&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
Fri Jan 29 10:08:35 2010
@@ -65,6 +65,7 @@
 import javax.xml.transform.dom.DOMSource;
 
 import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.jaxrs.ext.Oneway;
 import org.apache.cxf.phase.PhaseInterceptorChain;
 
 @Path("/bookstore")
@@ -489,6 +490,15 @@
     }
     
     @POST
+    @Path("/oneway")
+    @Oneway
+    public void onewayRequest() {
+        if (!PhaseInterceptorChain.getCurrentMessage().getExchange().isOneWay()) {
+            throw new WebApplicationException();
+        }
+    }
+    
+    @POST
     @Path("/books/customstatus")
     @Produces("text/xml")
     @Consumes("text/xml")

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=904445&r1=904444&r2=904445&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Fri Jan 29 10:08:35 2010
@@ -61,6 +61,20 @@
     
     
     @Test
+    public void testOnewayWebClient() throws Exception {
+        WebClient client = WebClient.create("http://localhost:9080/bookstore/oneway");
+        Response r = client.header("OnewayRequest", "true").post(null);
+        assertEquals(202, r.getStatus());
+    }
+    
+    @Test
+    public void testOnewayProxy() throws Exception {
+        BookStore proxy = JAXRSClientFactory.create("http://localhost:9080", BookStore.class);
+        proxy.onewayRequest();
+        assertEquals(202, WebClient.client(proxy).getResponse().getStatus());
+    }
+    
+    @Test
     public void testPropogateException() throws Exception {
         getAndCompare("http://localhost:9080/bookstore/propogateexception",
                       "", "application/xml", 500);



Mime
View raw message