cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-6003] Trying to create the beans from discovered classes with the auto wire support, the patch from Hesam Talebi applied
Date Mon, 15 Sep 2014 17:07:56 GMT
Repository: cxf
Updated Branches:
  refs/heads/master f563a0576 -> aecc29f4d


[CXF-6003] Trying to create the beans from discovered classes with the auto wire support,
the patch from Hesam Talebi applied


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

Branch: refs/heads/master
Commit: aecc29f4d1bde9a50c91f3612f2c0049ed594f03
Parents: f563a05
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Mon Sep 15 18:07:36 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Mon Sep 15 18:07:36 2014 +0100

----------------------------------------------------------------------
 .../spring/JAXRSServerFactoryBeanDefinitionParser.java | 10 +++++++++-
 .../spring/JAXRSClientFactoryBeanDefinitionParser.java | 13 +++++++++++--
 2 files changed, 20 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/aecc29f4/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java
index ee68a61..40b6286 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java
@@ -44,6 +44,7 @@ import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.BeanCreationException;
 import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
 import org.springframework.beans.factory.support.AbstractBeanDefinition;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import org.springframework.beans.factory.xml.ParserContext;
@@ -208,9 +209,16 @@ public class JAXRSServerFactoryBeanDefinitionParser extends AbstractBeanDefiniti
             }
         }        
         private List<Object> createBeans(Collection<Class<?>> classes)
{
+            AutowireCapableBeanFactory beanFactory = context.getAutowireCapableBeanFactory();
             final List< Object > providers = new ArrayList< Object >();
             for (final Class< ? > clazz: classes) {
-                providers.add(context.getAutowireCapableBeanFactory().createBean(clazz));
+                Object bean = null;
+                try {
+                    bean = beanFactory.createBean(clazz, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE,
true);
+                } catch (Exception ex) {
+                    bean = beanFactory.createBean(clazz);
+                }
+                providers.add(bean);
             }
             return providers;
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/aecc29f4/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/JAXRSClientFactoryBeanDefinitionParser.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/JAXRSClientFactoryBeanDefinitionParser.java
b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/JAXRSClientFactoryBeanDefinitionParser.java
index 14b7678..661d621 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/JAXRSClientFactoryBeanDefinitionParser.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spring/JAXRSClientFactoryBeanDefinitionParser.java
@@ -40,6 +40,7 @@ import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.BeanCreationException;
 import org.springframework.beans.factory.BeanDefinitionStoreException;
 import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
 import org.springframework.beans.factory.xml.ParserContext;
 import org.springframework.context.ApplicationContext;
@@ -130,9 +131,17 @@ public class JAXRSClientFactoryBeanDefinitionParser extends AbstractFactoryBeanD
                     if (classes.get(Path.class).size() > 1) {
                         throw new NoUniqueBeanDefinitionException(Path.class, classes.get(Path.class).size(),

                             "More than one service class (@Path) has been discovered");
-                    } else {                      
+                    } else {
+                        AutowireCapableBeanFactory beanFactory = ctx.getAutowireCapableBeanFactory();
                         for (final Class< ? > providerClass: classes.get(Provider.class))
{
-                            setProvider(ctx.getAutowireCapableBeanFactory().createBean(providerClass));
+                            Object bean = null;
+                            try {
+                                bean = beanFactory.createBean(providerClass, 
+                                                       AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE,
true);
+                            } catch (Exception ex) {
+                                bean = beanFactory.createBean(providerClass);
+                            }
+                            setProvider(bean);
                         }
                         
                         for (final Class< ? > serviceClass: classes.get(Path.class))
{                        


Mime
View raw message