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 2011/06/21 13:36:28 UTC
svn commit: r1137963 - in /cxf/branches/2.3.x-fixes: ./
rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/
rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/
rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/
Author: sergeyb
Date: Tue Jun 21 11:36:28 2011
New Revision: 1137963
URL: http://svn.apache.org/viewvc?rev=1137963&view=rev
Log:
Merged revisions 1137961 via svnmerge from
https://svn.apache.org/repos/asf/cxf/branches/2.4.x-fixes
................
r1137961 | sergeyb | 2011-06-21 12:32:53 +0100 (Tue, 21 Jun 2011) | 9 lines
Merged revisions 1137960 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1137960 | sergeyb | 2011-06-21 12:27:59 +0100 (Tue, 21 Jun 2011) | 1 line
[CXF-3608] Preferring more specific subresource locators to resource methods
........
................
Modified:
cxf/branches/2.3.x-fixes/ (props changed)
cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java
cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java
cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/TestResource.java
Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Tue Jun 21 11:36:28 2011
@@ -0,0 +1,2 @@
+/cxf/branches/2.4.x-fixes:1137961
+/cxf/trunk:1137960
Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java?rev=1137963&r1=1137962&r2=1137963&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java (original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java Tue Jun 21 11:36:28 2011
@@ -53,26 +53,24 @@ public class OperationResourceInfoCompar
}
}
- if (e1.getHttpMethod() != null && e2.getHttpMethod() == null
- || e1.getHttpMethod() == null && e2.getHttpMethod() != null) {
- // subresource method takes precedence over a subresource locator
- return e1.getHttpMethod() != null ? -1 : 1;
- }
-
if (headMethod) {
if (HEAD_METHOD.equals(e1.getHttpMethod())) {
return -1;
} else if (HEAD_METHOD.equals(e2.getHttpMethod())) {
return 1;
}
-
}
-
int result = URITemplate.compareTemplates(
e1.getURITemplate(),
e2.getURITemplate());
+ if (result == 0 && (e1.getHttpMethod() != null && e2.getHttpMethod() == null
+ || e1.getHttpMethod() == null && e2.getHttpMethod() != null)) {
+ // resource method takes precedence over a subresource locator
+ return e1.getHttpMethod() != null ? -1 : 1;
+ }
+
if (result == 0) {
result = JAXRSUtils.compareSortedMediaTypes(
Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java?rev=1137963&r1=1137962&r2=1137963&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java (original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/SelectMethodCandidatesTest.java Tue Jun 21 11:36:28 2011
@@ -211,6 +211,25 @@ public class SelectMethodCandidatesTest
@Test
public void testFindTargetSubResource() throws Exception {
+ doTestFindTargetSubResource("/1/2/3/d/resource", "resourceMethod");
+ }
+
+ @Test
+ public void testFindTargetSubResource2() throws Exception {
+ doTestFindTargetSubResource("/1/2/3/d/resource/sub", "subresource");
+ }
+
+ @Test
+ public void testFindTargetSubResource3() throws Exception {
+ doTestFindTargetSubResource("/1/2/3/d/resource2/2/2", "resourceMethod2");
+ }
+
+ @Test
+ public void testFindTargetSubResource4() throws Exception {
+ doTestFindTargetSubResource("/1/2/3/d/resource2/1/2", "subresource2");
+ }
+
+ public void doTestFindTargetSubResource(String path, String method) throws Exception {
JAXRSServiceFactoryBean sf = new JAXRSServiceFactoryBean();
sf.setResourceClasses(org.apache.cxf.jaxrs.resources.TestResource.class);
sf.create();
@@ -219,14 +238,14 @@ public class SelectMethodCandidatesTest
String acceptContentTypes = "text/xml,*/*";
MetadataMap<String, String> values = new MetadataMap<String, String>();
- ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, "/1/2/3/d/resource", values,
+ ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, path, values,
new MessageImpl());
OperationResourceInfo ori = JAXRSUtils.findTargetMethod(resource,
null,
"GET", values, contentTypes,
JAXRSUtils.sortMediaTypes(acceptContentTypes), true);
assertNotNull(ori);
- assertEquals("resourceMethod needs to be selected", "resourceMethod",
+ assertEquals("resourceMethod needs to be selected", method,
ori.getMethodToInvoke().getName());
}
Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/TestResource.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/TestResource.java?rev=1137963&r1=1137962&r2=1137963&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/TestResource.java (original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/TestResource.java Tue Jun 21 11:36:28 2011
@@ -42,6 +42,18 @@ public class TestResource {
return "";
}
+ @Path("/resource2/1/{b}")
+ public TestResource subresource2() {
+ return this;
+ }
+
+ @Path("/resource2/{a}/{b}")
+ @GET
+ @Produces("application/json")
+ public String resourceMethod2() {
+ return "";
+ }
+
@GET
@Produces("application/xml")
@Path("/resource1")