From: Juergen H. <jho...@us...> - 2008-10-14 11:25:19
|
Update of /cvsroot/springframework/spring/src/org/springframework/beans/factory/support In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15515/src/org/springframework/beans/factory/support Modified Files: Tag: mbranch-2-0 AbstractBeanDefinition.java Log Message: fixed corner case in AbstractBeanDefinition where a ClassCastException could arise in "getBeanClass(Name)" Index: AbstractBeanDefinition.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/beans/factory/support/AbstractBeanDefinition.java,v retrieving revision 1.71.2.1 retrieving revision 1.71.2.2 diff -C2 -d -r1.71.2.1 -r1.71.2.2 *** AbstractBeanDefinition.java 24 Nov 2007 19:06:21 -0000 1.71.2.1 --- AbstractBeanDefinition.java 14 Oct 2008 11:25:14 -0000 1.71.2.2 *************** *** 279,295 **** /** ! * Return the class of the wrapped bean. * @throws IllegalStateException if the bean definition does not define a bean class, * or a specified bean class name has not been resolved into an actual Class */ public Class getBeanClass() throws IllegalStateException { ! if (this.beanClass == null) { throw new IllegalStateException("No bean class specified on bean definition"); } ! if (!(this.beanClass instanceof Class)) { throw new IllegalStateException( ! "Bean class name [" + this.beanClass + "] has not been resolved into an actual Class"); } ! return (Class) this.beanClass; } --- 279,297 ---- /** ! * Return the class of the wrapped bean, if already resolved. ! * @return the bean class, or <code>null</code> if none defined * @throws IllegalStateException if the bean definition does not define a bean class, * or a specified bean class name has not been resolved into an actual Class */ public Class getBeanClass() throws IllegalStateException { ! Object beanClassObject = this.beanClass; ! if (beanClassObject == null) { throw new IllegalStateException("No bean class specified on bean definition"); } ! if (!(beanClassObject instanceof Class)) { throw new IllegalStateException( ! "Bean class name [" + beanClassObject + "] has not been resolved into an actual Class"); } ! return (Class) beanClassObject; } *************** *** 305,313 **** */ public String getBeanClassName() { ! if (this.beanClass instanceof Class) { ! return ((Class) this.beanClass).getName(); } else { ! return (String) this.beanClass; } } --- 307,316 ---- */ public String getBeanClassName() { ! Object beanClassObject = this.beanClass; ! if (beanClassObject instanceof Class) { ! return ((Class) beanClassObject).getName(); } else { ! return (String) beanClassObject; } } *************** *** 322,329 **** */ public Class resolveBeanClass(ClassLoader classLoader) throws ClassNotFoundException { ! if (this.beanClass == null) { return null; } ! Class resolvedClass = ClassUtils.forName(getBeanClassName(), classLoader); this.beanClass = resolvedClass; return resolvedClass; --- 325,333 ---- */ public Class resolveBeanClass(ClassLoader classLoader) throws ClassNotFoundException { ! String className = getBeanClassName(); ! if (className == null) { return null; } ! Class resolvedClass = ClassUtils.forName(className, classLoader); this.beanClass = resolvedClass; return resolvedClass; |