|
Spring Framework example source code file (RequiredAnnotationBeanPostProcessor.java)
The Spring Framework RequiredAnnotationBeanPostProcessor.java source code/* * Copyright 2002-2007 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.annotation; import java.beans.PropertyDescriptor; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import org.springframework.beans.BeansException; import org.springframework.beans.PropertyValues; import org.springframework.beans.factory.BeanInitializationException; import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter; import org.springframework.core.Ordered; import org.springframework.core.PriorityOrdered; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.util.Assert; /** * {@link org.springframework.beans.factory.config.BeanPostProcessor} implementation * that enforces required JavaBean properties to have been configured. * Required bean properties are detected through a Java 5 annotation: * by default, Spring's {@link Required} annotation. * * <p>The motivation for the existence of this BeanPostProcessor is to allow * developers to annotate the setter properties of their own classes with an * arbitrary JDK 1.5 annotation to indicate that the container must check * for the configuration of a dependency injected value. This neatly pushes * responsibility for such checking onto the container (where it arguably belongs), * and obviates the need (<b>in part) for a developer to code a method that * simply checks that all required properties have actually been set. * * <p>Please note that an 'init' method may still need to implemented (and may * still be desirable), because all that this class does is enforce that a * 'required' property has actually been configured with a value. It does * <b>not check anything else... In particular, it does not check that a * configured value is not <code>null. * * <p>Note: A default RequiredAnnotationBeanPostProcessor will be registered * by the "context:annotation-config" and "context:component-scan" XML tags. * Remove or turn off the default annotation configuration there if you intend * to specify a custom RequiredAnnotationBeanPostProcessor bean definition. * * @author Rob Harrop * @author Juergen Hoeller * @since 2.0 * @see #setRequiredAnnotationType * @see Required */ public class RequiredAnnotationBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter implements PriorityOrdered { private Class<? extends Annotation> requiredAnnotationType = Required.class; private int order = Ordered.LOWEST_PRECEDENCE - 1; /** Cache for validated bean names, skipping re-validation for the same bean */ private final Set<String> validatedBeanNames = Collections.synchronizedSet(new HashSet Other Spring Framework examples (source code examples)Here is a short list of links related to this Spring Framework RequiredAnnotationBeanPostProcessor.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.