use of org.springframework.core.env.StandardEnvironment in project spring-boot by spring-projects.
the class EnvironmentEndpoint method getPropertySources.
private MutablePropertySources getPropertySources() {
MutablePropertySources sources;
Environment environment = getEnvironment();
if (environment != null && environment instanceof ConfigurableEnvironment) {
sources = ((ConfigurableEnvironment) environment).getPropertySources();
} else {
sources = new StandardEnvironment().getPropertySources();
}
return sources;
}
use of org.springframework.core.env.StandardEnvironment in project gravitee-management-rest-api by gravitee-io.
the class IdentityProviderManagerImpl method create.
private <T> T create(Plugin plugin, Class<T> identityClass, Map<String, Object> properties) {
if (identityClass == null) {
return null;
}
try {
T identityObj = createInstance(identityClass);
final Import annImport = identityClass.getAnnotation(Import.class);
Set<Class<?>> configurations = (annImport != null) ? new HashSet<>(Arrays.asList(annImport.value())) : Collections.emptySet();
ApplicationContext idpApplicationContext = pluginContextFactory.create(new AnnotationBasedPluginContextConfigurer(plugin) {
@Override
public Set<Class<?>> configurations() {
return configurations;
}
@Override
public ConfigurableEnvironment environment() {
return new StandardEnvironment() {
@Override
protected void customizePropertySources(MutablePropertySources propertySources) {
propertySources.addFirst(new MapPropertySource(plugin.id(), properties));
super.customizePropertySources(propertySources);
}
};
}
});
idpApplicationContext.getAutowireCapableBeanFactory().autowireBean(identityObj);
if (identityObj instanceof InitializingBean) {
((InitializingBean) identityObj).afterPropertiesSet();
}
return identityObj;
} catch (Exception ex) {
LOGGER.error("An unexpected error occurs while loading identity provider", ex);
return null;
}
}
use of org.springframework.core.env.StandardEnvironment in project spring-data-commons by spring-projects.
the class AnnotationRepositoryConfigurationSourceUnitTests method setUp.
@Before
public void setUp() {
AnnotationMetadata annotationMetadata = new StandardAnnotationMetadata(SampleConfiguration.class, true);
environment = new StandardEnvironment();
resourceLoader = new DefaultResourceLoader();
registry = mock(BeanDefinitionRegistry.class);
source = new AnnotationRepositoryConfigurationSource(annotationMetadata, EnableRepositories.class, resourceLoader, environment, registry);
}
use of org.springframework.core.env.StandardEnvironment in project spring-data-commons by spring-projects.
the class RepositoryBeanDefinitionRegistrarSupportUnitTests method setUp.
@Before
public void setUp() {
environment = new StandardEnvironment();
registrar = new DummyRegistrar();
registrar.setEnvironment(environment);
}
use of org.springframework.core.env.StandardEnvironment in project spring-data-commons by spring-projects.
the class RepositoryConfigurationDelegateUnitTests method registersRepositoryBeanNameAsAttribute.
// DATACMNS-892
@Test
public void registersRepositoryBeanNameAsAttribute() {
StandardEnvironment environment = new StandardEnvironment();
GenericApplicationContext context = new GenericApplicationContext();
RepositoryConfigurationSource configSource = new AnnotationRepositoryConfigurationSource(new StandardAnnotationMetadata(TestConfig.class, true), EnableRepositories.class, context, environment, context.getDefaultListableBeanFactory());
RepositoryConfigurationDelegate delegate = new RepositoryConfigurationDelegate(configSource, context, environment);
for (BeanComponentDefinition definition : delegate.registerRepositoriesIn(context, extension)) {
BeanDefinition beanDefinition = definition.getBeanDefinition();
assertThat(beanDefinition.getAttribute(RepositoryConfigurationDelegate.FACTORY_BEAN_OBJECT_TYPE).toString(), endsWith("Repository"));
}
}
Aggregations