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


Java AnnotationConfigUtils类代码示例

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


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

示例1: asyncAdvisor

import org.springframework.context.annotation.AnnotationConfigUtils; //导入依赖的package包/类
@Bean(name=AnnotationConfigUtils.ASYNC_ANNOTATION_PROCESSOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public AsyncAnnotationBeanPostProcessor asyncAdvisor() {
	Assert.notNull(this.enableAsync, "@EnableAsync annotation metadata was not injected");
	AsyncAnnotationBeanPostProcessor bpp = new AsyncAnnotationBeanPostProcessor();
	Class<? extends Annotation> customAsyncAnnotation = enableAsync.getClass("annotation");
	if (customAsyncAnnotation != AnnotationUtils.getDefaultValue(EnableAsync.class, "annotation")) {
		bpp.setAsyncAnnotationType(customAsyncAnnotation);
	}
	if (this.executor != null) {
		bpp.setExecutor(this.executor);
	}
	bpp.setProxyTargetClass(this.enableAsync.getBoolean("proxyTargetClass"));
	bpp.setOrder(this.enableAsync.<Integer>getNumber("order"));
	return bpp;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:ProxyAsyncConfiguration.java

示例2: customBeanNameIsRespected

import org.springframework.context.annotation.AnnotationConfigUtils; //导入依赖的package包/类
@Test
public void customBeanNameIsRespected() {
	GenericApplicationContext ac = new GenericApplicationContext();
	AnnotationConfigUtils.registerAnnotationConfigProcessors(ac);
	ac.registerBeanDefinition("config", new RootBeanDefinition(ConfigWithBeanWithCustomName.class));
	ac.refresh();
	assertSame(ac.getBean("customName"), ConfigWithBeanWithCustomName.testBean);

	// method name should not be registered
	try {
		ac.getBean("methodName");
		fail("bean should not have been registered with 'methodName'");
	}
	catch (NoSuchBeanDefinitionException ex) {
		// expected
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:ConfigurationClassProcessingTests.java

示例3: testAutowiredFieldWithSingleNonQualifiedCandidate

import org.springframework.context.annotation.AnnotationConfigUtils; //导入依赖的package包/类
@Test
public void testAutowiredFieldWithSingleNonQualifiedCandidate() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs = new ConstructorArgumentValues();
	cavs.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
	context.registerBeanDefinition(JUERGEN, person);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedFieldTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	try {
		context.refresh();
		fail("expected BeanCreationException");
	}
	catch (BeanCreationException e) {
		assertTrue(e.getRootCause() instanceof NoSuchBeanDefinitionException);
		assertEquals("autowired", e.getBeanName());
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:QualifierAnnotationAutowireContextTests.java

示例4: testAutowiredMethodParameterWithSingleNonQualifiedCandidate

import org.springframework.context.annotation.AnnotationConfigUtils; //导入依赖的package包/类
@Test
public void testAutowiredMethodParameterWithSingleNonQualifiedCandidate() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs = new ConstructorArgumentValues();
	cavs.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
	context.registerBeanDefinition(JUERGEN, person);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	try {
		context.refresh();
		fail("expected BeanCreationException");
	}
	catch (BeanCreationException e) {
		assertTrue(e.getRootCause() instanceof NoSuchBeanDefinitionException);
		assertEquals("autowired", e.getBeanName());
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:QualifierAnnotationAutowireContextTests.java

示例5: testAutowiredConstructorArgumentWithSingleNonQualifiedCandidate

import org.springframework.context.annotation.AnnotationConfigUtils; //导入依赖的package包/类
@Test
public void testAutowiredConstructorArgumentWithSingleNonQualifiedCandidate() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs = new ConstructorArgumentValues();
	cavs.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
	context.registerBeanDefinition(JUERGEN, person);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedConstructorArgumentTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	try {
		context.refresh();
		fail("expected BeanCreationException");
	}
	catch (BeanCreationException e) {
		assertTrue(e instanceof UnsatisfiedDependencyException);
		assertEquals("autowired", e.getBeanName());
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:QualifierAnnotationAutowireContextTests.java

示例6: testAutowiredMethodParameterWithSingleQualifiedCandidate

import org.springframework.context.annotation.AnnotationConfigUtils; //导入依赖的package包/类
@Test
public void testAutowiredMethodParameterWithSingleQualifiedCandidate() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs = new ConstructorArgumentValues();
	cavs.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
	person.addQualifier(new AutowireCandidateQualifier(TestQualifier.class));
	context.registerBeanDefinition(JUERGEN, person);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	context.refresh();
	QualifiedMethodParameterTestBean bean =
			(QualifiedMethodParameterTestBean) context.getBean("autowired");
	assertEquals(JUERGEN, bean.getPerson().getName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:QualifierAnnotationAutowireContextTests.java

示例7: testAutowiredMethodParameterWithStaticallyQualifiedCandidate

import org.springframework.context.annotation.AnnotationConfigUtils; //导入依赖的package包/类
@Test
public void testAutowiredMethodParameterWithStaticallyQualifiedCandidate() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs = new ConstructorArgumentValues();
	cavs.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person = new RootBeanDefinition(QualifiedPerson.class, cavs, null);
	context.registerBeanDefinition(JUERGEN,
			ScopedProxyUtils.createScopedProxy(new BeanDefinitionHolder(person, JUERGEN), context, true).getBeanDefinition());
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	context.refresh();
	QualifiedMethodParameterTestBean bean =
			(QualifiedMethodParameterTestBean) context.getBean("autowired");
	assertEquals(JUERGEN, bean.getPerson().getName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:QualifierAnnotationAutowireContextTests.java

示例8: testAutowiredMethodParameterWithStaticallyQualifiedCandidateAmongOthers

import org.springframework.context.annotation.AnnotationConfigUtils; //导入依赖的package包/类
@Test
public void testAutowiredMethodParameterWithStaticallyQualifiedCandidateAmongOthers() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs = new ConstructorArgumentValues();
	cavs.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person = new RootBeanDefinition(QualifiedPerson.class, cavs, null);
	ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
	cavs2.addGenericArgumentValue(MARK);
	RootBeanDefinition person2 = new RootBeanDefinition(DefaultValueQualifiedPerson.class, cavs2, null);
	context.registerBeanDefinition(JUERGEN, person);
	context.registerBeanDefinition(MARK, person2);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	context.refresh();
	QualifiedMethodParameterTestBean bean =
			(QualifiedMethodParameterTestBean) context.getBean("autowired");
	assertEquals(JUERGEN, bean.getPerson().getName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:QualifierAnnotationAutowireContextTests.java

示例9: testAutowiredConstructorArgumentWithSingleQualifiedCandidate

import org.springframework.context.annotation.AnnotationConfigUtils; //导入依赖的package包/类
@Test
public void testAutowiredConstructorArgumentWithSingleQualifiedCandidate() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs = new ConstructorArgumentValues();
	cavs.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person = new RootBeanDefinition(Person.class, cavs, null);
	person.addQualifier(new AutowireCandidateQualifier(TestQualifier.class));
	context.registerBeanDefinition(JUERGEN, person);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedConstructorArgumentTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	context.refresh();
	QualifiedConstructorArgumentTestBean bean =
			(QualifiedConstructorArgumentTestBean) context.getBean("autowired");
	assertEquals(JUERGEN, bean.getPerson().getName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:QualifierAnnotationAutowireContextTests.java

示例10: testAutowiredFieldWithMultipleNonQualifiedCandidates

import org.springframework.context.annotation.AnnotationConfigUtils; //导入依赖的package包/类
@Test
public void testAutowiredFieldWithMultipleNonQualifiedCandidates() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs1 = new ConstructorArgumentValues();
	cavs1.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person1 = new RootBeanDefinition(Person.class, cavs1, null);
	ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
	cavs2.addGenericArgumentValue(MARK);
	RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
	context.registerBeanDefinition(JUERGEN, person1);
	context.registerBeanDefinition(MARK, person2);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedFieldTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	try {
		context.refresh();
		fail("expected BeanCreationException");
	}
	catch (BeanCreationException e) {
		assertTrue(e.getRootCause() instanceof NoSuchBeanDefinitionException);
		assertEquals("autowired", e.getBeanName());
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:QualifierAnnotationAutowireContextTests.java

示例11: testAutowiredMethodParameterWithMultipleNonQualifiedCandidates

import org.springframework.context.annotation.AnnotationConfigUtils; //导入依赖的package包/类
@Test
public void testAutowiredMethodParameterWithMultipleNonQualifiedCandidates() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs1 = new ConstructorArgumentValues();
	cavs1.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person1 = new RootBeanDefinition(Person.class, cavs1, null);
	ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
	cavs2.addGenericArgumentValue(MARK);
	RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
	context.registerBeanDefinition(JUERGEN, person1);
	context.registerBeanDefinition(MARK, person2);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	try {
		context.refresh();
		fail("expected BeanCreationException");
	}
	catch (BeanCreationException e) {
		assertTrue(e.getRootCause() instanceof NoSuchBeanDefinitionException);
		assertEquals("autowired", e.getBeanName());
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:QualifierAnnotationAutowireContextTests.java

示例12: testAutowiredConstructorArgumentWithMultipleNonQualifiedCandidates

import org.springframework.context.annotation.AnnotationConfigUtils; //导入依赖的package包/类
@Test
public void testAutowiredConstructorArgumentWithMultipleNonQualifiedCandidates() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs1 = new ConstructorArgumentValues();
	cavs1.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person1 = new RootBeanDefinition(Person.class, cavs1, null);
	ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
	cavs2.addGenericArgumentValue(MARK);
	RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
	context.registerBeanDefinition(JUERGEN, person1);
	context.registerBeanDefinition(MARK, person2);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedConstructorArgumentTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	try {
		context.refresh();
		fail("expected BeanCreationException");
	}
	catch (BeanCreationException e) {
		assertTrue(e instanceof UnsatisfiedDependencyException);
		assertEquals("autowired", e.getBeanName());
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:QualifierAnnotationAutowireContextTests.java

示例13: testAutowiredFieldResolvesQualifiedCandidate

import org.springframework.context.annotation.AnnotationConfigUtils; //导入依赖的package包/类
@Test
public void testAutowiredFieldResolvesQualifiedCandidate() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs1 = new ConstructorArgumentValues();
	cavs1.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person1 = new RootBeanDefinition(Person.class, cavs1, null);
	person1.addQualifier(new AutowireCandidateQualifier(TestQualifier.class));
	ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
	cavs2.addGenericArgumentValue(MARK);
	RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
	context.registerBeanDefinition(JUERGEN, person1);
	context.registerBeanDefinition(MARK, person2);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedFieldTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	context.refresh();
	QualifiedFieldTestBean bean = (QualifiedFieldTestBean) context.getBean("autowired");
	assertEquals(JUERGEN, bean.getPerson().getName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:QualifierAnnotationAutowireContextTests.java

示例14: testAutowiredFieldResolvesMetaQualifiedCandidate

import org.springframework.context.annotation.AnnotationConfigUtils; //导入依赖的package包/类
@Test
public void testAutowiredFieldResolvesMetaQualifiedCandidate() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs1 = new ConstructorArgumentValues();
	cavs1.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person1 = new RootBeanDefinition(Person.class, cavs1, null);
	person1.addQualifier(new AutowireCandidateQualifier(TestQualifier.class));
	ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
	cavs2.addGenericArgumentValue(MARK);
	RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
	context.registerBeanDefinition(JUERGEN, person1);
	context.registerBeanDefinition(MARK, person2);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(MetaQualifiedFieldTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	context.refresh();
	MetaQualifiedFieldTestBean bean = (MetaQualifiedFieldTestBean) context.getBean("autowired");
	assertEquals(JUERGEN, bean.getPerson().getName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:QualifierAnnotationAutowireContextTests.java

示例15: testAutowiredMethodParameterResolvesQualifiedCandidate

import org.springframework.context.annotation.AnnotationConfigUtils; //导入依赖的package包/类
@Test
public void testAutowiredMethodParameterResolvesQualifiedCandidate() {
	GenericApplicationContext context = new GenericApplicationContext();
	ConstructorArgumentValues cavs1 = new ConstructorArgumentValues();
	cavs1.addGenericArgumentValue(JUERGEN);
	RootBeanDefinition person1 = new RootBeanDefinition(Person.class, cavs1, null);
	person1.addQualifier(new AutowireCandidateQualifier(TestQualifier.class));
	ConstructorArgumentValues cavs2 = new ConstructorArgumentValues();
	cavs2.addGenericArgumentValue(MARK);
	RootBeanDefinition person2 = new RootBeanDefinition(Person.class, cavs2, null);
	context.registerBeanDefinition(JUERGEN, person1);
	context.registerBeanDefinition(MARK, person2);
	context.registerBeanDefinition("autowired",
			new RootBeanDefinition(QualifiedMethodParameterTestBean.class));
	AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
	context.refresh();
	QualifiedMethodParameterTestBean bean =
			(QualifiedMethodParameterTestBean) context.getBean("autowired");
	assertEquals(JUERGEN, bean.getPerson().getName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:QualifierAnnotationAutowireContextTests.java


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