Search in sources :

Example 1 with ConditionalOnBean

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

use of cn.taketoday.context.condition.ConditionalOnBean 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)

Example 3 with ConditionalOnBean

use of cn.taketoday.context.condition.ConditionalOnBean 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 4 with ConditionalOnBean

use of cn.taketoday.context.condition.ConditionalOnBean 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 ConditionalOnBean

use of cn.taketoday.context.condition.ConditionalOnBean in project today-infrastructure 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)

Aggregations

ConditionalOnBean (cn.taketoday.context.condition.ConditionalOnBean)5 ConditionalOnMissingBean (cn.taketoday.context.condition.ConditionalOnMissingBean)5 Component (cn.taketoday.lang.Component)5 BeanNameViewResolver (cn.taketoday.web.view.BeanNameViewResolver)2 ContentNegotiatingViewResolver (cn.taketoday.web.view.ContentNegotiatingViewResolver)2 Encoding (cn.taketoday.framework.web.server.Encoding)1 StringHttpMessageConverter (cn.taketoday.http.converter.StringHttpMessageConverter)1 Charset (java.nio.charset.Charset)1