Search in sources :

Example 1 with DependsOn

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

the class EmbeddedLdapAutoConfiguration method ldapContextSource.

@Bean
@DependsOn("directoryServer")
@ConditionalOnMissingBean
public ContextSource ldapContextSource() {
    LdapContextSource source = new LdapContextSource();
    if (hasCredentials(this.embeddedProperties.getCredential())) {
        source.setUserDn(this.embeddedProperties.getCredential().getUsername());
        source.setPassword(this.embeddedProperties.getCredential().getPassword());
    }
    source.setUrls(this.properties.determineUrls(this.environment));
    return source;
}
Also used : LdapContextSource(org.springframework.ldap.core.support.LdapContextSource) DependsOn(org.springframework.context.annotation.DependsOn) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with DependsOn

use of org.springframework.context.annotation.DependsOn in project gs-spring-security-3.2 by rwinch.

the class DataConfiguration method initDatabase.

@Bean
@DependsOn("entityManagerFactory")
public ResourceDatabasePopulator initDatabase(DataSource dataSource) throws Exception {
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(new ClassPathResource("data.sql"));
    populator.populate(dataSource.getConnection());
    return populator;
}
Also used : ResourceDatabasePopulator(org.springframework.jdbc.datasource.init.ResourceDatabasePopulator) ClassPathResource(org.springframework.core.io.ClassPathResource) DependsOn(org.springframework.context.annotation.DependsOn) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 3 with DependsOn

use of org.springframework.context.annotation.DependsOn in project spring-security by spring-projects.

the class DataConfig method initDatabase.

@Bean
@DependsOn("entityManagerFactory")
public ResourceDatabasePopulator initDatabase(DataSource dataSource) throws Exception {
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(new ClassPathResource("data.sql"));
    populator.populate(dataSource.getConnection());
    return populator;
}
Also used : ResourceDatabasePopulator(org.springframework.jdbc.datasource.init.ResourceDatabasePopulator) ClassPathResource(org.springframework.core.io.ClassPathResource) DependsOn(org.springframework.context.annotation.DependsOn) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 4 with DependsOn

use of org.springframework.context.annotation.DependsOn in project spring-security by spring-projects.

the class DataConfiguration method initDatabase.

@Bean
@DependsOn("entityManagerFactory")
public ResourceDatabasePopulator initDatabase(DataSource dataSource) throws Exception {
    ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
    populator.addScript(new ClassPathResource("data.sql"));
    populator.populate(dataSource.getConnection());
    return populator;
}
Also used : ResourceDatabasePopulator(org.springframework.jdbc.datasource.init.ResourceDatabasePopulator) ClassPathResource(org.springframework.core.io.ClassPathResource) DependsOn(org.springframework.context.annotation.DependsOn) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Example 5 with DependsOn

use of org.springframework.context.annotation.DependsOn in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850PersistenceConfig method iec61850EntityManagerFactory.

/**
     * Method for creating the Entity Manager Factory Bean.
     *
     * @return LocalContainerEntityManagerFactoryBean
     * @throws ClassNotFoundException
     *             when class not found
     */
@Bean
@DependsOn("iec61850Flyway")
public LocalContainerEntityManagerFactoryBean iec61850EntityManagerFactory() throws ClassNotFoundException {
    final LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
    entityManagerFactoryBean.setPersistenceUnitName("OSGP_PROTOCOL_ADAPTER_IEC61850");
    entityManagerFactoryBean.setDataSource(this.iec61850DataSource());
    entityManagerFactoryBean.setPackagesToScan(this.entityManagerPackagesToScan);
    entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistence.class);
    final Properties jpaProperties = new Properties();
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_DIALECT, this.hibernateDialect);
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_FORMAT_SQL, this.hibernateFormatSql);
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_NAMING_STRATEGY, this.hibernateNamingStrategy);
    jpaProperties.put(PROPERTY_NAME_HIBERNATE_SHOW_SQL, this.hibernateShowSql);
    entityManagerFactoryBean.setJpaProperties(jpaProperties);
    return entityManagerFactoryBean;
}
Also used : Properties(java.util.Properties) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) DependsOn(org.springframework.context.annotation.DependsOn) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Aggregations

DependsOn (org.springframework.context.annotation.DependsOn)7 Bean (org.springframework.context.annotation.Bean)6 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)4 ClassPathResource (org.springframework.core.io.ClassPathResource)3 ResourceDatabasePopulator (org.springframework.jdbc.datasource.init.ResourceDatabasePopulator)3 Properties (java.util.Properties)1 DataSource (org.apache.tomcat.jdbc.pool.DataSource)1 PoolProperties (org.apache.tomcat.jdbc.pool.PoolProperties)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 LdapContextSource (org.springframework.ldap.core.support.LdapContextSource)1