Search in sources :

Example 6 with Component

use of cn.taketoday.lang.Component in project today-infrastructure by TAKETODAY.

the class RedissonWebSessionConfiguration method redissonSessionRepository.

@Component
public RedissonSessionRepository redissonSessionRepository(RedissonClient client, SessionIdGenerator idGenerator, SessionEventDispatcher eventDispatcher) {
    var repository = new RedissonSessionRepository(client, keyPrefix, idGenerator, eventDispatcher);
    if (maxIdleTime != null && timeUnit != null) {
        Duration duration = Duration.of(maxIdleTime, timeUnit.toChronoUnit());
        repository.setDefaultMaxInactiveInterval(duration);
    }
    return repository;
}
Also used : Duration(java.time.Duration) Component(cn.taketoday.lang.Component)

Example 7 with Component

use of cn.taketoday.lang.Component in project today-framework by TAKETODAY.

the class RedissonWebSessionConfiguration method redissonSessionRepository.

@Component
public RedissonSessionRepository redissonSessionRepository(RedissonClient client, SessionIdGenerator idGenerator, SessionEventDispatcher eventDispatcher) {
    var repository = new RedissonSessionRepository(client, keyPrefix, idGenerator, eventDispatcher);
    if (maxIdleTime != null && timeUnit != null) {
        Duration duration = Duration.of(maxIdleTime, timeUnit.toChronoUnit());
        repository.setDefaultMaxInactiveInterval(duration);
    }
    return repository;
}
Also used : Duration(java.time.Duration) Component(cn.taketoday.lang.Component)

Example 8 with Component

use of cn.taketoday.lang.Component in project today-framework by TAKETODAY.

the class ClassPathScanningCandidateComponentProvider method registerDefaultFilters.

/**
 * Register the default filter for {@link Component @Component}.
 * <p>This will implicitly register all annotations that have the
 * {@link Component @Component} meta-annotation including the
 * {@link Repository @Repository}, {@link Service @Service}, and
 * {@link cn.taketoday.web.annotation.Controller @Controller} stereotype annotations.
 * <p>Also supports Jakarta EE's {@link jakarta.annotation.ManagedBean} and
 * JSR-330's {@link jakarta.inject.Named} annotations, if available.
 */
protected void registerDefaultFilters() {
    this.includeFilters.add(new AnnotationTypeFilter(Component.class));
    ClassLoader cl = ClassPathScanningCandidateComponentProvider.class.getClassLoader();
    try {
        this.includeFilters.add(new AnnotationTypeFilter(ClassUtils.forName("jakarta.annotation.ManagedBean", cl), false));
        log.trace("JSR-250 'jakarta.annotation.ManagedBean' found and supported for component scanning");
    } catch (ClassNotFoundException ex) {
    // JSR-250 1.1 API (as included in Jakarta EE) not available - simply skip.
    }
    try {
        this.includeFilters.add(new AnnotationTypeFilter(ClassUtils.forName("jakarta.inject.Named", cl), false));
        log.trace("JSR-330 'jakarta.inject.Named' annotation found and supported for component scanning");
    } catch (ClassNotFoundException ex) {
    // JSR-330 API not available - simply skip.
    }
}
Also used : AnnotationTypeFilter(cn.taketoday.core.type.filter.AnnotationTypeFilter) Component(cn.taketoday.lang.Component)

Example 9 with Component

use of cn.taketoday.lang.Component in project today-framework by TAKETODAY.

the class WebSessionConfig method sessionIdGenerator.

/**
 * @since 4.0
 */
@Component
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@ConditionalOnMissingBean(SessionIdGenerator.class)
SessionIdGenerator sessionIdGenerator(ServerProperties serverProperties) {
    SecureRandomSessionIdGenerator generator = new SecureRandomSessionIdGenerator();
    Session session = serverProperties.getSession();
    generator.setLength(session.getSessionIdLength());
    return generator;
}
Also used : SecureRandomSessionIdGenerator(cn.taketoday.web.session.SecureRandomSessionIdGenerator) Role(cn.taketoday.context.annotation.Role) ConditionalOnMissingBean(cn.taketoday.context.condition.ConditionalOnMissingBean) Component(cn.taketoday.lang.Component)

Example 10 with Component

use of cn.taketoday.lang.Component in project today-framework by TAKETODAY.

the class HttpMessageConvertersAutoConfiguration method stringHttpMessageConverter.

@Component
@ConditionalOnMissingBean
@ConditionalOnBean(ServerProperties.class)
public StringHttpMessageConverter stringHttpMessageConverter(Environment environment, ServerProperties serverProperties) {
    Encoding encoding = serverProperties.getEncoding();
    Charset charset = encoding.getCharset();
    StringHttpMessageConverter converter = new StringHttpMessageConverter(charset);
    converter.setWriteAcceptCharset(false);
    return converter;
}
Also used : Charset(java.nio.charset.Charset) Encoding(cn.taketoday.framework.web.server.Encoding) StringHttpMessageConverter(cn.taketoday.http.converter.StringHttpMessageConverter) ConditionalOnBean(cn.taketoday.context.condition.ConditionalOnBean) ConditionalOnMissingBean(cn.taketoday.context.condition.ConditionalOnMissingBean) Component(cn.taketoday.lang.Component)

Aggregations

Component (cn.taketoday.lang.Component)22 ConditionalOnMissingBean (cn.taketoday.context.condition.ConditionalOnMissingBean)14 Role (cn.taketoday.context.annotation.Role)8 ConditionalOnBean (cn.taketoday.context.condition.ConditionalOnBean)5 Advice (cn.taketoday.aop.support.annotation.Advice)3 Aspect (cn.taketoday.aop.support.annotation.Aspect)3 AnnotationTypeFilter (cn.taketoday.core.type.filter.AnnotationTypeFilter)2 StringHttpMessageConverter (cn.taketoday.http.converter.StringHttpMessageConverter)2 BeanFactoryTransactionAttributeSourceAdvisor (cn.taketoday.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor)2 TransactionInterceptor (cn.taketoday.transaction.interceptor.TransactionInterceptor)2 AcceptHeaderLocaleResolver (cn.taketoday.web.i18n.AcceptHeaderLocaleResolver)2 FixedLocaleResolver (cn.taketoday.web.i18n.FixedLocaleResolver)2 InternalResourceViewResolver (cn.taketoday.web.servlet.view.InternalResourceViewResolver)2 BeanNameViewResolver (cn.taketoday.web.view.BeanNameViewResolver)2 ContentNegotiatingViewResolver (cn.taketoday.web.view.ContentNegotiatingViewResolver)2 Charset (java.nio.charset.Charset)2 Duration (java.time.Duration)2 CacheEvictInterceptor (cn.taketoday.cache.interceptor.CacheEvictInterceptor)1 CachePutInterceptor (cn.taketoday.cache.interceptor.CachePutInterceptor)1 CacheableInterceptor (cn.taketoday.cache.interceptor.CacheableInterceptor)1