use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory in project cas by apereo.
the class DuoMultifactorWebflowConfigurer method doInitialize.
@Override
protected void doInitialize() {
provider.getProviders().forEach(p -> {
final FlowDefinitionRegistry duoFlowRegistry = buildDuoFlowRegistry(p);
applicationContext.getAutowireCapableBeanFactory().initializeBean(duoFlowRegistry, p.getId());
final ConfigurableListableBeanFactory cfg = (ConfigurableListableBeanFactory) applicationContext.getAutowireCapableBeanFactory();
cfg.registerSingleton(p.getId(), duoFlowRegistry);
registerMultifactorProviderAuthenticationWebflow(getLoginFlow(), p.getId(), duoFlowRegistry);
});
casProperties.getAuthn().getMfa().getDuo().stream().filter(DuoSecurityMultifactorProperties::isTrustedDeviceEnabled).forEach(duo -> {
final String id = duo.getId();
try {
LOGGER.debug("Activating multifactor trusted authentication for webflow [{}]", id);
final FlowDefinitionRegistry registry = applicationContext.getBean(id, FlowDefinitionRegistry.class);
registerMultifactorTrustedAuthentication(registry);
} catch (final Exception e) {
LOGGER.error("Failed to register multifactor trusted authentication for " + id, e);
}
});
}
use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory in project engine by craftercms.
the class BeanDefinitionUtils method createBeanDefinitionFromOriginal.
/**
* Creates a bean definition for the specified bean name. If the parent context of the current context contains a
* bean definition with the same name, the definition is created as a bean copy of the parent definition. This
* method is useful for config parsers that want to create a bean definition from configuration but also want to
* retain the default properties of the original bean.
*
* @param applicationContext the current application context
* @param beanName
* @return the bean definition
*/
public static BeanDefinition createBeanDefinitionFromOriginal(ApplicationContext applicationContext, String beanName) {
ApplicationContext parentContext = applicationContext.getParent();
BeanDefinition parentDefinition = null;
if (parentContext != null && parentContext.getAutowireCapableBeanFactory() instanceof ConfigurableListableBeanFactory) {
ConfigurableListableBeanFactory parentBeanFactory = (ConfigurableListableBeanFactory) parentContext.getAutowireCapableBeanFactory();
try {
parentDefinition = parentBeanFactory.getBeanDefinition(beanName);
} catch (NoSuchBeanDefinitionException e) {
}
}
if (parentDefinition != null) {
return new GenericBeanDefinition(parentDefinition);
} else {
return new GenericBeanDefinition();
}
}
use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory in project grails-core by grails.
the class AbstractGrailsPluginManager method doRuntimeConfiguration.
/**
* Base implementation that simply goes through the list of plugins and calls doWithRuntimeConfiguration on each
* @param springConfig The RuntimeSpringConfiguration instance
*/
public void doRuntimeConfiguration(RuntimeSpringConfiguration springConfig) {
ApplicationContext context = springConfig.getUnrefreshedApplicationContext();
AutowireCapableBeanFactory autowireCapableBeanFactory = context.getAutowireCapableBeanFactory();
if (autowireCapableBeanFactory instanceof ConfigurableListableBeanFactory) {
ConfigurableListableBeanFactory beanFactory = (ConfigurableListableBeanFactory) autowireCapableBeanFactory;
ConversionService existingConversionService = beanFactory.getConversionService();
ConverterRegistry converterRegistry;
if (existingConversionService == null) {
GenericConversionService conversionService = new GenericConversionService();
converterRegistry = conversionService;
beanFactory.setConversionService(conversionService);
} else {
converterRegistry = (ConverterRegistry) existingConversionService;
}
converterRegistry.addConverter(new Converter<NavigableMap.NullSafeNavigator, Object>() {
@Override
public Object convert(NavigableMap.NullSafeNavigator source) {
return null;
}
});
}
checkInitialised();
for (GrailsPlugin plugin : pluginList) {
if (plugin.supportsCurrentScopeAndEnvironment() && plugin.isEnabled(context.getEnvironment().getActiveProfiles())) {
plugin.doWithRuntimeConfiguration(springConfig);
}
}
}
use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory in project spring-framework by spring-projects.
the class AbstractApplicationContext method initLifecycleProcessor.
/**
* Initialize the LifecycleProcessor.
* Uses DefaultLifecycleProcessor if none defined in the context.
* @see org.springframework.context.support.DefaultLifecycleProcessor
*/
protected void initLifecycleProcessor() {
ConfigurableListableBeanFactory beanFactory = getBeanFactory();
if (beanFactory.containsLocalBean(LIFECYCLE_PROCESSOR_BEAN_NAME)) {
this.lifecycleProcessor = beanFactory.getBean(LIFECYCLE_PROCESSOR_BEAN_NAME, LifecycleProcessor.class);
if (logger.isDebugEnabled()) {
logger.debug("Using LifecycleProcessor [" + this.lifecycleProcessor + "]");
}
} else {
DefaultLifecycleProcessor defaultProcessor = new DefaultLifecycleProcessor();
defaultProcessor.setBeanFactory(beanFactory);
this.lifecycleProcessor = defaultProcessor;
beanFactory.registerSingleton(LIFECYCLE_PROCESSOR_BEAN_NAME, this.lifecycleProcessor);
if (logger.isDebugEnabled()) {
logger.debug("Unable to locate LifecycleProcessor with name '" + LIFECYCLE_PROCESSOR_BEAN_NAME + "': using default [" + this.lifecycleProcessor + "]");
}
}
}
use of org.springframework.beans.factory.config.ConfigurableListableBeanFactory in project spring-framework by spring-projects.
the class PersistenceAnnotationBeanPostProcessor method findDefaultEntityManagerFactory.
/**
* Find a single default EntityManagerFactory in the Spring application context.
* @return the default EntityManagerFactory
* @throws NoSuchBeanDefinitionException if there is no single EntityManagerFactory in the context
*/
protected EntityManagerFactory findDefaultEntityManagerFactory(String requestingBeanName) throws NoSuchBeanDefinitionException {
if (this.beanFactory instanceof ConfigurableListableBeanFactory) {
// Fancy variant with dependency registration
ConfigurableListableBeanFactory clbf = (ConfigurableListableBeanFactory) this.beanFactory;
NamedBeanHolder<EntityManagerFactory> emfHolder = clbf.resolveNamedBean(EntityManagerFactory.class);
clbf.registerDependentBean(emfHolder.getBeanName(), requestingBeanName);
return emfHolder.getBeanInstance();
} else {
// Plain variant: just find a default bean
return this.beanFactory.getBean(EntityManagerFactory.class);
}
}
Aggregations