cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r891824 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ rt/management/src/main/java/org/apache/cxf/management/interceptor/ rt/...
Date Thu, 17 Dec 2009 18:27:50 GMT
Author: sergeyb
Date: Thu Dec 17 18:27:49 2009
New Revision: 891824

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

........
  r891817 | sergeyb | 2009-12-17 18:17:30 +0000 (Thu, 17 Dec 2009) | 1 line
  
  CXF-2585,CXF-2541: JMX support for JAXRS proxies and webclients, and a minor fix for proxies
to support empty posts   
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/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/client/WebClient.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/management/src/main/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTimeInterceptor.java
    cxf/branches/2.2.x-fixes/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor2Test.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 (original)
+++ svn:mergeinfo Thu Dec 17 18:27:49 2009
@@ -1 +1 @@
-/cxf/trunk:891375-891393,891452
+/cxf/trunk:891375-891393,891452,891817

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

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/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=891824&r1=891823&r2=891824&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
Thu Dec 17 18:27:49 2009
@@ -67,6 +67,7 @@
 import org.apache.cxf.phase.PhaseChainCache;
 import org.apache.cxf.phase.PhaseInterceptorChain;
 import org.apache.cxf.phase.PhaseManager;
+import org.apache.cxf.service.Service;
 import org.apache.cxf.transport.ConduitInitiatorManager;
 import org.apache.cxf.transport.MessageObserver;
 import org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory;
@@ -574,8 +575,19 @@
         
         //setup conduit selector
         prepareConduitSelector(m);
+        exchange.put(Service.class, cfg.getConduitSelector().getEndpoint().getService());
         
         return m;
     }
 
+    protected void setEmptyRequestProperty(Message outMessage, String httpMethod) {
+        if ("POST".equals(httpMethod)) {
+            outMessage.put("org.apache.cxf.post.empty", true);
+        }
+    }
+    
+    protected void setPlainOperationNameProperty(Message outMessage, String name) {
+        outMessage.put("org.apache.cxf.resource.operation.name", name);
+    }
+    
 }

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=891824&r1=891823&r2=891824&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
Thu Dec 17 18:27:49 2009
@@ -413,15 +413,17 @@
             }
             outMessage.put(URITemplate.TEMPLATE_PARAMETERS, templatesMap);
         }
-        
+        outMessage.setContent(OperationResourceInfo.class, ori);
+        setPlainOperationNameProperty(outMessage, ori.getMethodToInvoke().getName());
         boolean isForm = types.containsKey(ParameterType.FORM);
         if (bodyIndex != -1 || isForm) {
-            outMessage.setContent(OperationResourceInfo.class, ori);
             outMessage.put("BODY_INDEX", bodyIndex);
             Object body = isForm ? handleForm(types, params) : params[bodyIndex];
             MessageContentsList contents = new MessageContentsList(new Object[]{body});
             outMessage.setContent(List.class, contents);
             outMessage.getInterceptorChain().add(new BodyWriter());
+        } else {
+            setEmptyRequestProperty(outMessage, ori.getHttpMethod());
         }
         
         // execute chain    

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=891824&r1=891823&r2=891824&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
Thu Dec 17 18:27:49 2009
@@ -40,6 +40,7 @@
 import javax.ws.rs.core.Response.ResponseBuilder;
 import javax.ws.rs.core.UriBuilder;
 
+
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.helpers.CastUtils;
@@ -559,15 +560,17 @@
     protected Response doChainedInvocation(String httpMethod, 
         MultivaluedMap<String, String> headers, Object body, Class<?> responseClass,
Type genericType) {
         
-        Message m = createMessage(httpMethod, headers, getCurrentURI());
+        URI uri = getCurrentURI();
+        Message m = createMessage(httpMethod, headers, uri);
         m.put(URITemplate.TEMPLATE_PARAMETERS, templates);
         if (body != null) {
             MessageContentsList contents = new MessageContentsList(body);
             m.setContent(List.class, contents);
             m.getInterceptorChain().add(new BodyWriter());
-        } else if ("POST".equals(httpMethod)) {
-            m.put("org.apache.cxf.post.empty", "true");
+        } else {
+            setEmptyRequestProperty(m, httpMethod);
         }
+        setPlainOperationNameProperty(m, httpMethod + ":" + uri.toString());
         
         try {
             m.getInterceptorChain().doIntercept(m);

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=891824&r1=891823&r2=891824&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
Thu Dec 17 18:27:49 2009
@@ -209,7 +209,7 @@
                                       MultivaluedMap<String, String> values) {
         message.getExchange().put(OperationResourceInfo.class, ori);
         message.put(URITemplate.TEMPLATE_PARAMETERS, values);
-        message.getExchange().put("org.apache.cxf.management.operation.name", 
+        message.getExchange().put("org.apache.cxf.resource.operation.name", 
                                   ori.getMethodToInvoke().getName());
     }
 }

Modified: cxf/branches/2.2.x-fixes/rt/management/src/main/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTimeInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/management/src/main/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTimeInterceptor.java?rev=891824&r1=891823&r2=891824&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/management/src/main/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTimeInterceptor.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/management/src/main/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTimeInterceptor.java
Thu Dec 17 18:27:49 2009
@@ -112,7 +112,7 @@
             String operationName = opInfo == null ? null : "\"" + opInfo.getName().getLocalPart()
+ "\"";
             
             if (operationName == null) {
-                Object nameProperty = ex.get("org.apache.cxf.management.operation.name");
+                Object nameProperty = ex.get("org.apache.cxf.resource.operation.name");
                 if (nameProperty != null) {
                     operationName = "\"" + nameProperty.toString() + "\"";
                 }

Modified: cxf/branches/2.2.x-fixes/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor2Test.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor2Test.java?rev=891824&r1=891823&r2=891824&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor2Test.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor2Test.java
Thu Dec 17 18:27:49 2009
@@ -170,7 +170,7 @@
     @Override
     protected void setupOperationForMessage() {
         EasyMock.expect(exchange.get(OperationInfo.class)).andReturn(null);
-        EasyMock.expect(exchange.get("org.apache.cxf.management.operation.name"))
+        EasyMock.expect(exchange.get("org.apache.cxf.resource.operation.name"))
             .andReturn(OPERATION_NAME.getLocalPart());
     }
 }

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=891824&r1=891823&r2=891824&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
Thu Dec 17 18:27:49 2009
@@ -39,11 +39,17 @@
 import org.apache.commons.httpclient.methods.PutMethod;
 import org.apache.commons.httpclient.methods.RequestEntity;
 import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
+import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.ext.xml.XMLSource;
+import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.provider.XSLTJaxbProvider;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 
 import org.junit.BeforeClass;
@@ -215,6 +221,16 @@
     }
     
     @Test
+    public void testEmptyPostProxy() throws Exception {
+        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); 
+        bean.setAddress("http://localhost:9080");
+        bean.setResourceClass(BookStore.class);
+        BookStore store = bean.create(BookStore.class);
+        store.emptypost();
+        assertEquals(204, WebClient.client(store).getResponse().getStatus());
+    }
+    
+    @Test
     public void testGetBookByEncodedQuery() throws Exception {
         getAndCompareAsStrings("http://localhost:9080/bookstore/bookquery?"
                                + "urlid=http%3A%2F%2Ftest.com%2Frss%2F123",
@@ -1106,4 +1122,22 @@
         return bos.getOut().toString();        
     }
 
+    @Ignore
+    public class EmptyPostOutInterceptor extends AbstractPhaseInterceptor<Message>
{
+                
+        public EmptyPostOutInterceptor() {
+             super(Phase.PRE_MARSHAL);
+            
+        } 
+
+        public void handleMessage(Message message) throws Fault {
+            OperationResourceInfo ori = message.getContent(OperationResourceInfo.class);
+            if (ori != null && ori.getMethodToInvoke().getName().equals("emptypost"))
{
+                message.put("org.apache.cxf.post.empty", true);
+            }
+        }
+        
+        
+
+    }
 }



Mime
View raw message