use of org.springframework.beans.factory.support.RootBeanDefinition in project spring-security by spring-projects.
the class AuthenticationConfigBuilder method createRememberMeProvider.
private void createRememberMeProvider(String key) {
RootBeanDefinition provider = new RootBeanDefinition(RememberMeAuthenticationProvider.class);
provider.setSource(rememberMeFilter.getSource());
provider.getConstructorArgumentValues().addGenericArgumentValue(key);
String id = pc.getReaderContext().generateBeanName(provider);
pc.registerBeanComponent(new BeanComponentDefinition(provider, id));
rememberMeProviderRef = new RuntimeBeanReference(id);
}
use of org.springframework.beans.factory.support.RootBeanDefinition in project spring-security by spring-projects.
the class GrantedAuthorityDefaultsParserUtils method registerWithDefaultRolePrefix.
static RootBeanDefinition registerWithDefaultRolePrefix(ParserContext pc, Class<? extends AbstractGrantedAuthorityDefaultsBeanFactory> beanFactoryClass) {
RootBeanDefinition beanFactoryDefinition = new RootBeanDefinition(beanFactoryClass);
String beanFactoryRef = pc.getReaderContext().generateBeanName(beanFactoryDefinition);
pc.getRegistry().registerBeanDefinition(beanFactoryRef, beanFactoryDefinition);
RootBeanDefinition bean = new RootBeanDefinition();
bean.setFactoryBeanName(beanFactoryRef);
bean.setFactoryMethodName("getBean");
return bean;
}
use of org.springframework.beans.factory.support.RootBeanDefinition in project spring-boot by spring-projects.
the class ServletComponentScanRegistrarTests method packagesConfiguredWithValueAsm.
@Test
public void packagesConfiguredWithValueAsm() {
this.context = new AnnotationConfigApplicationContext();
this.context.registerBeanDefinition("valuePackages", new RootBeanDefinition(ValuePackages.class.getName()));
this.context.refresh();
ServletComponentRegisteringPostProcessor postProcessor = this.context.getBean(ServletComponentRegisteringPostProcessor.class);
assertThat(postProcessor.getPackagesToScan()).contains("com.example.foo", "com.example.bar");
}
use of org.springframework.beans.factory.support.RootBeanDefinition in project spring-boot by spring-projects.
the class ServletWebServerApplicationContextTests method beanDefinition.
private BeanDefinition beanDefinition(Object bean) {
RootBeanDefinition beanDefinition = new RootBeanDefinition();
beanDefinition.setBeanClass(getClass());
beanDefinition.setFactoryMethodName("getBean");
ConstructorArgumentValues constructorArguments = new ConstructorArgumentValues();
constructorArguments.addGenericArgumentValue(bean);
beanDefinition.setConstructorArgumentValues(constructorArguments);
return beanDefinition;
}
use of org.springframework.beans.factory.support.RootBeanDefinition in project spring-framework by spring-projects.
the class AnnotationAsyncExecutionAspectTests method qualifiedAsyncMethodsAreRoutedToCorrectExecutor.
/*
@Test
public void methodReturningNonVoidNonFutureInAsyncClassGetsRoutedSynchronously() {
ClassWithAsyncAnnotation obj = new ClassWithAsyncAnnotation();
int returnValue = obj.return5();
assertEquals(5, returnValue);
assertEquals(0, executor.submitStartCounter);
assertEquals(0, executor.submitCompleteCounter);
}
*/
@Test
public void qualifiedAsyncMethodsAreRoutedToCorrectExecutor() throws InterruptedException, ExecutionException {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
beanFactory.registerBeanDefinition("e1", new RootBeanDefinition(ThreadPoolTaskExecutor.class));
AnnotationAsyncExecutionAspect.aspectOf().setBeanFactory(beanFactory);
ClassWithQualifiedAsyncMethods obj = new ClassWithQualifiedAsyncMethods();
Future<Thread> defaultThread = obj.defaultWork();
assertThat(defaultThread.get(), not(Thread.currentThread()));
assertThat(defaultThread.get().getName(), not(startsWith("e1-")));
ListenableFuture<Thread> e1Thread = obj.e1Work();
assertThat(e1Thread.get().getName(), startsWith("e1-"));
CompletableFuture<Thread> e1OtherThread = obj.e1OtherWork();
assertThat(e1OtherThread.get().getName(), startsWith("e1-"));
}
Aggregations