Search in sources :

Example 1 with SimpleThreadScope

use of cn.taketoday.context.support.SimpleThreadScope in project today-infrastructure by TAKETODAY.

the class MapperScanTest method setupContext.

@BeforeEach
void setupContext() {
    applicationContext = new AnnotationConfigApplicationContext();
    applicationContext.getBeanFactory().registerScope("thread", new SimpleThreadScope());
    setupSqlSessionFactory();
// assume support for autowiring fields is added by MapperScannerConfigurer
// via
// cn.taketoday.context.annotation.ClassPathBeanDefinitionScanner.includeAnnotationConfig
}
Also used : AnnotationConfigApplicationContext(cn.taketoday.context.annotation.AnnotationConfigApplicationContext) SimpleThreadScope(cn.taketoday.context.support.SimpleThreadScope) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with SimpleThreadScope

use of cn.taketoday.context.support.SimpleThreadScope in project today-infrastructure by TAKETODAY.

the class MapperScannerConfigurerTest method setupContext.

@BeforeEach
void setupContext() {
    applicationContext = new GenericApplicationContext();
    // add the mapper scanner as a bean definition rather than explicitly setting a
    // postProcessor on the context so initialization follows the same code path as reading from
    // an XML config file
    GenericBeanDefinition definition = new GenericBeanDefinition();
    definition.setBeanClass(MapperScannerConfigurer.class);
    definition.getPropertyValues().add("basePackage", "cn.taketoday.orm.mybatis.mapper");
    applicationContext.registerBeanDefinition("mapperScanner", definition);
    applicationContext.getBeanFactory().registerScope("thread", new SimpleThreadScope());
    setupSqlSessionFactory("sqlSessionFactory");
// assume support for autowiring fields is added by MapperScannerConfigurer via
// cn.taketoday.context.annotation.ClassPathBeanDefinitionScanner.includeAnnotationConfig
}
Also used : GenericBeanDefinition(cn.taketoday.beans.factory.support.GenericBeanDefinition) SimpleThreadScope(cn.taketoday.context.support.SimpleThreadScope) GenericApplicationContext(cn.taketoday.context.support.GenericApplicationContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with SimpleThreadScope

use of cn.taketoday.context.support.SimpleThreadScope in project today-framework by TAKETODAY.

the class MapperScannerConfigurerTest method setupContext.

@BeforeEach
void setupContext() {
    applicationContext = new GenericApplicationContext();
    // add the mapper scanner as a bean definition rather than explicitly setting a
    // postProcessor on the context so initialization follows the same code path as reading from
    // an XML config file
    GenericBeanDefinition definition = new GenericBeanDefinition();
    definition.setBeanClass(MapperScannerConfigurer.class);
    definition.getPropertyValues().add("basePackage", "cn.taketoday.orm.mybatis.mapper");
    applicationContext.registerBeanDefinition("mapperScanner", definition);
    applicationContext.getBeanFactory().registerScope("thread", new SimpleThreadScope());
    setupSqlSessionFactory("sqlSessionFactory");
// assume support for autowiring fields is added by MapperScannerConfigurer via
// cn.taketoday.context.annotation.ClassPathBeanDefinitionScanner.includeAnnotationConfig
}
Also used : GenericBeanDefinition(cn.taketoday.beans.factory.support.GenericBeanDefinition) SimpleThreadScope(cn.taketoday.context.support.SimpleThreadScope) GenericApplicationContext(cn.taketoday.context.support.GenericApplicationContext) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with SimpleThreadScope

use of cn.taketoday.context.support.SimpleThreadScope in project today-framework by TAKETODAY.

the class MapperScanTest method setupContext.

@BeforeEach
void setupContext() {
    applicationContext = new AnnotationConfigApplicationContext();
    applicationContext.getBeanFactory().registerScope("thread", new SimpleThreadScope());
    setupSqlSessionFactory();
// assume support for autowiring fields is added by MapperScannerConfigurer
// via
// cn.taketoday.context.annotation.ClassPathBeanDefinitionScanner.includeAnnotationConfig
}
Also used : AnnotationConfigApplicationContext(cn.taketoday.context.annotation.AnnotationConfigApplicationContext) SimpleThreadScope(cn.taketoday.context.support.SimpleThreadScope) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

SimpleThreadScope (cn.taketoday.context.support.SimpleThreadScope)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 GenericBeanDefinition (cn.taketoday.beans.factory.support.GenericBeanDefinition)2 AnnotationConfigApplicationContext (cn.taketoday.context.annotation.AnnotationConfigApplicationContext)2 GenericApplicationContext (cn.taketoday.context.support.GenericApplicationContext)2