fr.ird.observe.services.ObserveServiceInitializer Maven / Gradle / Ivy
Show all versions of toolkit-service Show documentation
package fr.ird.observe.services;
/*
* #%L
* ObServe Toolkit :: Service
* %%
* Copyright (C) 2017 - 2021 Ultreia.io
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* .
* #L%
*/
import fr.ird.observe.dto.db.configuration.ObserveDataSourceConfiguration;
import fr.ird.observe.dto.db.configuration.ObserveDataSourceConfigurationAndConnection;
import fr.ird.observe.dto.db.configuration.ObserveDataSourceConfigurationAndConnectionDto;
import fr.ird.observe.dto.db.configuration.ObserveDataSourceConnection;
import java.util.Objects;
/**
* Objet contentant les informations nécessaire pour créer un nouveau service.
*
* Ces informations viennent en général du context applicatif appelant.
*
* Created on 31/08/15.
*
* @author Tony Chemit - [email protected]
*/
public class ObserveServiceInitializer implements ObserveDataSourceConfigurationAndConnection {
private final ObserveServiceInitializerConfig initializerConfig;
private final ObserveDataSourceConfigurationAndConnection configurationAndConnection;
public ObserveServiceInitializer(ObserveServiceInitializer initializer, ObserveDataSourceConfiguration dataSourceConfiguration, ObserveDataSourceConnection dataSourceConnection) {
this(initializer.getInitializerConfig(), dataSourceConfiguration, dataSourceConnection);
}
public ObserveServiceInitializer(ObserveServiceInitializerConfig initializerConfig, ObserveDataSourceConfiguration dataSourceConfiguration, ObserveDataSourceConnection dataSourceConnection) {
this.initializerConfig = Objects.requireNonNull(initializerConfig);
this.configurationAndConnection = new ObserveDataSourceConfigurationAndConnectionDto(dataSourceConfiguration, dataSourceConnection);
}
public ObserveServiceInitializerConfig getInitializerConfig() {
return initializerConfig;
}
@Override
public ObserveDataSourceConfiguration getConfiguration() {
return configurationAndConnection.getConfiguration();
}
@Override
public ObserveDataSourceConnection getConnection() {
return configurationAndConnection.getConnection();
}
@Override
public void setConfiguration(ObserveDataSourceConfiguration configuration) {
this.configurationAndConnection.setConfiguration(configuration);
}
@Override
public void setConnection(ObserveDataSourceConnection connection) {
this.configurationAndConnection.setConnection(connection);
}
}