Search in sources :

Example 71 with Bean

use of org.springframework.context.annotation.Bean in project spring-framework by spring-projects.

the class WebFluxConfigurationSupport method viewResolutionResultHandler.

@Bean
public ViewResolutionResultHandler viewResolutionResultHandler() {
    ViewResolverRegistry registry = new ViewResolverRegistry(getApplicationContext());
    configureViewResolvers(registry);
    List<ViewResolver> resolvers = registry.getViewResolvers();
    ViewResolutionResultHandler handler = new ViewResolutionResultHandler(resolvers, webFluxContentTypeResolver(), webFluxAdapterRegistry());
    handler.setDefaultViews(registry.getDefaultViews());
    handler.setOrder(registry.getOrder());
    return handler;
}
Also used : ViewResolutionResultHandler(org.springframework.web.reactive.result.view.ViewResolutionResultHandler) ViewResolver(org.springframework.web.reactive.result.view.ViewResolver) Bean(org.springframework.context.annotation.Bean)

Example 72 with Bean

use of org.springframework.context.annotation.Bean in project spring-framework by spring-projects.

the class WebFluxConfigurationSupport method resourceHandlerMapping.

/**
	 * Return a handler mapping ordered at Integer.MAX_VALUE-1 with mapped
	 * resource handlers. To configure resource handling, override
	 * {@link #addResourceHandlers}.
	 */
@Bean
public HandlerMapping resourceHandlerMapping() {
    ResourceHandlerRegistry registry = new ResourceHandlerRegistry(this.applicationContext, webFluxContentTypeResolver());
    addResourceHandlers(registry);
    AbstractHandlerMapping handlerMapping = registry.getHandlerMapping();
    if (handlerMapping != null) {
        PathMatchConfigurer pathMatchConfigurer = getPathMatchConfigurer();
        if (pathMatchConfigurer.getPathMatcher() != null) {
            handlerMapping.setPathMatcher(pathMatchConfigurer.getPathMatcher());
        }
        if (pathMatchConfigurer.getPathHelper() != null) {
            handlerMapping.setPathHelper(pathMatchConfigurer.getPathHelper());
        }
    } else {
        handlerMapping = new EmptyHandlerMapping();
    }
    return handlerMapping;
}
Also used : AbstractHandlerMapping(org.springframework.web.reactive.handler.AbstractHandlerMapping) Bean(org.springframework.context.annotation.Bean)

Example 73 with Bean

use of org.springframework.context.annotation.Bean in project spring-framework by spring-projects.

the class WebFluxConfigurationSupport method requestMappingHandlerAdapter.

@Bean
public RequestMappingHandlerAdapter requestMappingHandlerAdapter() {
    RequestMappingHandlerAdapter adapter = createRequestMappingHandlerAdapter();
    adapter.setMessageReaders(getMessageReaders());
    adapter.setWebBindingInitializer(getConfigurableWebBindingInitializer());
    adapter.setReactiveAdapterRegistry(webFluxAdapterRegistry());
    List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>();
    addArgumentResolvers(resolvers);
    if (!resolvers.isEmpty()) {
        adapter.setCustomArgumentResolvers(resolvers);
    }
    return adapter;
}
Also used : ArrayList(java.util.ArrayList) HandlerMethodArgumentResolver(org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver) RequestMappingHandlerAdapter(org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter) Bean(org.springframework.context.annotation.Bean)

Example 74 with Bean

use of org.springframework.context.annotation.Bean in project spring-framework by spring-projects.

the class WebMvcConfigurationSupport method mvcContentNegotiationManager.

/**
	 * Return a {@link ContentNegotiationManager} instance to use to determine
	 * requested {@linkplain MediaType media types} in a given request.
	 */
@Bean
public ContentNegotiationManager mvcContentNegotiationManager() {
    if (this.contentNegotiationManager == null) {
        ContentNegotiationConfigurer configurer = new ContentNegotiationConfigurer(this.servletContext);
        configurer.mediaTypes(getDefaultMediaTypes());
        configureContentNegotiation(configurer);
        try {
            this.contentNegotiationManager = configurer.getContentNegotiationManager();
        } catch (Exception ex) {
            throw new BeanInitializationException("Could not create ContentNegotiationManager", ex);
        }
    }
    return this.contentNegotiationManager;
}
Also used : BeanInitializationException(org.springframework.beans.factory.BeanInitializationException) BeanInitializationException(org.springframework.beans.factory.BeanInitializationException) Bean(org.springframework.context.annotation.Bean)

Example 75 with Bean

use of org.springframework.context.annotation.Bean in project spring-framework by spring-projects.

the class WebMvcConfigurationSupport method beanNameHandlerMapping.

/**
	 * Return a {@link BeanNameUrlHandlerMapping} ordered at 2 to map URL
	 * paths to controller bean names.
	 */
@Bean
public BeanNameUrlHandlerMapping beanNameHandlerMapping() {
    BeanNameUrlHandlerMapping mapping = new BeanNameUrlHandlerMapping();
    mapping.setOrder(2);
    mapping.setInterceptors(getInterceptors());
    mapping.setCorsConfigurations(getCorsConfigurations());
    return mapping;
}
Also used : BeanNameUrlHandlerMapping(org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping) Bean(org.springframework.context.annotation.Bean)

Aggregations

Bean (org.springframework.context.annotation.Bean)4059 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1090 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)444 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)393 ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)309 lombok.val (lombok.val)294 HashMap (java.util.HashMap)285 Lazy (org.springframework.context.annotation.Lazy)257 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)194 FilterRegistrationBean (org.springframework.boot.web.servlet.FilterRegistrationBean)158 Map (java.util.Map)152 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)112 Properties (java.util.Properties)100 Autowired (org.springframework.beans.factory.annotation.Autowired)93 ArrayList (java.util.ArrayList)85 Primary (org.springframework.context.annotation.Primary)84 Qualifier (org.springframework.beans.factory.annotation.Qualifier)75 CamelContextAware (org.apache.camel.CamelContextAware)69 ThreadPoolTaskExecutor (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)69 JpaTransactionManager (org.springframework.orm.jpa.JpaTransactionManager)61