Search in sources :

Example 1 with Component

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

the class WebMvcAutoConfiguration method defaultViewResolver.

@Component
@ConditionalOnMissingBean
public InternalResourceViewResolver defaultViewResolver() {
    InternalResourceViewResolver resolver = new InternalResourceViewResolver();
    resolver.setPrefix(this.mvcProperties.getView().getPrefix());
    resolver.setSuffix(this.mvcProperties.getView().getSuffix());
    return resolver;
}
Also used : InternalResourceViewResolver(cn.taketoday.web.servlet.view.InternalResourceViewResolver) ConditionalOnMissingBean(cn.taketoday.context.condition.ConditionalOnMissingBean) Component(cn.taketoday.lang.Component)

Example 2 with Component

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

the class WebMvcAutoConfiguration method beanNameViewResolver.

@Component
@ConditionalOnBean(View.class)
@ConditionalOnMissingBean
public BeanNameViewResolver beanNameViewResolver() {
    BeanNameViewResolver resolver = new BeanNameViewResolver();
    resolver.setOrder(Ordered.LOWEST_PRECEDENCE - 10);
    return resolver;
}
Also used : BeanNameViewResolver(cn.taketoday.web.view.BeanNameViewResolver) ConditionalOnBean(cn.taketoday.context.condition.ConditionalOnBean) ConditionalOnMissingBean(cn.taketoday.context.condition.ConditionalOnMissingBean) Component(cn.taketoday.lang.Component)

Example 3 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 4 with Component

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

the class WebMvcAutoConfiguration method viewResolver.

@Component
@ConditionalOnBean(ViewResolver.class)
@ConditionalOnMissingBean(name = "viewResolver", value = ContentNegotiatingViewResolver.class)
public ContentNegotiatingViewResolver viewResolver(@Nullable ContentNegotiationManager contentNegotiationManager) {
    ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();
    resolver.setContentNegotiationManager(contentNegotiationManager);
    // ContentNegotiatingViewResolver uses all the other view resolvers to locate
    // a view so it should have a high precedence
    resolver.setOrder(Ordered.HIGHEST_PRECEDENCE);
    return resolver;
}
Also used : ContentNegotiatingViewResolver(cn.taketoday.web.view.ContentNegotiatingViewResolver) ConditionalOnBean(cn.taketoday.context.condition.ConditionalOnBean) ConditionalOnMissingBean(cn.taketoday.context.condition.ConditionalOnMissingBean) Component(cn.taketoday.lang.Component)

Example 5 with Component

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

the class ProxyCachingConfiguration method cacheEvictInterceptor.

@Aspect
@Component
@ConditionalOnMissingBean
@Advice(CacheEvict.class)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
CacheEvictInterceptor cacheEvictInterceptor(CacheManager cacheManager, CacheExpressionOperations operations) {
    CacheEvictInterceptor cacheEvictInterceptor = new CacheEvictInterceptor(cacheManager);
    cacheEvictInterceptor.setExpressionOperations(operations);
    return cacheEvictInterceptor;
}
Also used : CacheEvictInterceptor(cn.taketoday.cache.interceptor.CacheEvictInterceptor) Role(cn.taketoday.context.annotation.Role) ConditionalOnMissingBean(cn.taketoday.context.condition.ConditionalOnMissingBean) Advice(cn.taketoday.aop.support.annotation.Advice) Aspect(cn.taketoday.aop.support.annotation.Aspect) Component(cn.taketoday.lang.Component)

Aggregations

Component (cn.taketoday.lang.Component)7 ConditionalOnMissingBean (cn.taketoday.context.condition.ConditionalOnMissingBean)6 Advice (cn.taketoday.aop.support.annotation.Advice)3 Aspect (cn.taketoday.aop.support.annotation.Aspect)3 Role (cn.taketoday.context.annotation.Role)3 ConditionalOnBean (cn.taketoday.context.condition.ConditionalOnBean)2 CacheEvictInterceptor (cn.taketoday.cache.interceptor.CacheEvictInterceptor)1 CachePutInterceptor (cn.taketoday.cache.interceptor.CachePutInterceptor)1 CacheableInterceptor (cn.taketoday.cache.interceptor.CacheableInterceptor)1 AnnotationTypeFilter (cn.taketoday.core.type.filter.AnnotationTypeFilter)1 InternalResourceViewResolver (cn.taketoday.web.servlet.view.InternalResourceViewResolver)1 BeanNameViewResolver (cn.taketoday.web.view.BeanNameViewResolver)1 ContentNegotiatingViewResolver (cn.taketoday.web.view.ContentNegotiatingViewResolver)1