|
Spring Framework example source code file (CustomEditorConfigurer.java)
The Spring Framework CustomEditorConfigurer.java source code/* * Copyright 2002-2008 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.factory.config; import java.beans.PropertyEditor; import java.util.Iterator; import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.BeansException; import org.springframework.beans.FatalBeanException; import org.springframework.beans.PropertyEditorRegistrar; import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.core.Ordered; import org.springframework.util.ClassUtils; /** * {@link BeanFactoryPostProcessor} implementation that allows for convenient * registration of custom {@link PropertyEditor property editors}. * * <p>As of Spring 2.0, the recommended usage is to use custom * {@link PropertyEditorRegistrar} implementations that in turn register * any desired editors on a given * {@link org.springframework.beans.PropertyEditorRegistry registry}. * Each PropertyEditorRegistrar can register any number of custom editors. * * <pre class="code"> * <bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer"> * <property name="propertyEditorRegistrars"> * <list> * <bean class="mypackage.MyCustomDateEditorRegistrar"/> * <bean class="mypackage.MyObjectEditorRegistrar"/> * </list> * </property> * </bean></pre> * * <p>Alternative configuration example with custom editor classes: * * <pre class="code"> * <bean id="customEditorConfigurer" class="org.springframework.beans.factory.config.CustomEditorConfigurer"> * <property name="customEditors"> * <map> * <entry key="java.util.Date" value="mypackage.MyCustomDateEditor"/> * <entry key="mypackage.MyObject" value="mypackage.MyObjectEditor"/> * </map> * </property> * </bean></pre> * * <p>Also supports "java.lang.String[]"-style array class names and primitive * class names (e.g. "boolean"). Delegates to {@link ClassUtils} for actual * class name resolution. * * <p>NOTE: Custom property editors registered with this configurer do * <i>not apply to data binding. Custom editors for data binding need to * be registered on the {@link org.springframework.validation.DataBinder}: * Use a common base class or delegate to common PropertyEditorRegistrar * implementations to reuse editor registration there. * * @author Juergen Hoeller * @since 27.02.2004 * @see java.beans.PropertyEditor * @see org.springframework.beans.PropertyEditorRegistrar * @see ConfigurableBeanFactory#addPropertyEditorRegistrar * @see ConfigurableBeanFactory#registerCustomEditor * @see org.springframework.validation.DataBinder#registerCustomEditor * @see org.springframework.web.servlet.mvc.BaseCommandController#setPropertyEditorRegistrars * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder */ public class CustomEditorConfigurer implements BeanFactoryPostProcessor, BeanClassLoaderAware, Ordered { protected final Log logger = LogFactory.getLog(getClass()); private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered private PropertyEditorRegistrar[] propertyEditorRegistrars; private Map customEditors; private boolean ignoreUnresolvableEditors = false; private ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader(); public void setOrder(int order) { this.order = order; } public int getOrder() { return this.order; } /** * Specify the {@link PropertyEditorRegistrar PropertyEditorRegistrars} * to apply to beans defined within the current application context. * <p>This allows for sharing Other Spring Framework examples (source code examples)Here is a short list of links related to this Spring Framework CustomEditorConfigurer.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.