Search in sources :

Example 1 with Bean

use of cn.taketoday.context.annotation.Bean in project today-infrastructure 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 2 with Bean

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

the class ProxyCachingConfiguration method cacheInterceptor.

@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public CacheInterceptor cacheInterceptor(CacheOperationSource cacheOperationSource) {
    CacheInterceptor interceptor = new CacheInterceptor();
    interceptor.configure(this.errorHandler, this.keyGenerator, this.cacheResolver, this.cacheManager);
    interceptor.setCacheOperationSource(cacheOperationSource);
    return interceptor;
}
Also used : CacheInterceptor(cn.taketoday.cache.interceptor.CacheInterceptor) Role(cn.taketoday.context.annotation.Role) Bean(cn.taketoday.context.annotation.Bean)

Example 3 with Bean

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

the class ProxyCachingConfiguration method cacheAdvisor.

@Bean(name = CacheManagementConfigUtils.CACHE_ADVISOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public BeanFactoryCacheOperationSourceAdvisor cacheAdvisor(CacheOperationSource cacheOperationSource, CacheInterceptor cacheInterceptor) {
    BeanFactoryCacheOperationSourceAdvisor advisor = new BeanFactoryCacheOperationSourceAdvisor();
    advisor.setCacheOperationSource(cacheOperationSource);
    advisor.setAdvice(cacheInterceptor);
    if (this.enableCaching != null) {
        advisor.setOrder(this.enableCaching.<Integer>getNumber("order"));
    }
    return advisor;
}
Also used : BeanFactoryCacheOperationSourceAdvisor(cn.taketoday.cache.interceptor.BeanFactoryCacheOperationSourceAdvisor) Role(cn.taketoday.context.annotation.Role) Bean(cn.taketoday.context.annotation.Bean)

Example 4 with Bean

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

the class LifecycleAutoConfiguration method defaultLifecycleProcessor.

@Bean(name = AbstractApplicationContext.LIFECYCLE_PROCESSOR_BEAN_NAME)
@ConditionalOnMissingBean(search = SearchStrategy.CURRENT, name = AbstractApplicationContext.LIFECYCLE_PROCESSOR_BEAN_NAME)
public DefaultLifecycleProcessor defaultLifecycleProcessor(LifecycleProperties properties) {
    DefaultLifecycleProcessor lifecycleProcessor = new DefaultLifecycleProcessor();
    lifecycleProcessor.setTimeoutPerShutdownPhase(properties.getTimeoutPerShutdownPhase().toMillis());
    return lifecycleProcessor;
}
Also used : DefaultLifecycleProcessor(cn.taketoday.context.support.DefaultLifecycleProcessor) ConditionalOnMissingBean(cn.taketoday.context.condition.ConditionalOnMissingBean) Bean(cn.taketoday.context.annotation.Bean) ConditionalOnMissingBean(cn.taketoday.context.condition.ConditionalOnMissingBean)

Example 5 with Bean

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

the class MessageSourceAutoConfiguration method messageSource.

@Bean
public MessageSource messageSource(MessageSourceProperties properties) {
    ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
    if (StringUtils.hasText(properties.getBasename())) {
        messageSource.setBasenames(StringUtils.commaDelimitedListToStringArray(StringUtils.trimAllWhitespace(properties.getBasename())));
    }
    if (properties.getEncoding() != null) {
        messageSource.setDefaultEncoding(properties.getEncoding().name());
    }
    messageSource.setFallbackToSystemLocale(properties.isFallbackToSystemLocale());
    Duration cacheDuration = properties.getCacheDuration();
    if (cacheDuration != null) {
        messageSource.setCacheMillis(cacheDuration.toMillis());
    }
    messageSource.setAlwaysUseMessageFormat(properties.isAlwaysUseMessageFormat());
    messageSource.setUseCodeAsDefaultMessage(properties.isUseCodeAsDefaultMessage());
    return messageSource;
}
Also used : ResourceBundleMessageSource(cn.taketoday.context.support.ResourceBundleMessageSource) Duration(java.time.Duration) Bean(cn.taketoday.context.annotation.Bean) ConditionalOnMissingBean(cn.taketoday.context.condition.ConditionalOnMissingBean)

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