cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-7293] Updating AbstractSpringComponentScanServer to ignore client proxy classes, with thanks to Dennis Kieselhorst
Date Tue, 28 Mar 2017 16:17:32 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 428f7700d -> 9df8cbc09


[CXF-7293] Updating AbstractSpringComponentScanServer to ignore client proxy classes, with
thanks to Dennis Kieselhorst


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/9df8cbc0
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/9df8cbc0
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/9df8cbc0

Branch: refs/heads/master
Commit: 9df8cbc0942a52dee2f94d9aea08be46b501bb78
Parents: 428f770
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Mar 28 17:17:17 2017 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue Mar 28 17:17:17 2017 +0100

----------------------------------------------------------------------
 .../spring/AbstractSpringComponentScanServer.java | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/9df8cbc0/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/AbstractSpringComponentScanServer.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/AbstractSpringComponentScanServer.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/AbstractSpringComponentScanServer.java
index 9225ad9..d5a11dc 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/AbstractSpringComponentScanServer.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/AbstractSpringComponentScanServer.java
@@ -19,6 +19,7 @@
 package org.apache.cxf.jaxrs.spring;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Proxy;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.LinkedList;
@@ -32,6 +33,7 @@ import javax.ws.rs.ext.Provider;
 
 import org.apache.cxf.annotations.Provider.Scope;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.ClassHelper;
 import org.apache.cxf.common.util.ClasspathScanner;
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.common.util.StringUtils;
@@ -135,10 +137,26 @@ public abstract class AbstractSpringComponentScanServer extends AbstractSpringCo
                                       Set<String> componentScanPackagesSet,
                                       Set<String> componentScanBeansSet) {
         return isAnnotationAvailable(beanName, ann)
+            && nonProxyClass(beanName)
             && matchesServiceAnnotation(beanName)
             && matchesComponentPackage(beanName, componentScanPackagesSet)
             && matchesComponentName(beanName, componentScanBeansSet);
     }
+    protected boolean nonProxyClass(String beanName) {
+        // JAX-RS runtime needs to be able to access the real component class to introspect
it for
+        // JAX-RS annotations; the following check ensures that the valid proxified components
+        // are accepted while the client proxies are ignored.
+        Class<?> type = ClassHelper.getRealClassFromClass(applicationContext.getType(beanName));
+        if (Proxy.isProxyClass(type) && applicationContext.isSingleton(beanName))
{
+            type = ClassHelper.getRealClass(applicationContext.getBean(beanName));
+        }
+        if (Proxy.isProxyClass(type)) {
+            LOG.fine("Can not determine the real class of the component '" + beanName + "'");
+            return false;
+        } else {
+            return true;
+        }
+    }
     protected boolean matchesComponentName(String beanName, Set<String> componentScanBeansSet)
{
         return componentScanBeansSet == null || componentScanBeansSet.contains(beanName);
     }


Mime
View raw message