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

    1   /*
    2    * Copyright 2002-2007 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.FatalBeanException;
   20   
   21   /**
   22    * Exception thrown when the BeanFactory cannot load the specified class
   23    * of a given bean.
   24    *
   25    * @author Juergen Hoeller
   26    * @since 2.0
   27    */
   28   public class CannotLoadBeanClassException extends FatalBeanException {
   29   
   30   	private String resourceDescription;
   31   
   32   	private String beanName;
   33   
   34   	private String beanClassName;
   35   
   36   
   37   	/**
   38   	 * Create a new CannotLoadBeanClassException.
   39   	 * @param resourceDescription description of the resource
   40   	 * that the bean definition came from
   41   	 * @param beanName the name of the bean requested
   42   	 * @param beanClassName the name of the bean class
   43   	 * @param cause the root cause
   44   	 */
   45   	public CannotLoadBeanClassException(
   46   			String resourceDescription, String beanName, String beanClassName, ClassNotFoundException cause) {
   47   
   48   		super("Cannot find class [" + beanClassName + "] for bean with name '" + beanName +
   49   				"' defined in " + resourceDescription, cause);
   50   		this.resourceDescription = resourceDescription;
   51   		this.beanName = beanName;
   52   		this.beanClassName = beanClassName;
   53   	}
   54   
   55   	/**
   56   	 * Create a new CannotLoadBeanClassException.
   57   	 * @param resourceDescription description of the resource
   58   	 * that the bean definition came from
   59   	 * @param beanName the name of the bean requested
   60   	 * @param beanClassName the name of the bean class
   61   	 * @param cause the root cause
   62   	 */
   63   	public CannotLoadBeanClassException(
   64   			String resourceDescription, String beanName, String beanClassName, LinkageError cause) {
   65   
   66   		super("Error loading class [" + beanClassName + "] for bean with name '" + beanName +
   67   				"' defined in " + resourceDescription + ": problem with class file or dependent class", cause);
   68   		this.resourceDescription = resourceDescription;
   69   		this.beanName = beanName;
   70   		this.beanClassName = beanClassName;
   71   	}
   72   
   73   
   74   	/**
   75   	 * Return the description of the resource that the bean
   76   	 * definition came from.
   77   	 */
   78   	public String getResourceDescription() {
   79   		return this.resourceDescription;
   80   	}
   81   
   82   	/**
   83   	 * Return the name of the bean requested.
   84   	 */
   85   	public String getBeanName() {
   86   		return this.beanName;
   87   	}
   88   
   89   	/**
   90   	 * Return the name of the class we were trying to load.
   91   	 */
   92   	public String getBeanClassName() {
   93   		return this.beanClassName;
   94   	}
   95   
   96   }

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