use of org.springframework.context.annotation.AnnotatedBeanDefinitionReader in project spring-boot by spring-projects.
the class ImportsContextCustomizer method customizeContext.
@Override
public void customizeContext(ConfigurableApplicationContext context, MergedContextConfiguration mergedContextConfiguration) {
BeanDefinitionRegistry registry = getBeanDefinitionRegistry(context);
AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(registry);
registerCleanupPostProcessor(registry, reader);
registerImportsConfiguration(registry, reader);
}
use of org.springframework.context.annotation.AnnotatedBeanDefinitionReader in project spring-framework by spring-projects.
the class EnvironmentSecurityManagerIntegrationTests method securityManagerDisallowsAccessToSystemEnvironmentAndDisallowsAccessToIndividualKey.
@Test
public void securityManagerDisallowsAccessToSystemEnvironmentAndDisallowsAccessToIndividualKey() {
SecurityManager securityManager = new SecurityManager() {
@Override
public void checkPermission(Permission perm) {
// ReadOnlySystemAttributesMap will come into play.
if ("getenv.*".equals(perm.getName())) {
throw new AccessControlException("Accessing the system environment is disallowed");
}
// 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));
}
use of org.springframework.context.annotation.AnnotatedBeanDefinitionReader in project spring-framework by spring-projects.
the class AnnotationConfigContextLoader method loadBeanDefinitions.
/**
* Register classes in the supplied {@link GenericApplicationContext context}
* from the classes in the supplied {@link MergedContextConfiguration}.
*
* <p>Each class must represent an <em>annotated class</em>. An
* {@link AnnotatedBeanDefinitionReader} is used to register the appropriate
* bean definitions.
*
* <p>Note that this method does not call {@link #createBeanDefinitionReader}
* since {@code AnnotatedBeanDefinitionReader} is not an instance of
* {@link BeanDefinitionReader}.
*
* @param context the context in which the annotated classes should be registered
* @param mergedConfig the merged configuration from which the classes should be retrieved
*
* @see AbstractGenericContextLoader#loadBeanDefinitions
*/
@Override
protected void loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig) {
Class<?>[] annotatedClasses = mergedConfig.getClasses();
if (logger.isDebugEnabled()) {
logger.debug("Registering annotated classes: " + ObjectUtils.nullSafeToString(annotatedClasses));
}
new AnnotatedBeanDefinitionReader(context).register(annotatedClasses);
}
use of org.springframework.context.annotation.AnnotatedBeanDefinitionReader in project spring-framework by spring-projects.
the class EnvironmentSystemIntegrationTests method annotatedBeanDefinitionReader_inheritsEnvironmentFromEnvironmentCapableBDR.
@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));
}
use of org.springframework.context.annotation.AnnotatedBeanDefinitionReader in project spring-framework by spring-projects.
the class SpringAtInjectTck method suite.
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);
}
Aggregations