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:10:22 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 103a6aef9 -> 0f3d4a6f0


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

Branch: refs/heads/3.0.x-fixes
Commit: 0f3d4a6f0b6469e89fa1a3338c40ce54c47fbc2e
Parents: 103a6ae
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:09:53 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/0f3d4a6f/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 7adfaa5..4ab0137 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;
@@ -209,9 +210,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/0f3d4a6f/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 c35f25b..6bb80f8 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;
@@ -131,9 +132,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