Search in sources :

Example 76 with Bean

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

the class WebMvcConfigurationSupport 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, this.servletContext, mvcContentNegotiationManager());
    addResourceHandlers(registry);
    AbstractHandlerMapping handlerMapping = registry.getHandlerMapping();
    if (handlerMapping != null) {
        handlerMapping.setPathMatcher(mvcPathMatcher());
        handlerMapping.setUrlPathHelper(mvcUrlPathHelper());
        handlerMapping.setInterceptors(new ResourceUrlProviderExposingInterceptor(mvcResourceUrlProvider()));
        handlerMapping.setCorsConfigurations(getCorsConfigurations());
    } else {
        handlerMapping = new EmptyHandlerMapping();
    }
    return handlerMapping;
}
Also used : ResourceUrlProviderExposingInterceptor(org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor) AbstractHandlerMapping(org.springframework.web.servlet.handler.AbstractHandlerMapping) Bean(org.springframework.context.annotation.Bean)

Example 77 with Bean

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

the class ProxyTransactionManagementConfiguration method transactionAdvisor.

@Bean(name = TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public BeanFactoryTransactionAttributeSourceAdvisor transactionAdvisor() {
    BeanFactoryTransactionAttributeSourceAdvisor advisor = new BeanFactoryTransactionAttributeSourceAdvisor();
    advisor.setTransactionAttributeSource(transactionAttributeSource());
    advisor.setAdvice(transactionInterceptor());
    advisor.setOrder(this.enableTx.<Integer>getNumber("order"));
    return advisor;
}
Also used : BeanFactoryTransactionAttributeSourceAdvisor(org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor) Role(org.springframework.context.annotation.Role) Bean(org.springframework.context.annotation.Bean)

Example 78 with Bean

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

the class SecurityFilterAutoConfiguration method securityFilterChainRegistration.

@Bean
@ConditionalOnBean(name = DEFAULT_FILTER_NAME)
public DelegatingFilterProxyRegistrationBean securityFilterChainRegistration(SecurityProperties securityProperties) {
    DelegatingFilterProxyRegistrationBean registration = new DelegatingFilterProxyRegistrationBean(DEFAULT_FILTER_NAME);
    registration.setOrder(securityProperties.getFilterOrder());
    registration.setDispatcherTypes(getDispatcherTypes(securityProperties));
    return registration;
}
Also used : DelegatingFilterProxyRegistrationBean(org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) Bean(org.springframework.context.annotation.Bean) DelegatingFilterProxyRegistrationBean(org.springframework.boot.web.servlet.DelegatingFilterProxyRegistrationBean)

Example 79 with Bean

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

the class SendGridAutoConfiguration method sendGrid.

@Bean
@ConditionalOnMissingBean(SendGrid.class)
public SendGrid sendGrid() {
    SendGrid sendGrid = createSendGrid();
    if (this.properties.isProxyConfigured()) {
        HttpHost proxy = new HttpHost(this.properties.getProxy().getHost(), this.properties.getProxy().getPort());
        sendGrid.setClient(HttpClientBuilder.create().setProxy(proxy).setUserAgent("sendgrid/" + sendGrid.getVersion() + ";java").build());
    }
    return sendGrid;
}
Also used : SendGrid(com.sendgrid.SendGrid) HttpHost(org.apache.http.HttpHost) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 80 with Bean

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

the class HashMapSessionConfiguration method sessionRepository.

@Bean
public SessionRepository<ExpiringSession> sessionRepository(SessionProperties properties) {
    MapSessionRepository repository = new MapSessionRepository();
    Integer timeout = properties.getTimeout();
    if (timeout != null) {
        repository.setDefaultMaxInactiveInterval(timeout);
    }
    return repository;
}
Also used : MapSessionRepository(org.springframework.session.MapSessionRepository) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) 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