001/* 002 * Copyright 2002-2012 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.beans.factory; 018 019/** 020 * Callback that allows a bean to be aware of the bean 021 * {@link ClassLoader class loader}; that is, the class loader used by the 022 * present bean factory to load bean classes. 023 * 024 * <p>This is mainly intended to be implemented by framework classes which 025 * have to pick up application classes by name despite themselves potentially 026 * being loaded from a shared class loader. 027 * 028 * <p>For a list of all bean lifecycle methods, see the 029 * {@link BeanFactory BeanFactory javadocs}. 030 * 031 * @author Juergen Hoeller 032 * @author Chris Beams 033 * @since 2.0 034 * @see BeanNameAware 035 * @see BeanFactoryAware 036 * @see InitializingBean 037 */ 038public interface BeanClassLoaderAware extends Aware { 039 040 /** 041 * Callback that supplies the bean {@link ClassLoader class loader} to 042 * a bean instance. 043 * <p>Invoked <i>after</i> the population of normal bean properties but 044 * <i>before</i> an initialization callback such as 045 * {@link InitializingBean InitializingBean's} 046 * {@link InitializingBean#afterPropertiesSet()} 047 * method or a custom init-method. 048 * @param classLoader the owning class loader; may be {@code null} in 049 * which case a default {@code ClassLoader} must be used, for example 050 * the {@code ClassLoader} obtained via 051 * {@link org.springframework.util.ClassUtils#getDefaultClassLoader()} 052 */ 053 void setBeanClassLoader(ClassLoader classLoader); 054 055}