Search in sources :

Example 66 with Bean

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

the class GenericCacheConfiguration method cacheManager.

@Bean
public SimpleCacheManager cacheManager(Collection<Cache> caches) {
    SimpleCacheManager cacheManager = new SimpleCacheManager();
    cacheManager.setCaches(caches);
    return this.customizers.customize(cacheManager);
}
Also used : SimpleCacheManager(org.springframework.cache.support.SimpleCacheManager) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 67 with Bean

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

the class InfinispanCacheConfiguration method infinispanCacheManager.

@Bean(destroyMethod = "stop")
@ConditionalOnMissingBean
public EmbeddedCacheManager infinispanCacheManager() throws IOException {
    EmbeddedCacheManager cacheManager = createEmbeddedCacheManager();
    List<String> cacheNames = this.cacheProperties.getCacheNames();
    if (!CollectionUtils.isEmpty(cacheNames)) {
        for (String cacheName : cacheNames) {
            cacheManager.defineConfiguration(cacheName, getDefaultCacheConfiguration());
        }
    }
    return cacheManager;
}
Also used : EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) SpringEmbeddedCacheManager(org.infinispan.spring.provider.SpringEmbeddedCacheManager) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 68 with Bean

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

the class PersistenceExceptionTranslationAutoConfiguration method persistenceExceptionTranslationPostProcessor.

@Bean
@ConditionalOnMissingBean(PersistenceExceptionTranslationPostProcessor.class)
@ConditionalOnProperty(prefix = "spring.dao.exceptiontranslation", name = "enabled", matchIfMissing = true)
public static PersistenceExceptionTranslationPostProcessor persistenceExceptionTranslationPostProcessor() {
    PersistenceExceptionTranslationPostProcessor postProcessor = new PersistenceExceptionTranslationPostProcessor();
    postProcessor.setProxyTargetClass(true);
    return postProcessor;
}
Also used : PersistenceExceptionTranslationPostProcessor(org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean) ConditionalOnProperty(org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)

Example 69 with Bean

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

the class MongoDataAutoConfiguration method mongoMappingContext.

@Bean
@ConditionalOnMissingBean
public MongoMappingContext mongoMappingContext(BeanFactory beanFactory, CustomConversions conversions) throws ClassNotFoundException {
    MongoMappingContext context = new MongoMappingContext();
    context.setInitialEntitySet(new EntityScanner(this.applicationContext).scan(Document.class, Persistent.class));
    Class<?> strategyClass = this.properties.getFieldNamingStrategy();
    if (strategyClass != null) {
        context.setFieldNamingStrategy((FieldNamingStrategy) BeanUtils.instantiateClass(strategyClass));
    }
    context.setSimpleTypeHolder(conversions.getSimpleTypeHolder());
    return context;
}
Also used : MongoMappingContext(org.springframework.data.mongodb.core.mapping.MongoMappingContext) Persistent(org.springframework.data.annotation.Persistent) Document(org.springframework.data.mongodb.core.mapping.Document) EntityScanner(org.springframework.boot.autoconfigure.domain.EntityScanner) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 70 with Bean

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

the class Neo4jDataAutoConfiguration method sessionFactory.

@Bean
public SessionFactory sessionFactory(org.neo4j.ogm.config.Configuration configuration, ApplicationContext applicationContext, ObjectProvider<List<EventListener>> eventListeners) {
    SessionFactory sessionFactory = new SessionFactory(configuration, getPackagesToScan(applicationContext));
    List<EventListener> providedEventListeners = eventListeners.getIfAvailable();
    if (providedEventListeners != null) {
        for (EventListener eventListener : providedEventListeners) {
            sessionFactory.register(eventListener);
        }
    }
    return sessionFactory;
}
Also used : SessionFactory(org.neo4j.ogm.session.SessionFactory) EventListener(org.neo4j.ogm.session.event.EventListener) 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