All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vlingo.xoom.data.SymbioJdbcDatabaseProvider Maven / Gradle / Ivy

Go to download

The easiest way to jump start your data and storage use with vlingo/xoom and the greater vlingo/PLATFORM.

There is a newer version: 1.3.0
Show newest version
// Copyright © 2012-2020 VLINGO LABS. All rights reserved.
//
// This Source Code Form is subject to the terms of the
// Mozilla Public License, v. 2.0. If a copy of the MPL
// was not distributed with this file, You can obtain
// one at https://mozilla.org/MPL/2.0/.

package io.vlingo.xoom.data;

import javax.inject.Singleton;
import javax.sql.DataSource;

import io.micronaut.context.annotation.Requires;
import io.micronaut.jdbc.BasicJdbcConfiguration;
import io.vlingo.symbio.store.common.jdbc.DatabaseType;
import io.vlingo.xoom.data.config.DataConfiguration;

@Singleton
@Requires(beans = DataSource.class)
public class SymbioJdbcDatabaseProvider {

    private final DataConfiguration dataConfiguration;
    private final DataSource dataSource;
    private final JdbcStorageConfiguration jdbcStorageConfiguration;

    public SymbioJdbcDatabaseProvider(DataConfiguration dataConfiguration, DataSource dataSource,
                                      BasicJdbcConfiguration jdbcConfiguration)
            throws Exception {
        this.dataConfiguration = dataConfiguration;
        this.dataSource = dataSource;
        this.jdbcStorageConfiguration = new JdbcStorageConfiguration(dataConfiguration.getDatabaseType() == null ?
                DatabaseType.databaseType(jdbcConfiguration.getUrl()) :
                DatabaseType.databaseType(dataConfiguration.getDatabaseType()), dataConfiguration, jdbcConfiguration);
    }

    public DataConfiguration getDataConfiguration() {
        return dataConfiguration;
    }

    public DataSource getDataSource() {
        return dataSource;
    }

    public JdbcStorageConfiguration getJdbcStorageConfiguration() {
        return jdbcStorageConfiguration;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy