Regression faulty gitignore blocked config package

This commit is contained in:
Rohan Sircar 2020-05-31 17:07:36 +05:30
parent 012fbb3f7c
commit 36ba88a546
4 changed files with 113 additions and 0 deletions

View File

@ -0,0 +1,16 @@
package org.ros.chatto.config;
import org.ehcache.event.CacheEvent;
import org.ehcache.event.CacheEventListener;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class CustomCacheEventLogger implements CacheEventListener<Object, Object> {
@Override
public void onEvent(CacheEvent<? extends Object, ? extends Object> cacheEvent) {
log.debug("custom Caching event {} key = {} old {} new {} ", cacheEvent.getType(), cacheEvent.getKey(),
cacheEvent.getOldValue(), cacheEvent.getNewValue());
}
}

View File

@ -0,0 +1,33 @@
package org.ros.chatto.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import lombok.Getter;
@Component
@EnableConfigurationProperties
@PropertySource(value = "classpath:queries.properties")
@Getter
public class DBInitializerConfig {
private final String dbName;
private final String numTablesQuery;
private final String resetSessionsQuery;
private final String clearTokensQuery;
public DBInitializerConfig(@Value("${chatto.datasource.database-name}") String dbName,
@Value("${num-tables}") String numTablesQuery, @Value("${reset-sessions}") String resetSessionsQuery,
@Value("${clear-tokens}") String clearTokensQuery) {
this.dbName = dbName;
this.numTablesQuery = numTablesQuery;
this.resetSessionsQuery = resetSessionsQuery;
this.clearTokensQuery = clearTokensQuery;
}
}

View File

@ -0,0 +1,54 @@
package org.ros.chatto.config;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
@Configuration
@Component
// @ConfigurationProperties(prefix = "chatto.datasource")
@Getter
// @Setter
@Slf4j
public class DataSourceConfig {
// jdbc:mysql://localhost:3306/chatto_db?useSSL=false
private final String DATASOURCE_URL = "jdbc:mysql://%s:%d/%s?%s";
private final String username;
private final String password;
private final String databaseName;
private final String url;
private final int port;
private final String params;
public DataSourceConfig(@Value("${chatto.datasource.username}") String username,
@Value("${chatto.datasource.password}") String password,
@Value("${chatto.datasource.database-name}") String databaseName,
@Value("${chatto.datasource.url}") String url, @Value("${chatto.datasource.port}") int port,
@Value("${chatto.datasource.params}") String params) {
this.username = username;
this.password = password;
this.databaseName = databaseName;
this.url = url;
this.port = port;
this.params = params;
}
@Bean
public DataSource getDataSource() {
final DataSourceBuilder<?> dataSourceBuilder = DataSourceBuilder.create();
dataSourceBuilder.url(String.format(DATASOURCE_URL, url, port, databaseName, params));
dataSourceBuilder.username(username);
dataSourceBuilder.password(password);
return dataSourceBuilder.build();
}
}

View File

@ -0,0 +1,10 @@
package org.ros.chatto.config;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration;
@EnableCaching
@Configuration
public class EhCacheConfig {
}