当前位置: 首页>>代码示例>>Java>>正文


Java AnnotatedGenericBeanDefinition.setScope方法代码示例

本文整理汇总了Java中org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition.setScope方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotatedGenericBeanDefinition.setScope方法的具体用法?Java AnnotatedGenericBeanDefinition.setScope怎么用?Java AnnotatedGenericBeanDefinition.setScope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition的用法示例。


在下文中一共展示了AnnotatedGenericBeanDefinition.setScope方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerBeanDefinitionForImportedConfigurationClass

import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; //导入方法依赖的package包/类
/**
 * Register the {@link Configuration} class itself as a bean definition.
 */
private void registerBeanDefinitionForImportedConfigurationClass(ConfigurationClass configClass) {
	AnnotationMetadata metadata = configClass.getMetadata();
	AnnotatedGenericBeanDefinition configBeanDef = new AnnotatedGenericBeanDefinition(metadata);

	ScopeMetadata scopeMetadata = scopeMetadataResolver.resolveScopeMetadata(configBeanDef);
	configBeanDef.setScope(scopeMetadata.getScopeName());
	String configBeanName = this.importBeanNameGenerator.generateBeanName(configBeanDef, this.registry);
	AnnotationConfigUtils.processCommonDefinitionAnnotations(configBeanDef, metadata);

	BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(configBeanDef, configBeanName);
	definitionHolder = AnnotationConfigUtils.applyScopedProxyMode(scopeMetadata, definitionHolder, this.registry);
	this.registry.registerBeanDefinition(definitionHolder.getBeanName(), definitionHolder.getBeanDefinition());
	configClass.setBeanName(configBeanName);

	if (logger.isDebugEnabled()) {
		logger.debug("Registered bean definition for imported class '" + configBeanName + "'");
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:ConfigurationClassBeanDefinitionReader.java

示例2: registerBean

import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; //导入方法依赖的package包/类
public void registerBean(Class<?> annotatedClass, String name,
		@SuppressWarnings("unchecked") Class<? extends Annotation>... qualifiers) {

	AnnotatedGenericBeanDefinition abd = new AnnotatedGenericBeanDefinition(annotatedClass);
	if (this.conditionEvaluator.shouldSkip(abd.getMetadata())) {
		return;
	}

	ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(abd);
	abd.setScope(scopeMetadata.getScopeName());
	String beanName = (name != null ? name : this.beanNameGenerator.generateBeanName(abd, this.registry));
	AnnotationConfigUtils.processCommonDefinitionAnnotations(abd);
	if (qualifiers != null) {
		for (Class<? extends Annotation> qualifier : qualifiers) {
			if (Primary.class.equals(qualifier)) {
				abd.setPrimary(true);
			}
			else if (Lazy.class.equals(qualifier)) {
				abd.setLazyInit(true);
			}
			else {
				abd.addQualifier(new AutowireCandidateQualifier(qualifier));
			}
		}
	}

	BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(abd, beanName);
	definitionHolder = AnnotationConfigUtils.applyScopedProxyMode(scopeMetadata, definitionHolder, this.registry);
	BeanDefinitionReaderUtils.registerBeanDefinition(definitionHolder, this.registry);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:AnnotatedBeanDefinitionReader.java

示例3: registerBean

import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; //导入方法依赖的package包/类
public void registerBean(Class<?> annotatedClass, String name,
		@SuppressWarnings("unchecked") Class<? extends Annotation>... qualifiers) {

	AnnotatedGenericBeanDefinition abd = new AnnotatedGenericBeanDefinition(annotatedClass);
	if (this.conditionEvaluator.shouldSkip(abd.getMetadata())) {
		return;
	}

	ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(abd);
	abd.setScope(scopeMetadata.getScopeName());
	String beanName = (name != null ? name : this.beanNameGenerator.generateBeanName(abd, this.registry));
	AnnotationConfigUtils.processCommonDefinitionAnnotations(abd);
	if (qualifiers != null) {
		for (Class<? extends Annotation> qualifier : qualifiers) {
			if (Primary.class == qualifier) {
				abd.setPrimary(true);
			}
			else if (Lazy.class == qualifier) {
				abd.setLazyInit(true);
			}
			else {
				abd.addQualifier(new AutowireCandidateQualifier(qualifier));
			}
		}
	}

	BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(abd, beanName);
	definitionHolder = AnnotationConfigUtils.applyScopedProxyMode(scopeMetadata, definitionHolder, this.registry);
	BeanDefinitionReaderUtils.registerBeanDefinition(definitionHolder, this.registry);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:31,代码来源:AnnotatedBeanDefinitionReader.java

示例4: registerBean

import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; //导入方法依赖的package包/类
private void registerBean(BeanDefinitionRegistry registry, String name,Class<?> beanClass) {
	AnnotatedGenericBeanDefinition abd = new AnnotatedGenericBeanDefinition(beanClass);

	ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(abd);
	abd.setScope(scopeMetadata.getScopeName());
	// 可以自动生成name
	String beanName = (name != null ? name : this.beanNameGenerator.generateBeanName(abd, registry));

	AnnotationConfigUtils.processCommonDefinitionAnnotations(abd);

	BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(abd,beanName);
	BeanDefinitionReaderUtils.registerBeanDefinition(definitionHolder,registry);
}
 
开发者ID:seagrape,项目名称:kekoa,代码行数:14,代码来源:MyBeanDefinitionRegistryPostProcessor.java

示例5: registerBean

import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; //导入方法依赖的package包/类
public void registerBean(Class<?> annotatedClass, String name, Class<? extends Annotation>... qualifiers) {
	AnnotatedGenericBeanDefinition abd = new AnnotatedGenericBeanDefinition(annotatedClass);
	AnnotationMetadata metadata = abd.getMetadata();
	if (metadata.isAnnotated(Profile.class.getName())) {
		AnnotationAttributes profile = MetadataUtils.attributesFor(metadata, Profile.class);
		if (!this.environment.acceptsProfiles(profile.getStringArray("value"))) {
			return;
		}
	}
	ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(abd);
	abd.setScope(scopeMetadata.getScopeName());
	String beanName = (name != null ? name : this.beanNameGenerator.generateBeanName(abd, this.registry));
	AnnotationConfigUtils.processCommonDefinitionAnnotations(abd);
	if (qualifiers != null) {
		for (Class<? extends Annotation> qualifier : qualifiers) {
			if (Primary.class.equals(qualifier)) {
				abd.setPrimary(true);
			}
			else if (Lazy.class.equals(qualifier)) {
				abd.setLazyInit(true);
			}
			else {
				abd.addQualifier(new AutowireCandidateQualifier(qualifier));
			}
		}
	}
	BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(abd, beanName);
	definitionHolder = AnnotationConfigUtils.applyScopedProxyMode(scopeMetadata, definitionHolder, this.registry);
	BeanDefinitionReaderUtils.registerBeanDefinition(definitionHolder, this.registry);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:31,代码来源:AnnotatedBeanDefinitionReader.java


注:本文中的org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition.setScope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。