AbstractBeanDefinitionReader.java
Upload User: jiancairen
Upload Date: 2007-08-27
Package Size: 26458k
Code Size: 2k
Category:

Java Develop

Development Platform:

Java

  1. /*
  2.  * Copyright 2002-2004 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. package org.springframework.beans.factory.support;
  17. import org.apache.commons.logging.Log;
  18. import org.apache.commons.logging.LogFactory;
  19. /**
  20.  * Abstract base class for bean definition readers which implement
  21.  * the BeanDefinitionReader interface.
  22.  *
  23.  * <p>Provides common properties like the bean factory to work on
  24.  * and the class loader to use for loading bean classes.
  25.  *
  26.  * @author Juergen Hoeller
  27.  * @since 11.12.2003
  28.  * @see BeanDefinitionReaderUtils
  29.  */
  30. public abstract class AbstractBeanDefinitionReader implements BeanDefinitionReader {
  31. protected final Log logger = LogFactory.getLog(getClass());
  32. private final BeanDefinitionRegistry beanFactory;
  33. private ClassLoader beanClassLoader = Thread.currentThread().getContextClassLoader();
  34. /**
  35.  * Create a new AbstractBeanDefinitionReader for the given factory.
  36.  * @param beanFactory the bean factory to work on
  37.  */
  38. protected AbstractBeanDefinitionReader(BeanDefinitionRegistry beanFactory) {
  39. this.beanFactory = beanFactory;
  40. }
  41. public BeanDefinitionRegistry getBeanFactory() {
  42. return beanFactory;
  43. }
  44. /**
  45.  * Set the class loader to use for bean classes.
  46.  * Default is the thread context class loader.
  47.  * <p>Setting this to null suggests to not load bean classes but just register
  48.  * bean definitions with class names, for example when just registering beans
  49.  * in a registry but not actually instantiating them in a factory.
  50.  * @see java.lang.Thread#getContextClassLoader
  51.  */
  52. public void setBeanClassLoader(ClassLoader beanClassLoader) {
  53. this.beanClassLoader = beanClassLoader;
  54. }
  55. public ClassLoader getBeanClassLoader() {
  56. return beanClassLoader;
  57. }
  58. }