站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.1.0 API 文档英文版

ClassPathBeanDefinitionScanner (Spring Framework API 2.1) - Spring Framework 2.1.0 API 文档英文版


The Spring Framework

org.springframework.context.annotation
Class ClassPathBeanDefinitionScanner

java.lang.Object
  extended by org.springframework.context.annotation.ClassPathBeanDefinitionScanner
All Implemented Interfaces:
BeanDefinitionScanner, ResourceLoaderAware

public class ClassPathBeanDefinitionScanner
extends Object
implements BeanDefinitionScanner, ResourceLoaderAware

A BeanDefinitionScanner that detects bean candidates on the classpath.

Since:
2.1
Author:
Mark Fisher, Juergen Hoeller

Constructor Summary
ClassPathBeanDefinitionScanner(BeanDefinitionRegistry registry)
          Create a new ClassPathBeanDefinitionScanner for the given bean factory.
 
Method Summary
 int scan(String basePackage)
          Perform a scan within the specified base package.
 int scan(String[] basePackages)
          Perform a scan within the specified base packages.
 int scan(String[] basePackages, boolean useDefaultFilters, List<TypeFilter> excludeFilters, List<TypeFilter> includeFilters)
          Perform a scan within the specified base packages.
 int scan(String basePackage, boolean useDefaultFilters, List<TypeFilter> excludeFilters, List<TypeFilter> includeFilters)
          Perform a scan within the specified base package.
 void setBeanNameGenerator(BeanNameGenerator beanNameGenerator)
          Set the BeanNameGenerator to use for detected bean classes.
 void setIncludeAnnotationConfig(boolean includeAnnotationConfig)
          Specify whether to register annotation config post-processors.
 void setResourceLoader(ResourceLoader resourceLoader)
          Set the ResourceLoader to use for resource locations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassPathBeanDefinitionScanner

public ClassPathBeanDefinitionScanner(BeanDefinitionRegistry registry)
Create a new ClassPathBeanDefinitionScanner for the given bean factory.

If the passed-in bean factory does not only implement the BeanDefinitionRegistry interface but also the ResourceLoader interface, it will be used as default ResourceLoader as well. This will usually be the case for ApplicationContext implementations.

If given a plain BeanDefinitionRegistry, the default ResourceLoader will be a PathMatchingResourcePatternResolver.

Parameters:
registry - the BeanFactory to load bean definitions into, in the form of a BeanDefinitionRegistry
See Also:
setResourceLoader(org.springframework.core.io.ResourceLoader)
Method Detail

setResourceLoader

public void setResourceLoader(ResourceLoader resourceLoader)
Set the ResourceLoader to use for resource locations. This will typically be a ResourcePatternResolver implementation.

Default is PathMatchingResourcePatternResolver, also capable of resource pattern resolving through the ResourcePatternResolver interface.

Specified by:
setResourceLoader in interface ResourceLoaderAware
Parameters:
resourceLoader - ResourceLoader object to be used by this object
See Also:
ResourcePatternResolver, PathMatchingResourcePatternResolver

setBeanNameGenerator

public void setBeanNameGenerator(BeanNameGenerator beanNameGenerator)
Set the BeanNameGenerator to use for detected bean classes.

Default is a ComponentBeanNameGenerator.


setIncludeAnnotationConfig

public void setIncludeAnnotationConfig(boolean includeAnnotationConfig)
Specify whether to register annotation config post-processors.

The default is to register the post-processors. Turn this off to be able to ignore the annotations or to process them differently.


scan

public int scan(String basePackage)
Perform a scan within the specified base package.

Specified by:
scan in interface BeanDefinitionScanner
Parameters:
basePackage - the package to check for annotated classes
Returns:
number of beans registered

scan

public int scan(String[] basePackages)
Perform a scan within the specified base packages.

Specified by:
scan in interface BeanDefinitionScanner
Parameters:
basePackages - the packages to check for annotated classes
Returns:
number of beans registered

scan

public int scan(String basePackage,
                boolean useDefaultFilters,
                List<TypeFilter> excludeFilters,
                List<TypeFilter> includeFilters)
Perform a scan within the specified base package.

Parameters:
basePackage - the package to check for annotated classes
Returns:
number of beans registered

scan

public int scan(String[] basePackages,
                boolean useDefaultFilters,
                List<TypeFilter> excludeFilters,
                List<TypeFilter> includeFilters)
Perform a scan within the specified base packages.

Parameters:
basePackages - the packages to check for annotated classes
Returns:
number of beans registered

The Spring Framework

Copyright © 2002-2007 The Spring Framework.