You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2010/05/27 18:44:29 UTC

svn commit: r948905 - in /cxf/branches/2.2.x-fixes: ./ common/common/src/main/java/org/apache/cxf/common/injection/ common/common/src/main/java/org/apache/cxf/common/util/

Author: dkulp
Date: Thu May 27 16:44:29 2010
New Revision: 948905

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

........
  r948877 | dkulp | 2010-05-27 12:21:17 -0400 (Thu, 27 May 2010) | 1 line
  
  [CXF-2829] When injecting fields, get the real object out of the proxy.
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java
    cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/ClassHelper.java
    cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java

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

Modified: cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java?rev=948905&r1=948904&r2=948905&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java (original)
+++ cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java Thu May 27 16:44:29 2010
@@ -38,6 +38,7 @@ import javax.annotation.Resources;
 import org.apache.cxf.common.annotation.AbstractAnnotationVisitor;
 import org.apache.cxf.common.annotation.AnnotationProcessor;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.ClassHelper;
 import org.apache.cxf.resource.ResourceManager;
 import org.apache.cxf.resource.ResourceResolver;
 
@@ -280,7 +281,7 @@ public class ResourceInjector extends Ab
         try {
             if (field.getType().isAssignableFrom(resource.getClass())) { 
                 field.setAccessible(true); 
-                field.set(getTarget(), resource);
+                field.set(ClassHelper.getRealObject(getTarget()), resource);
             }
         } catch (IllegalAccessException e) { 
             e.printStackTrace();

Modified: cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/ClassHelper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/ClassHelper.java?rev=948905&r1=948904&r2=948905&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/ClassHelper.java (original)
+++ cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/ClassHelper.java Thu May 27 16:44:29 2010
@@ -45,6 +45,10 @@ public class ClassHelper {
     protected Class getRealClassFromClassInternal(Class cls) {
         return cls;
     }
+    protected Object getRealObjectInternal(Object o) {
+        return o;
+    }
+    
     
     
     public static Class getRealClass(Object o) {
@@ -54,4 +58,10 @@ public class ClassHelper {
     public static Class getRealClassFromClass(Class cls) {
         return HELPER.getRealClassFromClassInternal(cls);
     }
+    
+    public static Object getRealObject(Object o) {
+        return HELPER.getRealObjectInternal(o);
+    }
+
+    
 }

Modified: cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java?rev=948905&r1=948904&r2=948905&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java (original)
+++ cxf/branches/2.2.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/SpringAopClassHelper.java Thu May 27 16:44:29 2010
@@ -37,7 +37,21 @@ class SpringAopClassHelper extends Class
         }
         return cls;
     }
-    
+    protected Object getRealObjectInternal(Object o) {
+        if (o instanceof Advised) {
+            try {
+
+                Advised advised = (Advised)o;
+                Object target = advised.getTargetSource().getTarget();
+                //could be a proxy of a proxy.....   
+                return getRealObjectInternal(target);
+            } catch (Exception ex) {
+                // ignore
+            }
+        }
+        return o;
+    }
+
     protected Class getRealClassInternal(Object o) {
         if (AopUtils.isAopProxy(o)) {
             Advised advised = (Advised)o;