Search in sources :

Example 11 with Bean

use of cn.taketoday.context.annotation.Bean in project today-framework by TAKETODAY.

the class TransactionManagerConfiguration method transactionManager2.

@Bean
@NoSynch
public PlatformTransactionManager transactionManager2() {
    CallCountingTransactionManager tm = new CallCountingTransactionManager();
    tm.setTransactionSynchronization(CallCountingTransactionManager.SYNCHRONIZATION_NEVER);
    return tm;
}
Also used : CallCountingTransactionManager(cn.taketoday.transaction.testfixture.CallCountingTransactionManager) Bean(cn.taketoday.context.annotation.Bean)

Example 12 with Bean

use of cn.taketoday.context.annotation.Bean in project today-framework by TAKETODAY.

the class ProxyJCacheConfiguration method cacheAdvisor.

@Bean(name = CacheManagementConfigUtils.JCACHE_ADVISOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public BeanFactoryJCacheOperationSourceAdvisor cacheAdvisor(JCacheOperationSource jCacheOperationSource, JCacheInterceptor jCacheInterceptor) {
    BeanFactoryJCacheOperationSourceAdvisor advisor = new BeanFactoryJCacheOperationSourceAdvisor();
    advisor.setCacheOperationSource(jCacheOperationSource);
    advisor.setAdvice(jCacheInterceptor);
    if (this.enableCaching != null) {
        advisor.setOrder(this.enableCaching.<Integer>getNumber("order"));
    }
    return advisor;
}
Also used : BeanFactoryJCacheOperationSourceAdvisor(cn.taketoday.cache.jcache.interceptor.BeanFactoryJCacheOperationSourceAdvisor) Role(cn.taketoday.context.annotation.Role) Bean(cn.taketoday.context.annotation.Bean)

Example 13 with Bean

use of cn.taketoday.context.annotation.Bean in project today-framework by TAKETODAY.

the class FactoryMethodComponent method protectedInstance.

@Bean
@BeanAge(1)
protected TestBean protectedInstance(@Qualifier("public") TestBean spouse, @Value("#{privateInstance.age}") String country) {
    TestBean tb = new TestBean("protectedInstance", 1);
    tb.setSpouse(tb);
    tb.setCountry(country);
    return tb;
}
Also used : TestBean(cn.taketoday.beans.testfixture.beans.TestBean) BeanAge(cn.taketoday.context.annotation.BeanAge) Bean(cn.taketoday.context.annotation.Bean) TestBean(cn.taketoday.beans.testfixture.beans.TestBean)

Example 14 with Bean

use of cn.taketoday.context.annotation.Bean in project today-framework by TAKETODAY.

the class JdbcTemplateConfiguration method jdbcTemplate.

@Bean
@Primary
JdbcTemplate jdbcTemplate(DataSource dataSource, JdbcProperties properties) {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    JdbcProperties.Template template = properties.getTemplate();
    jdbcTemplate.setFetchSize(template.getFetchSize());
    jdbcTemplate.setMaxRows(template.getMaxRows());
    if (template.getQueryTimeout() != null) {
        jdbcTemplate.setQueryTimeout((int) template.getQueryTimeout().getSeconds());
    }
    return jdbcTemplate;
}
Also used : JdbcTemplate(cn.taketoday.jdbc.core.JdbcTemplate) NamedParameterJdbcTemplate(cn.taketoday.jdbc.core.namedparam.NamedParameterJdbcTemplate) Primary(cn.taketoday.context.annotation.Primary) Bean(cn.taketoday.context.annotation.Bean) ConditionalOnMissingBean(cn.taketoday.context.condition.ConditionalOnMissingBean)

Example 15 with Bean

use of cn.taketoday.context.annotation.Bean in project today-framework by TAKETODAY.

the class ProxyJCacheConfiguration method cacheInterceptor.

@Bean(name = "jCacheInterceptor")
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public JCacheInterceptor cacheInterceptor(JCacheOperationSource jCacheOperationSource) {
    JCacheInterceptor interceptor = new JCacheInterceptor(this.errorHandler);
    interceptor.setCacheOperationSource(jCacheOperationSource);
    return interceptor;
}
Also used : JCacheInterceptor(cn.taketoday.cache.jcache.interceptor.JCacheInterceptor) Role(cn.taketoday.context.annotation.Role) Bean(cn.taketoday.context.annotation.Bean)

Aggregations

Bean (cn.taketoday.context.annotation.Bean)25 ConditionalOnMissingBean (cn.taketoday.context.condition.ConditionalOnMissingBean)9 Role (cn.taketoday.context.annotation.Role)8 Employee (cn.taketoday.beans.testfixture.beans.Employee)4 DefaultLifecycleProcessor (cn.taketoday.context.support.DefaultLifecycleProcessor)3 ResourceBundleMessageSource (cn.taketoday.context.support.ResourceBundleMessageSource)3 Duration (java.time.Duration)3 TestBean (cn.taketoday.beans.testfixture.beans.TestBean)2 BeanFactoryCacheOperationSourceAdvisor (cn.taketoday.cache.interceptor.BeanFactoryCacheOperationSourceAdvisor)2 CacheInterceptor (cn.taketoday.cache.interceptor.CacheInterceptor)2 BeanFactoryJCacheOperationSourceAdvisor (cn.taketoday.cache.jcache.interceptor.BeanFactoryJCacheOperationSourceAdvisor)2 JCacheInterceptor (cn.taketoday.cache.jcache.interceptor.JCacheInterceptor)2 BeanAge (cn.taketoday.context.annotation.BeanAge)2 Primary (cn.taketoday.context.annotation.Primary)2 JdbcTemplate (cn.taketoday.jdbc.core.JdbcTemplate)2 NamedParameterJdbcTemplate (cn.taketoday.jdbc.core.namedparam.NamedParameterJdbcTemplate)2 CallCountingTransactionManager (cn.taketoday.transaction.testfixture.CallCountingTransactionManager)2 StringHttpMessageConverter (cn.taketoday.http.converter.StringHttpMessageConverter)1 Charset (java.nio.charset.Charset)1