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

com.aol.micro.server.mysql.distlock.datasource.MysqlDataSourceBuilder Maven / Gradle / Ivy

There is a newer version: 0.91.11
Show newest version
package com.aol.micro.server.mysql.distlock.datasource;

import javax.annotation.Resource;
import javax.sql.DataSource;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.zaxxer.hikari.HikariDataSource;

@Builder
@Configuration
@NoArgsConstructor
@AllArgsConstructor
public class MysqlDataSourceBuilder {

	@Resource(name = "distLockingEnv")
	private JdbcConfigDistLock env;

	@Bean(destroyMethod = "close", name = "distLockingDataSource")
	public DataSource mainDataSource() {
		return getDataSource();
	}

	private DataSource getDataSource() {
		HikariDataSource ds = new HikariDataSource();
		ds.setDriverClassName(env.getDriverClassName());
		ds.setJdbcUrl(env.getUrl());
		ds.setUsername(env.getUsername());
		ds.setPassword(env.getPassword());
		ds.setMaximumPoolSize(env.getMaxPoolSize());
		return ds;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy