Java 类org.springframework.boot.autoconfigure.jdbc.DataSourceInitializedEvent 实例源码

项目:druid-spring-boot    文件:DruidDataSourceInitializer.java   
private void runSchemaScripts() {
    List<Resource> scripts = getScripts("spring.datasource.schema",
            this.properties.getSchema(), "schema");
    if (!scripts.isEmpty()) {
        String username = this.properties.getSchemaUsername();
        String password = this.properties.getSchemaPassword();
        runScripts(scripts, username, password);
        try {
            this.applicationContext
                    .publishEvent(new DataSourceInitializedEvent(this.dataSource));
            // The listener might not be registered yet, so don't rely on it.
            if (!this.initialized) {
                runDataScripts();
                this.initialized = true;
            }
        } catch (IllegalStateException ex) {
            logger.warn("Could not send event to complete DataSource initialization ("
                    + ex.getMessage() + ")");
        }
    }
}
项目:spring-boot-multidatasource    文件:DataSourceInitializer.java   
private void runSchemaScripts() {
    String indexStr = getIndexStr();
    List<Resource> scripts = getScripts("spring.datasource" + indexStr + ".schema",
            this.properties.getSchema(), "schema" + indexStr);
    if (!scripts.isEmpty()) {
        String username = this.properties.getSchemaUsername();
        String password = this.properties.getSchemaPassword();
        runScripts(scripts, username, password);
        try {
            this.applicationContext
                    .publishEvent(new DataSourceInitializedEvent(this.dataSource));
            // The listener might not be registered yet, so don't rely on it.
            if (!this.initialized) {
                runDataScripts();
                this.initialized = true;
            }
        }
        catch (IllegalStateException ex) {
            logger.warn("Could not send event to complete DataSource initialization ("
                    + ex.getMessage() + ")");
        }
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:DataSourceInitializedPublisher.java   
@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
        throws BeansException {
    if (bean instanceof DataSource) {
        // Normally this will be the right DataSource
        this.dataSource = (DataSource) bean;
    }
    if (bean instanceof JpaProperties) {
        this.properties = (JpaProperties) bean;
    }
    if (bean instanceof EntityManagerFactory && this.dataSource != null
            && isInitializingDatabase()) {
        this.applicationContext
                .publishEvent(new DataSourceInitializedEvent(this.dataSource));
    }
    return bean;
}
项目:spring-boot-concourse    文件:DataSourceInitializedPublisher.java   
@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
        throws BeansException {
    if (bean instanceof DataSource) {
        // Normally this will be the right DataSource
        this.dataSource = (DataSource) bean;
    }
    if (bean instanceof JpaProperties) {
        this.properties = (JpaProperties) bean;
    }
    if (bean instanceof EntityManagerFactory && this.dataSource != null
            && isInitializingDatabase()) {
        this.applicationContext
                .publishEvent(new DataSourceInitializedEvent(this.dataSource));
    }
    return bean;
}
项目:contestparser    文件:DataSourceInitializedPublisher.java   
@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
        throws BeansException {
    if (bean instanceof DataSource) {
        // Normally this will be the right DataSource
        this.dataSource = (DataSource) bean;
    }
    if (bean instanceof JpaProperties) {
        this.properties = (JpaProperties) bean;
    }
    if (bean instanceof EntityManagerFactory && this.dataSource != null
            && isInitializingDatabase()) {
        this.applicationContext
                .publishEvent(new DataSourceInitializedEvent(this.dataSource));
    }
    return bean;
}
项目:druid-spring-boot    文件:DruidDataSourceInitializer.java   
@Override
public void onApplicationEvent(DataSourceInitializedEvent event) {
    if (!this.properties.isInitialize()) {
        logger.debug("Initialization disabled (not running data scripts)");
        return;
    }
    // NOTE the event can happen more than once and
    // the event datasource is not used here
    if (!this.initialized) {
        runDataScripts();
        this.initialized = true;
    }
}
项目:spring-boot-multidatasource    文件:DataSourceInitializer.java   
@Override
public void onApplicationEvent(DataSourceInitializedEvent event) {
    if (!this.properties.isInitialize()) {
        logger.debug("Initialization disabled (not running data scripts)");
        return;
    }
    // NOTE the event can happen more than once and
    // the event datasource is not used here
    if (!this.initialized) {
        runDataScripts();
        this.initialized = true;
    }
}