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:19:15 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 794243e6c -> 27ae9979b


[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/27ae9979
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/27ae9979
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/27ae9979

Branch: refs/heads/3.1.x-fixes
Commit: 27ae9979b88540574ee59c487f43c20c877c8be3
Parents: 794243e
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:18:58 2017 +0100

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


http://git-wip-us.apache.org/repos/asf/cxf/blob/27ae9979/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 4afe05e..9099519 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