You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2013/04/30 13:32:22 UTC
svn commit: r1477566 - in /cxf/branches/2.7.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/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ systests/...
Author: sergeyb
Date: Tue Apr 30 11:32:21 2013
New Revision: 1477566
URL: http://svn.apache.org/r1477566
Log:
Merged revisions 1477528,1477532,1477553 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1477528 | sergeyb | 2013-04-30 11:13:43 +0100 (Tue, 30 Apr 2013) | 1 line
[CXF-4992] Fixing subresource proxies invoking on non-HTTP endpoints
........
r1477532 | sergeyb | 2013-04-30 11:17:45 +0100 (Tue, 30 Apr 2013) | 1 line
[CXF-4992] Test server flag update
........
r1477553 | sergeyb | 2013-04-30 12:06:05 +0100 (Tue, 30 Apr 2013) | 1 line
[CXF-4992] Minor cleanup
........
Modified:
cxf/branches/2.7.x-fixes/ (props changed)
cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java
cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSJmsTest.java
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java
Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Merged /cxf/trunk:r1477528-1477553
Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java?rev=1477566&r1=1477565&r2=1477566&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java (original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java Tue Apr 30 11:32:21 2013
@@ -46,14 +46,18 @@ public class LocalClientState implements
public LocalClientState(URI baseURI) {
this.baseURI = baseURI;
- String scheme = baseURI.getScheme();
- if (!StringUtils.isEmpty(scheme) && scheme.startsWith(HTTP_SCHEME)) {
+ if (isHttpScheme(baseURI)) {
this.currentBuilder = UriBuilder.fromUri(baseURI);
} else {
this.currentBuilder = UriBuilder.fromUri("/");
}
}
+ public LocalClientState(URI baseURI, URI currentURI) {
+ this.baseURI = baseURI;
+ this.currentBuilder = UriBuilder.fromUri(currentURI);
+ }
+
public LocalClientState(LocalClientState cs) {
this.requestHeaders = new MetadataMap<String, String>(cs.requestHeaders);
this.templates = cs.templates == null ? null : new MetadataMap<String, String>(cs.templates);
@@ -118,10 +122,15 @@ public class LocalClientState implements
templates = null;
}
- public ClientState newState(URI newBaseURI,
+ public ClientState newState(URI currentURI,
MultivaluedMap<String, String> headers,
MultivaluedMap<String, String> templatesMap) {
- ClientState state = new LocalClientState(newBaseURI);
+ ClientState state = null;
+ if (isHttpScheme(currentURI)) {
+ state = new LocalClientState(currentURI);
+ } else {
+ state = new LocalClientState(baseURI, currentURI);
+ }
if (headers != null) {
state.setRequestHeaders(headers);
}
@@ -135,4 +144,8 @@ public class LocalClientState implements
state.setTemplates(newTemplateParams);
return state;
}
+
+ private static boolean isHttpScheme(URI uri) {
+ return !StringUtils.isEmpty(uri.getScheme()) && uri.getScheme().startsWith(HTTP_SCHEME);
+ }
}
Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java?rev=1477566&r1=1477565&r2=1477566&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java (original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java Tue Apr 30 11:32:21 2013
@@ -101,12 +101,10 @@ public class ThreadLocalClientState impl
removeThreadLocalState(Thread.currentThread());
}
- public ClientState newState(URI baseURI,
+ public ClientState newState(URI currentURI,
MultivaluedMap<String, String> headers,
MultivaluedMap<String, String> templates) {
- LocalClientState ls = new LocalClientState(baseURI);
- ls.setRequestHeaders(headers);
- ls.setTemplates(templates);
+ LocalClientState ls = (LocalClientState)getState().newState(currentURI, headers, templates);
return new ThreadLocalClientState(ls, timeToKeepState);
}
Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=1477566&r1=1477565&r2=1477566&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java (original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java Tue Apr 30 11:32:21 2013
@@ -25,6 +25,7 @@ import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.ws.rs.HttpMethod;
import javax.ws.rs.InternalServerErrorException;
import javax.ws.rs.NotAcceptableException;
import javax.ws.rs.NotFoundException;
@@ -127,6 +128,8 @@ public class JAXRSInInterceptor extends
if (JAXRSUtils.runContainerRequestFilters(providerFactory, message, true, null)) {
return;
}
+ String httpMethod = HttpUtils.getProtocolHeader(message, Message.HTTP_REQUEST_METHOD,
+ HttpMethod.POST, true);
String requestContentType = (String)message.get(Message.CONTENT_TYPE);
if (requestContentType == null) {
@@ -171,7 +174,6 @@ public class JAXRSInInterceptor extends
message.getExchange().put(JAXRSUtils.ROOT_RESOURCE_CLASS, resource);
- String httpMethod = HttpUtils.getProtocolHeader(message, Message.HTTP_REQUEST_METHOD, "POST");
OperationResourceInfo ori = null;
boolean operChecked = false;
Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java?rev=1477566&r1=1477565&r2=1477566&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java (original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java Tue Apr 30 11:32:21 2013
@@ -322,9 +322,16 @@ public final class HttpUtils {
}
public static String getProtocolHeader(Message m, String name, String defaultValue) {
+ return getProtocolHeader(m, name, defaultValue, false);
+ }
+
+ public static String getProtocolHeader(Message m, String name, String defaultValue, boolean setOnMessage) {
String value = (String)m.get(name);
if (value == null) {
value = new HttpHeadersImpl(m).getRequestHeaders().getFirst(name);
+ if (value != null && setOnMessage) {
+ m.put(name, value);
+ }
}
return value == null ? defaultValue : value;
}
Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSJmsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSJmsTest.java?rev=1477566&r1=1477565&r2=1477566&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSJmsTest.java (original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSJmsTest.java Tue Apr 30 11:32:21 2013
@@ -125,6 +125,22 @@ public class JAXRSJmsTest extends Abstra
}
@Test
+ public void testGetBookFromSubresourceProxyClient() throws Exception {
+ // setup the the client
+ String endpointAddressUrlEncoded = "jms:jndi:dynamicQueues/test.jmstransport.text"
+ + "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+ + "&replyToName=dynamicQueues/test.jmstransport.response"
+ + "&jndiURL=tcp://localhost:" + JMS_PORT
+ + "&jndiConnectionFactoryName=ConnectionFactory";
+
+ JMSBookStore client = JAXRSClientFactory.create(endpointAddressUrlEncoded, JMSBookStore.class);
+ Book bookProxy = client.getBookSubResource("123");
+ Book book = bookProxy.retrieveState();
+ assertEquals("Get a wrong response code.", 200, WebClient.client(bookProxy).getResponse().getStatus());
+ assertEquals("Get a wrong book id.", 123, book.getId());
+ }
+
+ @Test
public void testGetBookFromProxyClientWithQuery() throws Exception {
// setup the the client
String endpointAddressUrlEncoded = "jms:jndi:dynamicQueues/test.jmstransport.text"
Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java?rev=1477566&r1=1477565&r2=1477566&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java (original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java Tue Apr 30 11:32:21 2013
@@ -70,6 +70,18 @@ public class JAXRSLocalTransportTest ext
}
@Test
+ public void testSubresourceProxyDirectDispatchGet() throws Exception {
+ BookStore localProxy =
+ JAXRSClientFactory.create("local://books", BookStore.class);
+
+ WebClient.getConfig(localProxy).getRequestContext().put(LocalConduit.DIRECT_DISPATCH, Boolean.TRUE);
+
+ Book bookSubProxy = localProxy.getBookSubResource("123");
+ Book book = bookSubProxy.retrieveState();
+ assertEquals(123L, book.getId());
+ }
+
+ @Test
public void testProxyDirectDispatchPostWithGzip() throws Exception {
BookStore localProxy =
JAXRSClientFactory.create("local://books", BookStore.class);
Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java?rev=1477566&r1=1477565&r2=1477566&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java (original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java Tue Apr 30 11:32:21 2013
@@ -84,6 +84,11 @@ public class JMSBookStore {
return doGetBook(id);
}
+ @Path("/booksubresource/{bookId}/")
+ public Book getBookSubResource(@PathParam("bookId") String id) throws BookNotFoundFault {
+ return doGetBook(id);
+ }
+
private Book doGetBook(String id) throws BookNotFoundFault {
Book book = books.get(Long.parseLong(id));
if (book != null) {