-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancementA general enhancement
Milestone
Description
!!Use pwebb rather than philw opened SPR-8463 and commented
As of 3.1M2 the class org.springframework.beans.TypeConverterDelegate has the following method:
/**
* Find a default editor for the given type.
* @param requiredType the type to find an editor for
* @param descriptor the JavaBeans descriptor for the property
* @return the corresponding editor, or <code>null</code> if none
*/
protected PropertyEditor findDefaultEditor(Class requiredType, TypeDescriptor typeDescriptor) {
PropertyEditor editor = null;
//if (typeDescriptor instanceof PropertyTypeDescriptor) {
//PropertyDescriptor pd = ((PropertyTypeDescriptor) typeDescriptor).getPropertyDescriptor();
//editor = pd.createPropertyEditor(this.targetObject);
//}
if (editor == null && requiredType != null) {
// No custom editor -> check BeanWrapperImpl's default editors.
editor = this.propertyEditorRegistry.getDefaultEditor(requiredType);
if (editor == null && !String.class.equals(requiredType)) {
// No BeanWrapper default editor -> check standard JavaBean editor.
editor = BeanUtils.findEditorByConvention(requiredType);
}
}
return editor;
}
I have a class that needs to perform an identical lookup, so I have been paying close attention to this method:
As the PropertyTypeDescriptor class has now been removed could the commented out lines be removed all together? Looking at the code I was not entirely sure if they had been commented out as a temporary measure, or if the change is intended to be permanent.
Would it also be possible to have this method exposed as a static utility somewhere so that it can be reused?
Something like:
/**
* Find a default editor for the given type.
* @param requiredType the type to find an editor for
* @param descriptor the JavaBeans descriptor for the property
* @return the corresponding editor, or <code>null</code> if none
*/
protected PropertyEditor findDefaultEditor(Class<?> requiredType, TypeDescriptor typeDescriptor) {
return findDefaultEditor(requiredType, typeDescriptor, this.propertyEditorRegistry);
}
/**
* Find a default editor for the given type.
* @param requiredType the type to find an editor for
* @param descriptor the JavaBeans descriptor for the property
* @return the corresponding editor, or <code>null</code> if none
*/
public static PropertyEditor findDefaultEditor(Class<?> requiredType,
TypeDescriptor typeDescriptor,
PropertyEditorRegistrySupport propertyEditorRegistry) {
PropertyEditor editor = null;
if (requiredType != null) {
// check BeanWrapperImpl's default editors.
editor = propertyEditorRegistry.getDefaultEditor(requiredType);
if (editor == null && !String.class.equals(requiredType)) {
// No BeanWrapper default editor -> check standard JavaBean editor.
editor = BeanUtils.findEditorByConvention(requiredType);
}
}
return editor;
}
Affects: 3.1 M2
Issue Links:
- Poor Performance with lots of Prototype Scoped Beans [SPR-9670] #14304 Poor Performance with lots of Prototype Scoped Beans
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancementA general enhancement