From: Juergen H. <jho...@us...> - 2006-04-21 00:14:23
|
Update of /cvsroot/springframework/spring/src/org/springframework/beans In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19629/src/org/springframework/beans Modified Files: Tag: mbranch-1-2 BeanUtils.java BeanWrapperImpl.java MutablePropertyValues.java PropertyEditorRegistrar.java PropertyEditorRegistrySupport.java Added Files: Tag: mbranch-1-2 BeanInstantiationException.java Log Message: backported fixes and enhancements from 2.0 M4 (HEAD) Index: PropertyEditorRegistrar.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/beans/PropertyEditorRegistrar.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** PropertyEditorRegistrar.java 14 Nov 2005 11:55:32 -0000 1.1 --- PropertyEditorRegistrar.java 21 Apr 2006 00:13:48 -0000 1.1.2.1 *************** *** 1,11 **** /* ! * Copyright 2002-2005 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. * You may obtain a copy of the License at ! * * http://www.apache.org/licenses/LICENSE-2.0 ! * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, --- 1,11 ---- /* ! * Copyright 2002-2006 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. * You may obtain a copy of the License at ! * * http://www.apache.org/licenses/LICENSE-2.0 ! * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, *************** *** 23,35 **** * a corresponding registrar and reuse that in each case. * - * <p>Serves as super-interface for the BeanWrapper interface. - * Implemented by BeanWrapperImpl and also by the DataBinder class - * in the validation package. - * * @author Juergen Hoeller * @since 1.2.6 ! * @see BeanWrapper ! * @see BeanWrapperImpl ! * @see org.springframework.validation.DataBinder * @see java.beans.PropertyEditor */ --- 23,29 ---- * a corresponding registrar and reuse that in each case. * * @author Juergen Hoeller * @since 1.2.6 ! * @see PropertyEditorRegistry * @see java.beans.PropertyEditor */ *************** *** 41,44 **** --- 35,40 ---- * @param registry the PropertyEditorRegistry to register the custom * PropertyEditors with + * @see BeanWrapper + * @see org.springframework.validation.DataBinder */ void registerCustomEditors(PropertyEditorRegistry registry); Index: BeanWrapperImpl.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/beans/BeanWrapperImpl.java,v retrieving revision 1.86.2.4 retrieving revision 1.86.2.5 diff -C2 -d -r1.86.2.4 -r1.86.2.5 *** BeanWrapperImpl.java 21 Feb 2006 18:14:52 -0000 1.86.2.4 --- BeanWrapperImpl.java 21 Apr 2006 00:13:48 -0000 1.86.2.5 *************** *** 917,921 **** return result; } ! else { // A plain value: convert it to an array with a single component. Object result = Array.newInstance(componentType, 1); --- 917,921 ---- return result; } ! else if (convertedValue != null) { // A plain value: convert it to an array with a single component. Object result = Array.newInstance(componentType, 1); Index: MutablePropertyValues.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/beans/MutablePropertyValues.java,v retrieving revision 1.15.4.1 retrieving revision 1.15.4.2 diff -C2 -d -r1.15.4.1 -r1.15.4.2 *** MutablePropertyValues.java 17 Jan 2006 21:29:34 -0000 1.15.4.1 --- MutablePropertyValues.java 21 Apr 2006 00:13:48 -0000 1.15.4.2 *************** *** 5,11 **** * you may not use this file except in compliance with the License. * You may obtain a copy of the License at ! * * http://www.apache.org/licenses/LICENSE-2.0 ! * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, --- 5,11 ---- * you may not use this file except in compliance with the License. * You may obtain a copy of the License at ! * * http://www.apache.org/licenses/LICENSE-2.0 ! * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, *************** *** 137,153 **** /** - * Overloaded version of addPropertyValue that takes - * a property name and a property value. - * @param propertyName name of the property - * @param propertyValue value of the property - * @return this object to allow creating objects, adding multiple - * PropertyValues in a single statement - * @see #addPropertyValue(PropertyValue) - */ - public MutablePropertyValues addPropertyValue(String propertyName, Object propertyValue) { - return addPropertyValue(new PropertyValue(propertyName, propertyValue)); - } - - /** * Add a PropertyValue object, replacing any existing one * for the corresponding property. --- 137,140 ---- *************** *** 169,172 **** --- 156,170 ---- /** + * Overloaded version of <code>addPropertyValue</code> that takes + * a property name and a property value. + * @param propertyName name of the property + * @param propertyValue value of the property + * @see #addPropertyValue(PropertyValue) + */ + public void addPropertyValue(String propertyName, Object propertyValue) { + addPropertyValue(new PropertyValue(propertyName, propertyValue)); + } + + /** * Modify a PropertyValue object held in this object. * Indexed from 0. *************** *** 177,181 **** /** ! * Overloaded version of removePropertyValue that takes a property name. * @param propertyName name of the property * @see #removePropertyValue(PropertyValue) --- 175,179 ---- /** ! * Overloaded version of <code>removePropertyValue</code> that takes a property name. * @param propertyName name of the property * @see #removePropertyValue(PropertyValue) --- NEW FILE: BeanInstantiationException.java --- /* * Copyright 2002-2006 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. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.springframework.beans; /** * Exception thrown when instantiation of a bean failed. * Carries the offending bean class. * * @author Juergen Hoeller * @since 1.2.8 */ public class BeanInstantiationException extends FatalBeanException { private Class beanClass; /** * Create a new BeanInstantiationException. * @param beanClass the offending bean class * @param msg the detail message */ public BeanInstantiationException(Class beanClass, String msg) { this(beanClass, msg, null); } /** * Create a new BeanInstantiationException. * @param beanClass the offending bean class * @param msg the detail message * @param ex the root cause */ public BeanInstantiationException(Class beanClass, String msg, Throwable ex) { super("Could not instantiate bean class [" + beanClass.getName() + "]: " + msg, ex); this.beanClass = beanClass; } /** * Return the offending bean class. */ public Class getBeanClass() { return beanClass; } } Index: BeanUtils.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/beans/BeanUtils.java,v retrieving revision 1.41.2.1 retrieving revision 1.41.2.2 diff -C2 -d -r1.41.2.1 -r1.41.2.2 *** BeanUtils.java 18 Feb 2006 13:17:20 -0000 1.41.2.1 --- BeanUtils.java 21 Apr 2006 00:13:48 -0000 1.41.2.2 *************** *** 149,154 **** } catch (NoSuchMethodException ex) { ! throw new FatalBeanException("Could not instantiate class [" + clazz.getName() + ! "]: no default constructor found", ex); } } --- 149,153 ---- } catch (NoSuchMethodException ex) { ! throw new BeanInstantiationException(clazz, "No default constructor found", ex); } } *************** *** 164,168 **** */ public static Object instantiateClass(Constructor ctor, Object[] args) throws BeansException { ! Assert.notNull(ctor, "ctor must not be null"); try { if (!Modifier.isPublic(ctor.getModifiers()) || --- 163,167 ---- */ public static Object instantiateClass(Constructor ctor, Object[] args) throws BeansException { ! Assert.notNull(ctor, "Constructor must not be null"); try { if (!Modifier.isPublic(ctor.getModifiers()) || *************** *** 173,190 **** } catch (InstantiationException ex) { ! throw new FatalBeanException("Could not instantiate class [" + ctor.getDeclaringClass().getName() + ! "]: Is it an abstract class?", ex); } catch (IllegalAccessException ex) { ! throw new FatalBeanException("Could not instantiate class [" + ctor.getDeclaringClass().getName() + ! "]: Has the class definition changed? Is the constructor accessible?", ex); } catch (IllegalArgumentException ex) { ! throw new FatalBeanException("Could not instantiate class [" + ctor.getDeclaringClass().getName() + ! "]: illegal args for constructor", ex); } catch (InvocationTargetException ex) { ! throw new FatalBeanException("Could not instantiate class [" + ctor.getDeclaringClass().getName() + ! "]; constructor threw exception", ex.getTargetException()); } } --- 172,189 ---- } catch (InstantiationException ex) { ! throw new BeanInstantiationException(ctor.getDeclaringClass(), ! "Is it an abstract class?", ex); } catch (IllegalAccessException ex) { ! throw new BeanInstantiationException(ctor.getDeclaringClass(), ! "Has the class definition changed? Is the constructor accessible?", ex); } catch (IllegalArgumentException ex) { ! throw new BeanInstantiationException(ctor.getDeclaringClass(), ! "Illegal arguments for constructor", ex); } catch (InvocationTargetException ex) { ! throw new BeanInstantiationException(ctor.getDeclaringClass(), ! "Constructor threw exception", ex.getTargetException()); } } *************** *** 200,204 **** * @param methodName the name of the method to find * @param paramTypes the parameter types of the method to find ! * @return the method object, or <code>null</code> if not found * @see java.lang.Class#getMethod * @see #findDeclaredMethod --- 199,203 ---- * @param methodName the name of the method to find * @param paramTypes the parameter types of the method to find ! * @return the Method object, or <code>null</code> if not found * @see java.lang.Class#getMethod * @see #findDeclaredMethod *************** *** 221,225 **** * @param methodName the name of the method to find * @param paramTypes the parameter types of the method to find ! * @return the method object, or <code>null</code> if not found * @see java.lang.Class#getDeclaredMethod */ --- 220,224 ---- * @param methodName the name of the method to find * @param paramTypes the parameter types of the method to find ! * @return the Method object, or <code>null</code> if not found * @see java.lang.Class#getDeclaredMethod */ *************** *** 245,249 **** * @param clazz the class to check * @param methodName the name of the method to find ! * @return the method object, or <code>null</code> if not found * @see java.lang.Class#getMethods * @see #findDeclaredMethodWithMinimalParameters --- 244,248 ---- * @param clazz the class to check * @param methodName the name of the method to find ! * @return the Method object, or <code>null</code> if not found * @see java.lang.Class#getMethods * @see #findDeclaredMethodWithMinimalParameters *************** *** 456,461 **** throws BeansException { ! Assert.notNull(source, "source must not be null"); ! Assert.notNull(target, "target must not be null"); Class actualEditable = target.getClass(); --- 455,460 ---- throws BeansException { ! Assert.notNull(source, "Source must not be null"); ! Assert.notNull(target, "Target must not be null"); Class actualEditable = target.getClass(); Index: PropertyEditorRegistrySupport.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/beans/PropertyEditorRegistrySupport.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** PropertyEditorRegistrySupport.java 18 Feb 2006 13:22:01 -0000 1.1.2.1 --- PropertyEditorRegistrySupport.java 21 Apr 2006 00:13:48 -0000 1.1.2.2 *************** *** 35,38 **** --- 35,39 ---- import org.springframework.beans.propertyeditors.ByteArrayPropertyEditor; + import org.springframework.beans.propertyeditors.CharArrayPropertyEditor; import org.springframework.beans.propertyeditors.CharacterEditor; import org.springframework.beans.propertyeditors.ClassEditor; *************** *** 106,110 **** // Simple editors, without parameterization capabilities. // The JDK does not contain a default editor for any of these target types. - this.defaultEditors.put(byte[].class, new ByteArrayPropertyEditor()); this.defaultEditors.put(Class.class, new ClassEditor()); this.defaultEditors.put(File.class, new FileEditor()); --- 107,110 ---- *************** *** 123,126 **** --- 123,130 ---- this.defaultEditors.put(List.class, new CustomCollectionEditor(List.class)); + // Default editors for primitive arrays. + this.defaultEditors.put(byte[].class, new ByteArrayPropertyEditor()); + this.defaultEditors.put(char[].class, new CharArrayPropertyEditor()); + // Default instances of character and boolean editors. // Can be overridden by registering custom instances of those as custom editors. |