cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r738863 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ rt/frontend/jaxrs/src/main/java/org/apache...
Date Thu, 29 Jan 2009 14:14:20 GMT
Author: sergeyb
Date: Thu Jan 29 14:14:20 2009
New Revision: 738863

URL: http://svn.apache.org/viewvc?rev=738863&view=rev
Log:
CXF-1982 : saving the real resource object class on the invocation stack

Added:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/MethodInvocationInfo.java
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoStack.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java?rev=738863&r1=738862&r2=738863&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java Thu Jan
29 14:14:20 2009
@@ -39,6 +39,7 @@
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.jaxrs.model.MethodInvocationInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfoStack;
 import org.apache.cxf.jaxrs.model.URITemplate;
@@ -82,11 +83,11 @@
         }
 
         OperationResourceInfo ori = exchange.get(OperationResourceInfo.class);
-        pushOntoStack(ori, exchange.getInMessage());
-
         ClassResourceInfo cri = ori.getClassResourceInfo();
+        
         Object resourceObject = getServiceObject(exchange, resources);
-
+        pushOntoStack(ori, ClassHelper.getRealClass(resourceObject), exchange.getInMessage());
+                
         Method methodToInvoke = InjectionUtils.checkProxy(
              cri.getMethodDispatcher().getMethod(ori), resourceObject);
 
@@ -235,12 +236,12 @@
         return result;
     }
 
-    private void pushOntoStack(OperationResourceInfo ori, Message msg) {
+    private void pushOntoStack(OperationResourceInfo ori, Class<?> realClass, Message
msg) {
         OperationResourceInfoStack stack = msg.get(OperationResourceInfoStack.class);
         if (stack == null) {
             stack = new OperationResourceInfoStack();
             msg.put(OperationResourceInfoStack.class, stack);
         }
-        stack.push(ori);
+        stack.push(new MethodInvocationInfo(ori, realClass));
     }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java?rev=738863&r1=738862&r2=738863&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java Thu
Jan 29 14:14:20 2009
@@ -33,6 +33,7 @@
 import javax.ws.rs.core.UriInfo;
 
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.jaxrs.model.MethodInvocationInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfoStack;
 import org.apache.cxf.jaxrs.model.URITemplate;
@@ -130,8 +131,8 @@
     public List<Object> getMatchedResources() {
         if (stack != null) {
             List<Object> resources = new ArrayList<Object>(stack.size());
-            for (OperationResourceInfo ori : stack) {
-                resources.add(ori.getClassResourceInfo().getResourceClass());
+            for (MethodInvocationInfo invocation : stack) {
+                resources.add(invocation.getRealClass());
             }
             return resources;
         }
@@ -147,7 +148,8 @@
         if (stack != null) {
             List<String> uris = new ArrayList<String>(stack.size());
             String sum = "";
-            for (OperationResourceInfo ori : stack) {
+            for (MethodInvocationInfo invocation : stack) {
+                OperationResourceInfo ori = invocation.getMethodInfo();
                 Path[] paths = {
                     (Path)AnnotationUtils.getClassAnnotation(ori.getClassResourceInfo().getResourceClass(),
                                                              Path.class),

Added: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/MethodInvocationInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/MethodInvocationInfo.java?rev=738863&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/MethodInvocationInfo.java
(added)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/MethodInvocationInfo.java
Thu Jan 29 14:14:20 2009
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxrs.model;
+
+/**
+ * A pair of {@link OperationResourceInfo} representing a resource method being invoked 
+ * and actual {@link Class} of the object this method is invoked upon.
+ */
+public class MethodInvocationInfo {
+    private OperationResourceInfo ori;
+    private Class<?> realClass;
+    
+    public MethodInvocationInfo(OperationResourceInfo ori, Class<?> realClass) {
+        this.ori = ori;
+        this.realClass = realClass;
+    }
+    
+    public OperationResourceInfo getMethodInfo() {
+        return ori;
+    }
+    
+    public Class<?> getRealClass() {
+        return realClass;
+    }
+}

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoStack.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoStack.java?rev=738863&r1=738862&r2=738863&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoStack.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoStack.java
Thu Jan 29 14:14:20 2009
@@ -21,13 +21,13 @@
 import java.util.Stack;
 
 /**
- * Stack of {@link OperationResourceInfo} representing resources path when JAX-RS invocation
looks for target.
+ * Stack of {@link MethodInvocationInfo} representing resources path when JAX-RS invocation
looks for target.
  * Used to evaluate {@link UriInfo#getMatchedResources() UriInfo.getMatched*} methods when
sub-locators are
  * involved.
  * <p>
  * Stack elements are placed in order same as java stacktrace - root resource on bottom,
recent resource on
  * top.
  */
-public class OperationResourceInfoStack extends Stack<OperationResourceInfo> {
+public class OperationResourceInfoStack extends Stack<MethodInvocationInfo> {
     private static final long serialVersionUID = 1L;
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java?rev=738863&r1=738862&r2=738863&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java
Thu Jan 29 14:14:20 2009
@@ -79,6 +79,7 @@
                                                        id.value(),
                                                        mt.toString());
             LOG.warning(errorMsg.toString());
+            return null;
             
         }
         

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=738863&r1=738862&r2=738863&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Thu Jan 29 14:14:20 2009
@@ -690,6 +690,16 @@
                       + "class org.apache.cxf.systest.jaxrs.Chapter]", 
                       "text/plain", 200);
     }
+    
+    @Test
+    public void testUriInfoMatchedResourcesWithObject() throws Exception {
+        getAndCompare("http://localhost:9080/bookstore/"
+                      + "booksubresource/123/chaptersobject/sub/1/matched-resources", 
+                      "[class org.apache.cxf.systest.jaxrs.BookStore, " 
+                      + "class org.apache.cxf.systest.jaxrs.Book, "
+                      + "class org.apache.cxf.systest.jaxrs.Chapter]", 
+                      "text/plain", 200);
+    }
 
     @Test
     public void testUriInfoMatchedUrisDecode() throws Exception {



Mime
View raw message