From be63c07b2e49b6439a43610a64c3cf456d9c9458 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 10 Dec 2013 13:26:52 +0100 Subject: [PATCH] Polishing --- .../AbstractAutowireCapableBeanFactory.java | 16 ++++++---------- .../support/FactoryBeanRegistrySupport.java | 7 +++---- .../jdbc/core/StatementCreatorUtils.java | 2 +- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java index 867330f82b..5bd6b18232 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java @@ -743,11 +743,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac // Try to obtain the FactoryBean's object type without instantiating it at all. BeanDefinition fbDef = getBeanDefinition(factoryBeanName); if (fbDef instanceof AbstractBeanDefinition && ((AbstractBeanDefinition) fbDef).hasBeanClass()) { - Class fbClass = ((AbstractBeanDefinition) fbDef).getBeanClass(); - if (ClassUtils.isCglibProxyClass(fbClass)) { - // CGLIB subclass methods hide generic parameters. look at the superclass. - fbClass = fbClass.getSuperclass(); - } + // CGLIB subclass methods hide generic parameters; look at the original user class. + Class fbClass = ClassUtils.getUserClass(((AbstractBeanDefinition) fbDef).getBeanClass()); // Find the given factory method, taking into account that in the case of // @Bean methods, there may be parameters present. ReflectionUtils.doWithMethods(fbClass, @@ -820,12 +817,11 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac * @return the FactoryBean instance, or {@code null} to indicate * that we couldn't obtain a shortcut FactoryBean instance */ - @SuppressWarnings("unchecked") - private FactoryBean getSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) { + private FactoryBean getSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) { synchronized (getSingletonMutex()) { BeanWrapper bw = this.factoryBeanInstanceCache.get(beanName); if (bw != null) { - return (FactoryBean) bw.getWrappedInstance(); + return (FactoryBean) bw.getWrappedInstance(); } if (isSingletonCurrentlyInCreation(beanName)) { return null; @@ -845,7 +841,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac // Finished partial creation of this bean. afterSingletonCreation(beanName); } - FactoryBean fb = getFactoryBean(beanName, instance); + FactoryBean fb = getFactoryBean(beanName, instance); if (bw != null) { this.factoryBeanInstanceCache.put(beanName, bw); } @@ -862,7 +858,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac * @return the FactoryBean instance, or {@code null} to indicate * that we couldn't obtain a shortcut FactoryBean instance */ - private FactoryBean getNonSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) { + private FactoryBean getNonSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) { if (isPrototypeCurrentlyInCreation(beanName)) { return null; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java index 92361bdaca..afda1d4c60 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -192,13 +192,12 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg * @return the bean instance as FactoryBean * @throws BeansException if the given bean cannot be exposed as a FactoryBean */ - @SuppressWarnings("unchecked") - protected FactoryBean getFactoryBean(String beanName, Object beanInstance) throws BeansException { + protected FactoryBean getFactoryBean(String beanName, Object beanInstance) throws BeansException { if (!(beanInstance instanceof FactoryBean)) { throw new BeanCreationException(beanName, "Bean instance of type [" + beanInstance.getClass() + "] is not a FactoryBean"); } - return (FactoryBean) beanInstance; + return (FactoryBean) beanInstance; } /** diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/StatementCreatorUtils.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/StatementCreatorUtils.java index 981d38952a..ba90f29297 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/StatementCreatorUtils.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/StatementCreatorUtils.java @@ -417,7 +417,7 @@ public abstract class StatementCreatorUtils { * @see DisposableSqlTypeValue#cleanup() * @see org.springframework.jdbc.core.support.SqlLobValue#cleanup() */ - public static void cleanupParameters(Object[] paramValues) { + public static void cleanupParameters(Object... paramValues) { if (paramValues != null) { cleanupParameters(Arrays.asList(paramValues)); }