Home » Spring-Framework-090522 » org.springframework » beans » factory » [javadoc | source]

    1   /*
    2    * Copyright 2002-2008 the original author or authors.
    3    *
    4    * Licensed under the Apache License, Version 2.0 (the "License");
    5    * you may not use this file except in compliance with the License.
    6    * You may obtain a copy of the License at
    7    *
    8    *      http://www.apache.org/licenses/LICENSE-2.0
    9    *
   10    * Unless required by applicable law or agreed to in writing, software
   11    * distributed under the License is distributed on an "AS IS" BASIS,
   12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   13    * See the License for the specific language governing permissions and
   14    * limitations under the License.
   15    */
   16   
   17   package org.springframework.beans.factory;
   18   
   19   import org.springframework.beans.BeansException;
   20   import org.springframework.util.ClassUtils;
   21   
   22   /**
   23    * Exception thrown when a bean depends on other beans or simple properties
   24    * that were not specified in the bean factory definition, although
   25    * dependency checking was enabled.
   26    *
   27    * @author Rod Johnson
   28    * @author Juergen Hoeller
   29    * @since 03.09.2003
   30    */
   31   public class UnsatisfiedDependencyException extends BeanCreationException {
   32   
   33   	/**
   34   	 * Create a new UnsatisfiedDependencyException.
   35   	 * @param resourceDescription description of the resource that the bean definition came from
   36   	 * @param beanName the name of the bean requested
   37   	 * @param propertyName the name of the bean property that couldn't be satisfied
   38   	 * @param msg the detail message
   39   	 */
   40   	public UnsatisfiedDependencyException(
   41   			String resourceDescription, String beanName, String propertyName, String msg) {
   42   
   43   		super(resourceDescription, beanName,
   44   				"Unsatisfied dependency expressed through bean property '" + propertyName + "'" +
   45   				(msg != null ? ": " + msg : ""));
   46   	}
   47   
   48   	/**
   49   	 * Create a new UnsatisfiedDependencyException.
   50   	 * @param resourceDescription description of the resource that the bean definition came from
   51   	 * @param beanName the name of the bean requested
   52   	 * @param propertyName the name of the bean property that couldn't be satisfied
   53   	 * @param ex the bean creation exception that indicated the unsatisfied dependency
   54   	 */
   55   	public UnsatisfiedDependencyException(
   56   			String resourceDescription, String beanName, String propertyName, BeansException ex) {
   57   
   58   		this(resourceDescription, beanName, propertyName, (ex != null ? ": " + ex.getMessage() : ""));
   59   		initCause(ex);
   60   	}
   61   
   62   	/**
   63   	 * Create a new UnsatisfiedDependencyException.
   64   	 * @param resourceDescription description of the resource that the bean definition came from
   65   	 * @param beanName the name of the bean requested
   66   	 * @param ctorArgIndex the index of the constructor argument that couldn't be satisfied
   67   	 * @param ctorArgType the type of the constructor argument that couldn't be satisfied
   68   	 * @param msg the detail message
   69   	 */
   70   	public UnsatisfiedDependencyException(
   71   			String resourceDescription, String beanName, int ctorArgIndex, Class ctorArgType, String msg) {
   72   
   73   		super(resourceDescription, beanName,
   74   				"Unsatisfied dependency expressed through constructor argument with index " +
   75   				ctorArgIndex + " of type [" + ClassUtils.getQualifiedName(ctorArgType) + "]" +
   76   				(msg != null ? ": " + msg : ""));
   77   	}
   78   
   79   	/**
   80   	 * Create a new UnsatisfiedDependencyException.
   81   	 * @param resourceDescription description of the resource that the bean definition came from
   82   	 * @param beanName the name of the bean requested
   83   	 * @param ctorArgIndex the index of the constructor argument that couldn't be satisfied
   84   	 * @param ctorArgType the type of the constructor argument that couldn't be satisfied
   85   	 * @param ex the bean creation exception that indicated the unsatisfied dependency
   86   	 */
   87   	public UnsatisfiedDependencyException(
   88   			String resourceDescription, String beanName, int ctorArgIndex, Class ctorArgType, BeansException ex) {
   89   
   90   		this(resourceDescription, beanName, ctorArgIndex, ctorArgType, (ex != null ? ": " + ex.getMessage() : ""));
   91   		initCause(ex);
   92   	}
   93   
   94   }

Home » Spring-Framework-090522 » org.springframework » beans » factory » [javadoc | source]