Search in sources :

Example 81 with Bean

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

the class AtomikosJtaConfiguration method userTransactionService.

@Bean(initMethod = "init", destroyMethod = "shutdownForce")
@ConditionalOnMissingBean(UserTransactionService.class)
public UserTransactionServiceImp userTransactionService(AtomikosProperties atomikosProperties) {
    Properties properties = new Properties();
    if (StringUtils.hasText(this.jtaProperties.getTransactionManagerId())) {
        properties.setProperty("com.atomikos.icatch.tm_unique_name", this.jtaProperties.getTransactionManagerId());
    }
    properties.setProperty("com.atomikos.icatch.log_base_dir", getLogBaseDir());
    properties.putAll(atomikosProperties.asProperties());
    return new UserTransactionServiceImp(properties);
}
Also used : EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) Properties(java.util.Properties) AtomikosProperties(org.springframework.boot.jta.atomikos.AtomikosProperties) UserTransactionServiceImp(com.atomikos.icatch.config.UserTransactionServiceImp) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 82 with Bean

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

the class BitronixJtaConfiguration method bitronixConfiguration.

@Bean
@ConditionalOnMissingBean
@ConfigurationProperties(prefix = "spring.jta.bitronix.properties")
public bitronix.tm.Configuration bitronixConfiguration() {
    bitronix.tm.Configuration config = TransactionManagerServices.getConfiguration();
    if (StringUtils.hasText(this.jtaProperties.getTransactionManagerId())) {
        config.setServerId(this.jtaProperties.getTransactionManagerId());
    }
    File logBaseDir = getLogBaseDir();
    config.setLogPart1Filename(new File(logBaseDir, "part1.btm").getAbsolutePath());
    config.setLogPart2Filename(new File(logBaseDir, "part2.btm").getAbsolutePath());
    config.setDisableJmx(true);
    return config;
}
Also used : File(java.io.File) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConfigurationProperties(org.springframework.boot.context.properties.ConfigurationProperties) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 83 with Bean

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

the class ValidationAutoConfiguration method methodValidationPostProcessor.

@Bean
@ConditionalOnMissingBean
public static MethodValidationPostProcessor methodValidationPostProcessor(Validator validator) {
    MethodValidationPostProcessor processor = new MethodValidationPostProcessor();
    processor.setProxyTargetClass(true);
    processor.setValidator(validator);
    return processor;
}
Also used : MethodValidationPostProcessor(org.springframework.validation.beanvalidation.MethodValidationPostProcessor) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean) LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)

Example 84 with Bean

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

the class EmbeddedMongoAutoConfiguration method embeddedMongoConfiguration.

@Bean
@ConditionalOnMissingBean
public IMongodConfig embeddedMongoConfiguration() throws IOException {
    IFeatureAwareVersion featureAwareVersion = new ToStringFriendlyFeatureAwareVersion(this.embeddedProperties.getVersion(), this.embeddedProperties.getFeatures());
    MongodConfigBuilder builder = new MongodConfigBuilder().version(featureAwareVersion);
    if (this.embeddedProperties.getStorage() != null) {
        builder.replication(new Storage(this.embeddedProperties.getStorage().getDatabaseDir(), this.embeddedProperties.getStorage().getReplSetName(), this.embeddedProperties.getStorage().getOplogSize() != null ? this.embeddedProperties.getStorage().getOplogSize() : 0));
    }
    Integer configuredPort = this.properties.getPort();
    if (configuredPort != null && configuredPort > 0) {
        builder.net(new Net(getHost().getHostAddress(), configuredPort, Network.localhostIsIPv6()));
    } else {
        builder.net(new Net(getHost().getHostAddress(), Network.getFreeServerPort(getHost()), Network.localhostIsIPv6()));
    }
    return builder.build();
}
Also used : Storage(de.flapdoodle.embed.mongo.config.Storage) Net(de.flapdoodle.embed.mongo.config.Net) MongodConfigBuilder(de.flapdoodle.embed.mongo.config.MongodConfigBuilder) IFeatureAwareVersion(de.flapdoodle.embed.mongo.distribution.IFeatureAwareVersion) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ReactiveMongoClientFactoryBean(org.springframework.data.mongodb.core.ReactiveMongoClientFactoryBean) MongoClientFactoryBean(org.springframework.data.mongodb.core.MongoClientFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 85 with Bean

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

the class JpaBaseConfiguration method entityManagerFactoryBuilder.

@Bean
@ConditionalOnMissingBean
public EntityManagerFactoryBuilder entityManagerFactoryBuilder(JpaVendorAdapter jpaVendorAdapter, ObjectProvider<PersistenceUnitManager> persistenceUnitManager) {
    EntityManagerFactoryBuilder builder = new EntityManagerFactoryBuilder(jpaVendorAdapter, this.properties.getProperties(), persistenceUnitManager.getIfAvailable());
    builder.setCallback(getVendorCallback());
    return builder;
}
Also used : EntityManagerFactoryBuilder(org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

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