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;
}
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;
}
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.
}
}
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;
}
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;
}
Aggregations