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


Java AnnotatedGenericBeanDefinition类代码示例

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


AnnotatedGenericBeanDefinition类属于org.springframework.beans.factory.annotation包,在下文中一共展示了AnnotatedGenericBeanDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
	BeanDefinition configBeanDef = new AnnotatedGenericBeanDefinition(metadata);
	if (ConfigurationClassUtils.checkConfigurationClassCandidate(configBeanDef, this.metadataReaderFactory)) {
		String configBeanName = this.importBeanNameGenerator.generateBeanName(configBeanDef, this.registry);
		this.registry.registerBeanDefinition(configBeanName, configBeanDef);
		configClass.setBeanName(configBeanName);
		if (logger.isDebugEnabled()) {
			logger.debug(String.format("Registered bean definition for imported @Configuration class %s", configBeanName));
		}
	}
	else {
		this.problemReporter.error(
				new InvalidConfigurationImportProblem(metadata.getClassName(), configClass.getResource(), metadata));
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:ConfigurationClassBeanDefinitionReader.java

示例2: 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

示例3: testViewScopedClass

import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; //导入依赖的package包/类
@Test
public void testViewScopedClass() {
	GenericApplicationContext acx = new GenericApplicationContext();
	AnnotationConfigUtils.registerAnnotationConfigProcessors(acx);

	acx.registerBeanDefinition("viewScopedClass", new AnnotatedGenericBeanDefinition(
		new StandardAnnotationMetadata(ViewScopedClass.class)));
	acx.registerBeanDefinition("scopedBeansConfiguration", new RootBeanDefinition(
		ScopedBeansConfiguration.class));
	acx.addBeanFactoryPostProcessor(JsfScopeAnnotationsAutoConfiguration.jsfScopeAnnotationsConfigurer(acx.getEnvironment()));
	acx.addBeanFactoryPostProcessor(CdiScopeAnnotationsAutoConfiguration.cdiScopeAnnotationsConfigurer(acx.getEnvironment()));
	acx.refresh();

	assertThat(acx.getBeanDefinition("viewScopedClass").getScope())
		.isEqualTo(ViewScope.SCOPE_VIEW);
	assertThat(acx.getBeanDefinition("viewScopedBean").getScope())
		.isEqualTo(ViewScope.SCOPE_VIEW);
}
 
开发者ID:joinfaces,项目名称:joinfaces,代码行数:19,代码来源:JsfCdiToSpringApplicationBeanFactoryPostProcessorIT.java

示例4: testSessionScopedClass

import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; //导入依赖的package包/类
@Test
public void testSessionScopedClass() {
	GenericApplicationContext acx = new GenericApplicationContext();
	AnnotationConfigUtils.registerAnnotationConfigProcessors(acx);

	acx.registerBeanDefinition("sessionScopedClass", new AnnotatedGenericBeanDefinition(
		new StandardAnnotationMetadata(SessionScopedClass.class)));
	acx.registerBeanDefinition("scopedBeansConfiguration", new RootBeanDefinition(
		ScopedBeansConfiguration.class));
	acx.addBeanFactoryPostProcessor(JsfScopeAnnotationsAutoConfiguration.jsfScopeAnnotationsConfigurer(acx.getEnvironment()));
	acx.addBeanFactoryPostProcessor(CdiScopeAnnotationsAutoConfiguration.cdiScopeAnnotationsConfigurer(acx.getEnvironment()));
	acx.refresh();

	assertThat(acx.getBeanDefinition("sessionScopedClass").getScope())
		.isEqualTo(WebApplicationContext.SCOPE_SESSION);
	assertThat(acx.getBeanDefinition("sessionScopedBean").getScope())
		.isEqualTo(WebApplicationContext.SCOPE_SESSION);
}
 
开发者ID:joinfaces,项目名称:joinfaces,代码行数:19,代码来源:JsfCdiToSpringApplicationBeanFactoryPostProcessorIT.java

示例5: testNoScopedClass

import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; //导入依赖的package包/类
@Test
public void testNoScopedClass() {
	GenericApplicationContext acx = new GenericApplicationContext();
	AnnotationConfigUtils.registerAnnotationConfigProcessors(acx);

	acx.registerBeanDefinition("noScopedClass", new AnnotatedGenericBeanDefinition(
		new StandardAnnotationMetadata(NoScopedClass.class)));
	acx.registerBeanDefinition("scopedBeansConfiguration", new RootBeanDefinition(
		ScopedBeansConfiguration.class));
	acx.addBeanFactoryPostProcessor(JsfScopeAnnotationsAutoConfiguration.jsfScopeAnnotationsConfigurer(acx.getEnvironment()));
	acx.addBeanFactoryPostProcessor(CdiScopeAnnotationsAutoConfiguration.cdiScopeAnnotationsConfigurer(acx.getEnvironment()));
	acx.refresh();

	assertThat(acx.getBeanDefinition("noScopedClass").getScope())
		.isEqualTo("");
	assertThat(acx.getBeanDefinition("noScopedBean").getScope())
		.isEqualTo("");

}
 
开发者ID:joinfaces,项目名称:joinfaces,代码行数:20,代码来源:JsfCdiToSpringApplicationBeanFactoryPostProcessorIT.java

示例6: 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

示例7: postProcessBeanFactory

import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; //导入依赖的package包/类
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    System.out.println("------ register custom bean in BeanFactoryPostProcessor");
    beanFactory.registerSingleton("createByBeanFactoryPostProcessor", new SimpleBeanInBeanFactoryPostProcessor());
    if(beanFactory instanceof BeanDefinitionRegistry) {
        BeanDefinitionReaderUtils.registerBeanDefinition(
                new BeanDefinitionHolder(new AnnotatedGenericBeanDefinition(SimpleBeanWithDefinitionInBeanFactoryPostProcessor.class), "simpleBeanWithDefinitionInBeanFactoryPostProcessor"),                             (BeanDefinitionRegistry) beanFactory
        );
    }
}
 
开发者ID:fangjian0423,项目名称:springboot-analysis,代码行数:11,代码来源:MyBeanFactoryPostProcessor.java

示例8: 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

示例9: resolveScopeMetadataShouldNotApplyScopedProxyModeToSingleton

import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; //导入依赖的package包/类
@Test
public void resolveScopeMetadataShouldNotApplyScopedProxyModeToSingleton() {
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithSingletonScope.class);
	ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
	assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata);
	assertEquals(BeanDefinition.SCOPE_SINGLETON, scopeMetadata.getScopeName());
	assertEquals(NO, scopeMetadata.getScopedProxyMode());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:AnnotationScopeMetadataResolverTests.java

示例10: resolveScopeMetadataShouldApplyScopedProxyModeToPrototype

import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; //导入依赖的package包/类
@Test
public void resolveScopeMetadataShouldApplyScopedProxyModeToPrototype() {
	this.scopeMetadataResolver = new AnnotationScopeMetadataResolver(INTERFACES);
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithPrototypeScope.class);
	ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
	assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata);
	assertEquals(BeanDefinition.SCOPE_PROTOTYPE, scopeMetadata.getScopeName());
	assertEquals(INTERFACES, scopeMetadata.getScopedProxyMode());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:AnnotationScopeMetadataResolverTests.java

示例11: resolveScopeMetadataShouldReadScopedProxyModeFromAnnotation

import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; //导入依赖的package包/类
@Test
public void resolveScopeMetadataShouldReadScopedProxyModeFromAnnotation() {
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithScopedProxy.class);
	ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
	assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata);
	assertEquals("request", scopeMetadata.getScopeName());
	assertEquals(TARGET_CLASS, scopeMetadata.getScopedProxyMode());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:AnnotationScopeMetadataResolverTests.java

示例12: customRequestScope

import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; //导入依赖的package包/类
@Test
public void customRequestScope() {
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(AnnotatedWithCustomRequestScope.class);
	ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
	assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata);
	assertEquals("request", scopeMetadata.getScopeName());
	assertEquals(NO, scopeMetadata.getScopedProxyMode());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:AnnotationScopeMetadataResolverTests.java

示例13: customRequestScopeViaAsm

import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; //导入依赖的package包/类
@Test
public void customRequestScopeViaAsm() throws IOException {
	MetadataReaderFactory readerFactory = new SimpleMetadataReaderFactory();
	MetadataReader reader = readerFactory.getMetadataReader(AnnotatedWithCustomRequestScope.class.getName());
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(reader.getAnnotationMetadata());
	ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
	assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata);
	assertEquals("request", scopeMetadata.getScopeName());
	assertEquals(NO, scopeMetadata.getScopedProxyMode());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:AnnotationScopeMetadataResolverTests.java

示例14: customRequestScopeWithAttribute

import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; //导入依赖的package包/类
@Test
public void customRequestScopeWithAttribute() {
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(
		AnnotatedWithCustomRequestScopeWithAttributeOverride.class);
	ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
	assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata);
	assertEquals("request", scopeMetadata.getScopeName());
	assertEquals(TARGET_CLASS, scopeMetadata.getScopedProxyMode());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:AnnotationScopeMetadataResolverTests.java

示例15: customRequestScopeWithAttributeViaAsm

import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; //导入依赖的package包/类
@Test
public void customRequestScopeWithAttributeViaAsm() throws IOException {
	MetadataReaderFactory readerFactory = new SimpleMetadataReaderFactory();
	MetadataReader reader = readerFactory.getMetadataReader(AnnotatedWithCustomRequestScopeWithAttributeOverride.class.getName());
	AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(reader.getAnnotationMetadata());
	ScopeMetadata scopeMetadata = this.scopeMetadataResolver.resolveScopeMetadata(bd);
	assertNotNull("resolveScopeMetadata(..) must *never* return null.", scopeMetadata);
	assertEquals("request", scopeMetadata.getScopeName());
	assertEquals(TARGET_CLASS, scopeMetadata.getScopedProxyMode());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:AnnotationScopeMetadataResolverTests.java


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