本文整理汇总了Java中org.springframework.beans.factory.support.BeanNameGenerator类的典型用法代码示例。如果您正苦于以下问题:Java BeanNameGenerator类的具体用法?Java BeanNameGenerator怎么用?Java BeanNameGenerator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BeanNameGenerator类属于org.springframework.beans.factory.support包,在下文中一共展示了BeanNameGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createContext
import org.springframework.beans.factory.support.BeanNameGenerator; //导入依赖的package包/类
private ApplicationContext createContext(ScopedProxyMode scopedProxyMode) {
GenericWebApplicationContext context = new GenericWebApplicationContext();
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
scanner.setIncludeAnnotationConfig(false);
scanner.setBeanNameGenerator(new BeanNameGenerator() {
@Override
public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
return definition.getScope();
}
});
scanner.setScopedProxyMode(scopedProxyMode);
// Scan twice in order to find errors in the bean definition compatibility check.
scanner.scan(getClass().getPackage().getName());
scanner.scan(getClass().getPackage().getName());
context.refresh();
return context;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:ClassPathBeanDefinitionScannerScopeIntegrationTests.java
示例2: postProcessBeanDefinitionRegistry
import org.springframework.beans.factory.support.BeanNameGenerator; //导入依赖的package包/类
@Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
if (registry.containsBeanDefinition("restServer")) {
BeanDefinition beanDefinition = registry.getBeanDefinition("restServer");
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
scanner.addIncludeFilter(new AnnotationTypeFilter(Path.class));
BeanNameGenerator nameGenerator = new AnnotationBeanNameGenerator();
List<RuntimeBeanReference> beanNames = new ManagedList<>();
for (BeanDefinition definition : scanner.findCandidateComponents("net.techreadiness")) {
String beanName = nameGenerator.generateBeanName(definition, registry);
beanNames.add(new RuntimeBeanReference(beanName));
}
beanNames.addAll((Collection<? extends RuntimeBeanReference>) beanDefinition.getPropertyValues()
.getPropertyValue("serviceBeans").getValue());
beanDefinition.getPropertyValues().add("serviceBeans", beanNames);
}
}
示例3: ConfigurationClassParser
import org.springframework.beans.factory.support.BeanNameGenerator; //导入依赖的package包/类
/**
* Create a new {@link ConfigurationClassParser} instance that will be used
* to populate the set of configuration classes.
*/
public ConfigurationClassParser(MetadataReaderFactory metadataReaderFactory,
ProblemReporter problemReporter, Environment environment, ResourceLoader resourceLoader,
BeanNameGenerator componentScanBeanNameGenerator, BeanDefinitionRegistry registry) {
this.metadataReaderFactory = metadataReaderFactory;
this.problemReporter = problemReporter;
this.environment = environment;
this.resourceLoader = resourceLoader;
this.registry = registry;
this.componentScanParser = new ComponentScanAnnotationParser(
resourceLoader, environment, componentScanBeanNameGenerator, registry);
this.conditionEvaluator = new ConditionEvaluator(registry, environment, resourceLoader);
}
示例4: ComponentScanAnnotationParser
import org.springframework.beans.factory.support.BeanNameGenerator; //导入依赖的package包/类
public ComponentScanAnnotationParser(ResourceLoader resourceLoader, Environment environment,
BeanNameGenerator beanNameGenerator, BeanDefinitionRegistry registry) {
this.resourceLoader = resourceLoader;
this.environment = environment;
this.beanNameGenerator = beanNameGenerator;
this.registry = registry;
}
示例5: parseBeanNameGenerator
import org.springframework.beans.factory.support.BeanNameGenerator; //导入依赖的package包/类
protected void parseBeanNameGenerator(Element element, ClassPathBeanDefinitionScanner scanner) {
if (element.hasAttribute(NAME_GENERATOR_ATTRIBUTE)) {
BeanNameGenerator beanNameGenerator = (BeanNameGenerator) instantiateUserDefinedStrategy(
element.getAttribute(NAME_GENERATOR_ATTRIBUTE), BeanNameGenerator.class,
scanner.getResourceLoader().getClassLoader());
scanner.setBeanNameGenerator(beanNameGenerator);
}
}
示例6: ConfigurationClassBeanDefinitionReader
import org.springframework.beans.factory.support.BeanNameGenerator; //导入依赖的package包/类
/**
* Create a new {@link ConfigurationClassBeanDefinitionReader} instance that will be used
* to populate the given {@link BeanDefinitionRegistry}.
*/
public ConfigurationClassBeanDefinitionReader(BeanDefinitionRegistry registry, SourceExtractor sourceExtractor,
ProblemReporter problemReporter, MetadataReaderFactory metadataReaderFactory,
ResourceLoader resourceLoader, Environment environment, BeanNameGenerator importBeanNameGenerator) {
this.registry = registry;
this.sourceExtractor = sourceExtractor;
this.problemReporter = problemReporter;
this.metadataReaderFactory = metadataReaderFactory;
this.resourceLoader = resourceLoader;
this.environment = environment;
this.importBeanNameGenerator = importBeanNameGenerator;
this.conditionEvaluator = new ConditionEvaluator(registry, environment, resourceLoader);
}
示例7: ConfigurationClassBeanDefinitionReader
import org.springframework.beans.factory.support.BeanNameGenerator; //导入依赖的package包/类
/**
* Create a new {@link ConfigurationClassBeanDefinitionReader} instance that will be used
* to populate the given {@link BeanDefinitionRegistry}.
*/
ConfigurationClassBeanDefinitionReader(BeanDefinitionRegistry registry, SourceExtractor sourceExtractor,
ResourceLoader resourceLoader, Environment environment, BeanNameGenerator importBeanNameGenerator,
ImportRegistry importRegistry) {
this.registry = registry;
this.sourceExtractor = sourceExtractor;
this.resourceLoader = resourceLoader;
this.environment = environment;
this.importBeanNameGenerator = importBeanNameGenerator;
this.importRegistry = importRegistry;
this.conditionEvaluator = new ConditionEvaluator(registry, environment, resourceLoader);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:ConfigurationClassBeanDefinitionReader.java
示例8: customBeanNameGenerator
import org.springframework.beans.factory.support.BeanNameGenerator; //导入依赖的package包/类
@Test
public void customBeanNameGenerator() throws Exception {
TestSpringApplication application = new TestSpringApplication(
ExampleWebConfig.class);
BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
application.setBeanNameGenerator(beanNameGenerator);
this.context = application.run();
verify(application.getLoader()).setBeanNameGenerator(beanNameGenerator);
Object actualGenerator = this.context
.getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR);
assertThat(actualGenerator).isSameAs(beanNameGenerator);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:SpringApplicationTests.java
示例9: customBeanNameGeneratorWithNonWebApplication
import org.springframework.beans.factory.support.BeanNameGenerator; //导入依赖的package包/类
@Test
public void customBeanNameGeneratorWithNonWebApplication() throws Exception {
TestSpringApplication application = new TestSpringApplication(
ExampleWebConfig.class);
application.setWebEnvironment(false);
BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
application.setBeanNameGenerator(beanNameGenerator);
this.context = application.run();
verify(application.getLoader()).setBeanNameGenerator(beanNameGenerator);
Object actualGenerator = this.context
.getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR);
assertThat(actualGenerator).isSameAs(beanNameGenerator);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:SpringApplicationTests.java
示例10: customBeanNameGenerator
import org.springframework.beans.factory.support.BeanNameGenerator; //导入依赖的package包/类
@Test
public void customBeanNameGenerator() throws Exception {
TestSpringApplication application = new TestSpringApplication(
ExampleWebConfig.class);
BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
application.setBeanNameGenerator(beanNameGenerator);
this.context = application.run();
verify(application.getLoader()).setBeanNameGenerator(beanNameGenerator);
Object bean = this.context
.getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR);
assertThat(bean).isSameAs(beanNameGenerator);
}
示例11: ConfigurationClassParser
import org.springframework.beans.factory.support.BeanNameGenerator; //导入依赖的package包/类
/**
* Create a new {@link ConfigurationClassParser} instance that will be used
* to populate the set of configuration classes.
*/
public ConfigurationClassParser(MetadataReaderFactory metadataReaderFactory,
ProblemReporter problemReporter, Environment environment, ResourceLoader resourceLoader,
BeanNameGenerator componentScanBeanNameGenerator, BeanDefinitionRegistry registry) {
this.metadataReaderFactory = metadataReaderFactory;
this.problemReporter = problemReporter;
this.environment = environment;
this.resourceLoader = resourceLoader;
this.registry = registry;
this.componentScanParser = new ComponentScanAnnotationParser(
resourceLoader, environment, componentScanBeanNameGenerator, registry);
}
示例12: customBeanNameGenerator
import org.springframework.beans.factory.support.BeanNameGenerator; //导入依赖的package包/类
@Test
public void customBeanNameGenerator() throws Exception {
TestSpringApplication application = new TestSpringApplication(
ExampleWebConfig.class);
BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
application.setBeanNameGenerator(beanNameGenerator);
this.context = application.run();
verify(application.getLoader()).setBeanNameGenerator(beanNameGenerator);
assertThat(
this.context
.getBean(AnnotationConfigUtils.CONFIGURATION_BEAN_NAME_GENERATOR),
sameInstance((Object) beanNameGenerator));
}
示例13: ConfigurationClassBeanDefinitionReader
import org.springframework.beans.factory.support.BeanNameGenerator; //导入依赖的package包/类
/**
* Create a new {@link ConfigurationClassBeanDefinitionReader} instance that will be used
* to populate the given {@link BeanDefinitionRegistry}.
*/
public ConfigurationClassBeanDefinitionReader(
BeanDefinitionRegistry registry, SourceExtractor sourceExtractor,
ProblemReporter problemReporter, MetadataReaderFactory metadataReaderFactory,
ResourceLoader resourceLoader, Environment environment, BeanNameGenerator importBeanNameGenerator) {
this.registry = registry;
this.sourceExtractor = sourceExtractor;
this.problemReporter = problemReporter;
this.metadataReaderFactory = metadataReaderFactory;
this.resourceLoader = resourceLoader;
this.environment = environment;
this.importBeanNameGenerator = importBeanNameGenerator;
}
示例14: ConfigurationClassBeanDefinitionReader
import org.springframework.beans.factory.support.BeanNameGenerator; //导入依赖的package包/类
/**
* Create a new {@link ConfigurationClassBeanDefinitionReader} instance that will be used to populate the given
* {@link BeanDefinitionRegistry}.
*/
public ConfigurationClassBeanDefinitionReader(final BeanDefinitionRegistry registry, final SourceExtractor sourceExtractor,
final ProblemReporter problemReporter, final MetadataReaderFactory metadataReaderFactory, final ResourceLoader resourceLoader,
final Environment environment, final BeanNameGenerator importBeanNameGenerator) {
this.registry = registry;
this.sourceExtractor = sourceExtractor;
this.problemReporter = problemReporter;
this.metadataReaderFactory = metadataReaderFactory;
this.resourceLoader = resourceLoader;
this.environment = environment;
this.importBeanNameGenerator = importBeanNameGenerator;
}
开发者ID:ahoehma,项目名称:spring-autowire-qualified-beans,代码行数:17,代码来源:ConfigurationClassBeanDefinitionReader.java
示例15: initialize
import org.springframework.beans.factory.support.BeanNameGenerator; //导入依赖的package包/类
private void initialize(String defaultProfile, boolean autoScan) {
ServerConfiguration serverConfiguration = mainClass.getAnnotation(ServerConfiguration.class);
if (serverConfiguration != null && serverConfiguration.beanNameGenerator() != BeanNameGenerator.class) {
try {
applicationContext.setBeanNameGenerator(serverConfiguration.beanNameGenerator().newInstance());
} catch (Exception ignored) {
}
}
applicationContext.register(mainClass);
if (autoScan) {
applicationContext.scan(mainClass.getPackage().getName());
}
Set<String> activeProfiles = Sets.newLinkedHashSet();
String profileProperty = System.getProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, defaultProfile);
if (StringUtils.isNotBlank(profileProperty)) {
applicationContext.getEnvironment().setActiveProfiles(StringUtils.split(profileProperty, ","));
Collections.addAll(activeProfiles, StringUtils.split(profileProperty, ","));
logger.warn("activeProfiles are {}", activeProfiles);
}
Set<Resource> resources = getPropertiesResources(serverConfiguration == null ? null : serverConfiguration.properties());
ServerPropertiesConfigurer serverPropertiesConfigurer = new ServerPropertiesConfigurer(activeProfiles, resources);
serverPropertiesConfigurer.setIgnoreUnresolvablePlaceholders(true);
applicationContext.addBeanFactoryPostProcessor(serverPropertiesConfigurer);
this.properties = ServerPropertiesConfigurer.mergeProperties(activeProfiles, resources);
applicationContext.setEnvironment(new StandardEnvironment() {
@Override
protected void customizePropertySources(MutablePropertySources propertySources) {
propertySources.addFirst(new PropertiesPropertySource("applicationProperties", properties));
super.customizePropertySources(propertySources);
}
});
for (ServerProcessor serverProcessor : ServerProcessor.values()) {
serverProcessor.register(mainClass, applicationContext, properties);
}
if (defaultProfile != null && !activeProfiles.contains(defaultProfile)) {
pidFileWriter = new PidFileWriter(new File(System.getProperty("app.home", "."), "logs/pid"));
}
applicationContext.refresh();
}