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


Java AnnotatedBeanDefinitionReader类代码示例

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


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

示例1: suite

import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; //导入依赖的package包/类
public static Test suite() {
	GenericApplicationContext ac = new GenericApplicationContext();
	AnnotatedBeanDefinitionReader bdr = new AnnotatedBeanDefinitionReader(ac);
	bdr.setScopeMetadataResolver(new Jsr330ScopeMetadataResolver());

	bdr.registerBean(Convertible.class);
	bdr.registerBean(DriversSeat.class, Drivers.class);
	bdr.registerBean(Seat.class, Primary.class);
	bdr.registerBean(V8Engine.class);
	bdr.registerBean(SpareTire.class, "spare");
	bdr.registerBean(Cupholder.class);
	bdr.registerBean(Tire.class, Primary.class);
	bdr.registerBean(FuelTank.class);

	ac.refresh();
	Car car = ac.getBean(Car.class);

	return Tck.testsFor(car, false, true);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:SpringAtInjectTck.java

示例2: securityManagerDisallowsAccessToSystemEnvironmentButAllowsAccessToIndividualKeys

import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; //导入依赖的package包/类
@Test
public void securityManagerDisallowsAccessToSystemEnvironmentButAllowsAccessToIndividualKeys() {
	SecurityManager securityManager = new SecurityManager() {
		@Override
		public void checkPermission(Permission perm) {
			// Disallowing access to System#getenv means that our
			// ReadOnlySystemAttributesMap will come into play.
			if ("getenv.*".equals(perm.getName())) {
				throw new AccessControlException("Accessing the system environment is disallowed");
			}
		}
	};
	System.setSecurityManager(securityManager);

	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(bf);
	reader.register(C1.class);
	assertThat(bf.containsBean("c1"), is(true));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:EnvironmentSecurityManagerIntegrationTests.java

示例3: setUp

import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; //导入依赖的package包/类
@Before
public void setUp() {
	ServletContext servletContext = new MockServletContext();
	MockHttpServletRequest mockRequest = new MockHttpServletRequest(servletContext);
	mockRequest.setAttribute(FROM_CUSTOM_MOCK, FROM_CUSTOM_MOCK);
	RequestContextHolder.setRequestAttributes(new ServletWebRequest(mockRequest, new MockHttpServletResponse()));

	this.wac.setServletContext(servletContext);
	new AnnotatedBeanDefinitionReader(this.wac).register(WebConfig.class);
	this.wac.refresh();

	this.mockMvc = webAppContextSetup(this.wac)
			.defaultRequest(get("/").requestAttr(FROM_MVC_TEST_DEFAULT, FROM_MVC_TEST_DEFAULT))
			.alwaysExpect(status().isOk())
			.build();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:CustomRequestAttributesRequestContextHolderTests.java

示例4: securityManagerDisallowsAccessToSystemEnvironmentButAllowsAccessToIndividualKeys

import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; //导入依赖的package包/类
@Test
public void securityManagerDisallowsAccessToSystemEnvironmentButAllowsAccessToIndividualKeys() {
	SecurityManager securityManager = new SecurityManager() {
		@Override
		public void checkPermission(Permission perm) {
			// disallowing access to System#getenv means that our
			// ReadOnlySystemAttributesMap will come into play.
			if ("getenv.*".equals(perm.getName())) {
				throw new AccessControlException(
						"Accessing the system environment is disallowed");
			}
		}
	};
	System.setSecurityManager(securityManager);

	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(bf);
	reader.register(C1.class);
	assertThat(bf.containsBean("c1"), is(true));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:21,代码来源:EnvironmentSecurityManagerIntegrationTests.java

示例5: loadContexts

import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; //导入依赖的package包/类
private void loadContexts(Element element, BeanDefinitionRegistry beanDefinitionRegistry) {
    String externalDatabase = element.getAttribute("externalDatabase");
    if (StringUtils.isBlank(externalDatabase) || externalDatabase.equals(Boolean.FALSE.toString())) {
        AnnotatedBeanDefinitionReader definitionReader = new AnnotatedBeanDefinitionReader(beanDefinitionRegistry);
        definitionReader.register(ScoreDefaultDatasourceContext.class);
        definitionReader.register(ScoreDatabaseContext.class);
    }

    String repositoriesContextPath = "META-INF/spring/score/context/scoreRepositoryContext.xml";

    String ignoreEngineJobs = element.getAttribute("ignoreEngineJobs");
    if(StringUtils.isNotBlank(ignoreEngineJobs) && ignoreEngineJobs.equals(Boolean.TRUE.toString())){
        new XmlBeanDefinitionReader(beanDefinitionRegistry).loadBeanDefinitions(repositoriesContextPath);
    }
    else{
        new XmlBeanDefinitionReader(beanDefinitionRegistry).loadBeanDefinitions(repositoriesContextPath,ENGINE_JOBS_CONTEXT_LOCATION);
    }
}
 
开发者ID:CloudSlang,项目名称:score,代码行数:19,代码来源:EngineBeanDefinitionParser.java

示例6: securityManagerDisallowsAccessToSystemEnvironmentAndDisallowsAccessToIndividualKey

import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; //导入依赖的package包/类
@Test
public void securityManagerDisallowsAccessToSystemEnvironmentAndDisallowsAccessToIndividualKey() {
	SecurityManager securityManager = new SecurityManager() {
		@Override
		public void checkPermission(Permission perm) {
			// Disallowing access to System#getenv means that our
			// ReadOnlySystemAttributesMap will come into play.
			if ("getenv.*".equals(perm.getName())) {
				throw new AccessControlException("Accessing the system environment is disallowed");
			}
			// Disallowing access to the spring.profiles.active property means that
			// the BeanDefinitionReader won't be able to determine which profiles are
			// active. We should see an INFO-level message in the console about this
			// and as a result, any components marked with a non-default profile will
			// be ignored.
			if (("getenv." + AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME).equals(perm.getName())) {
				throw new AccessControlException(
						format("Accessing system environment variable [%s] is disallowed",
								AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME));
			}
		}
	};
	System.setSecurityManager(securityManager);

	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(bf);
	reader.register(C1.class);
	assertThat(bf.containsBean("c1"), is(false));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:30,代码来源:EnvironmentSecurityManagerIntegrationTests.java

示例7: annotatedBeanDefinitionReader_inheritsEnvironmentFromEnvironmentCapableBDR

import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; //导入依赖的package包/类
@Test
public void annotatedBeanDefinitionReader_inheritsEnvironmentFromEnvironmentCapableBDR() {
	GenericApplicationContext ctx = new GenericApplicationContext();
	ctx.setEnvironment(prodEnv);
	new AnnotatedBeanDefinitionReader(ctx).register(Config.class);
	ctx.refresh();
	assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
	assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:10,代码来源:EnvironmentSystemIntegrationTests.java

示例8: BeanDefinitionLoader

import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; //导入依赖的package包/类
/**
 * Create a new {@link BeanDefinitionLoader} that will load beans into the specified
 * {@link BeanDefinitionRegistry}.
 * @param registry the bean definition registry that will contain the loaded beans
 * @param sources the bean sources
 */
BeanDefinitionLoader(BeanDefinitionRegistry registry, Object... sources) {
	Assert.notNull(registry, "Registry must not be null");
	Assert.notEmpty(sources, "Sources must not be empty");
	this.sources = sources;
	this.annotatedReader = new AnnotatedBeanDefinitionReader(registry);
	this.xmlReader = new XmlBeanDefinitionReader(registry);
	if (isGroovyPresent()) {
		this.groovyReader = new GroovyBeanDefinitionReader(registry);
	}
	this.scanner = new ClassPathBeanDefinitionScanner(registry);
	this.scanner.addExcludeFilter(new ClassExcludeFilter(sources));
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:BeanDefinitionLoader.java

示例9: customizeContext

import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; //导入依赖的package包/类
@Override
public void customizeContext(ConfigurableApplicationContext context,
		MergedContextConfiguration mergedContextConfiguration) {
	BeanDefinitionRegistry registry = getBeanDefinitionRegistry(context);
	AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(
			registry);
	registerCleanupPostProcessor(registry, reader);
	registerImportsConfiguration(registry, reader);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:ImportsContextCustomizer.java

示例10: registerCleanupPostProcessor

import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; //导入依赖的package包/类
private void registerCleanupPostProcessor(BeanDefinitionRegistry registry,
		AnnotatedBeanDefinitionReader reader) {
	BeanDefinition definition = registerBean(registry, reader,
			ImportsCleanupPostProcessor.BEAN_NAME, ImportsCleanupPostProcessor.class);
	definition.getConstructorArgumentValues().addIndexedArgumentValue(0,
			this.testClass);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:ImportsContextCustomizer.java

示例11: registerBean

import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private BeanDefinition registerBean(BeanDefinitionRegistry registry,
		AnnotatedBeanDefinitionReader reader, String beanName, Class<?> type) {
	reader.registerBean(type, beanName);
	BeanDefinition definition = registry.getBeanDefinition(beanName);
	return definition;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:ImportsContextCustomizer.java

示例12: initAnnotatedConf

import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; //导入依赖的package包/类
private static void initAnnotatedConf(GenericApplicationContext context){
	Class componentScanAnnotated=ProcessInfo.getAnnotationInitClass();
	if(componentScanAnnotated!=null){
		AnnotatedGenericBeanDefinition def=new AnnotatedGenericBeanDefinition(ProcessInfo.getAnnotationInitClass());
		AnnotatedBeanDefinitionReader reader=new AnnotatedBeanDefinitionReader(context);
		AnnotationScopeMetadataResolver resolver=new AnnotationScopeMetadataResolver();
		resolver.resolveScopeMetadata(def);
		reader.setScopeMetadataResolver(resolver);
	}
}
 
开发者ID:MyCATApache,项目名称:Mycat-openEP,代码行数:11,代码来源:SpringInitializer.java

示例13: securityManagerDisallowsAccessToSystemEnvironmentAndDisallowsAccessToIndividualKey

import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; //导入依赖的package包/类
@Test
public void securityManagerDisallowsAccessToSystemEnvironmentAndDisallowsAccessToIndividualKey() {
	SecurityManager securityManager = new SecurityManager() {
		@Override
		public void checkPermission(Permission perm) {
			// disallowing access to System#getenv means that our
			// ReadOnlySystemAttributesMap will come into play.
			if ("getenv.*".equals(perm.getName())) {
				throw new AccessControlException(
						"Accessing the system environment is disallowed");
			}
			// disallowing access to the spring.profiles.active property means that
			// the BeanDefinitionReader won't be able to determine which profiles are
			// active. We should see an INFO-level message in the console about this
			// and as a result, any components marked with a non-default profile will
			// be ignored.
			if (("getenv."+AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME).equals(perm.getName())) {
				throw new AccessControlException(
						format("Accessing system environment variable [%s] is disallowed",
								AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME));
			}
		}
	};
	System.setSecurityManager(securityManager);

	DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
	AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(bf);
	reader.register(C1.class);
	assertThat(bf.containsBean("c1"), is(false));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:31,代码来源:EnvironmentSecurityManagerIntegrationTests.java

示例14: register

import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; //导入依赖的package包/类
@Override
public AnnotatedClassViewRegistrar register (Class<?> first, Class<?>... rest) {
  try (GenericWebApplicationContext context = createContext ()) {
    AnnotatedBeanDefinitionReader reader = createAnnotatedReader (context);

    reader.register (first);
    reader.register (rest);

    context.refresh ();

    mergeViews (context);
  }
  return this;
}
 
开发者ID:dfci-cccb,项目名称:mev,代码行数:15,代码来源:MapHotPlugViewRegistry.java

示例15: testAnnotatedBeanDefinitionReader

import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; //导入依赖的package包/类
@Test
public void testAnnotatedBeanDefinitionReader() {
    AnnotatedBeanDefinitionReader annotatedReader = new AnnotatedBeanDefinitionReader(beanDefinitionRegistry);
    annotatedReader.register(CustomComponentProviderApplication.class);
}
 
开发者ID:fangjian0423,项目名称:springboot-analysis,代码行数:6,代码来源:SpringEmbeddedProviderTest.java


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