aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/configuration
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-06-29 14:03:04 +0300
committerGravatar Vitaly Takmazov2017-06-29 14:03:04 +0300
commit02723131139806c761539a42a5fa80b68ecadee8 (patch)
treeca66f22993908758385f708eb2da4e4aeb20510a /juick-server/src/main/java/com/juick/configuration
parent4cc4b08f4377b7db697abdb533c625da608eb3d3 (diff)
project structure: split server into jdbc + web
Diffstat (limited to 'juick-server/src/main/java/com/juick/configuration')
-rw-r--r--juick-server/src/main/java/com/juick/configuration/DataConfiguration.java80
-rw-r--r--juick-server/src/main/java/com/juick/configuration/SearchConfiguration.java43
-rw-r--r--juick-server/src/main/java/com/juick/configuration/UpdaterConfiguration.java30
3 files changed, 0 insertions, 153 deletions
diff --git a/juick-server/src/main/java/com/juick/configuration/DataConfiguration.java b/juick-server/src/main/java/com/juick/configuration/DataConfiguration.java
deleted file mode 100644
index 4258703d..00000000
--- a/juick-server/src/main/java/com/juick/configuration/DataConfiguration.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package com.juick.configuration;
-
-import com.juick.database.MySqlUpdater;
-import com.juick.service.search.SearchService;
-import org.apache.commons.dbcp2.BasicDataSource;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.context.annotation.*;
-import org.springframework.core.env.Environment;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.datasource.DataSourceTransactionManager;
-import org.springframework.transaction.PlatformTransactionManager;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
-import org.springframework.transaction.annotation.TransactionManagementConfigurer;
-
-import javax.annotation.Resource;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Created by aalexeev on 11/11/16.
- */
-@Configuration
-@EnableTransactionManagement
-@PropertySource(value = {"classpath:juick.conf"})
-@ComponentScan(basePackages = {"com.juick.service"})
-public class DataConfiguration implements TransactionManagementConfigurer {
- @Resource
- private Environment env;
-
- // NOTE: The close() method will be called automatically with default @Bean settings
- // But Datasource interface has no close() method
- @Bean
- public BasicDataSource dataSource() {
- BasicDataSource dataSource = new BasicDataSource();
-
- dataSource.setDriverClassName(env.getProperty("datasource_driver", "com.mysql.jdbc.Driver"));
- dataSource.setUrl(env.getProperty("datasource_url"));
- dataSource.setUsername(env.getProperty("datasource_user", StringUtils.EMPTY));
- dataSource.setPassword(env.getProperty("datasource_password", StringUtils.EMPTY));
-
- dataSource.setValidationQuery("select 1");
-
- return dataSource;
- }
-
- @Bean
- public PlatformTransactionManager transactionManager() {
- return new DataSourceTransactionManager(dataSource());
- }
-
- @Override
- public PlatformTransactionManager annotationDrivenTransactionManager() {
- return transactionManager();
- }
-
- @Bean
- @DependsOn("dataSource")
- public JdbcTemplate jdbcTemplate() {
- return new JdbcTemplate(dataSource());
- }
-
- @Bean
- public SearchService emptySearchService() {
- return new SearchService() {
- @Override
- public void setMaxResult(int maxResult) {
- }
-
- @Override
- public List<Integer> searchInAllMessages(String searchString, int messageIdBefore) {
- return Collections.emptyList();
- }
-
- @Override
- public List<Integer> searchByStringAndUser(String searchString, int userId, int messageIdBefore) {
- return Collections.emptyList();
- }
- };
- }
-}
diff --git a/juick-server/src/main/java/com/juick/configuration/SearchConfiguration.java b/juick-server/src/main/java/com/juick/configuration/SearchConfiguration.java
deleted file mode 100644
index e6b446b6..00000000
--- a/juick-server/src/main/java/com/juick/configuration/SearchConfiguration.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.juick.configuration;
-
-import com.juick.service.search.SearchService;
-import com.juick.service.search.SphinxSearchServiceImpl;
-import org.apache.commons.dbcp2.BasicDataSource;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.DependsOn;
-import org.springframework.context.annotation.PropertySource;
-import org.springframework.core.env.Environment;
-
-import javax.annotation.Resource;
-
-/**
- * Created by aalexeev on 11/18/16.
- */
-@Configuration
-@PropertySource(value = {"classpath:juick.conf"})
-public class SearchConfiguration {
- @Resource
- private Environment env;
-
- // NOTE: The close() method will be called automatically with default @Bean settings
- // But Datasource interface has no close() method
- @Bean
- public BasicDataSource searchDataSource() {
- BasicDataSource dataSource = new BasicDataSource();
-
- dataSource.setDriverClassName(env.getProperty("sphinx_driver", "com.mysql.jdbc.Driver"));
- dataSource.setUrl(env.getProperty("sphinx_url"));
- dataSource.setUsername(env.getProperty("sphinx_user", StringUtils.EMPTY));
- dataSource.setPassword(env.getProperty("sphinx_password", StringUtils.EMPTY));
-
- return dataSource;
- }
-
- @Bean
- @DependsOn("searchDataSource")
- public SearchService searchService() {
- return new SphinxSearchServiceImpl(searchDataSource());
- }
-}
diff --git a/juick-server/src/main/java/com/juick/configuration/UpdaterConfiguration.java b/juick-server/src/main/java/com/juick/configuration/UpdaterConfiguration.java
deleted file mode 100644
index b3c0424c..00000000
--- a/juick-server/src/main/java/com/juick/configuration/UpdaterConfiguration.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.juick.configuration;
-
-import com.juick.database.MySqlUpdater;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.DependsOn;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.transaction.PlatformTransactionManager;
-
-import javax.inject.Inject;
-
-/**
- * Created by aalexeev on 12/13/16.
- */
-@Configuration
-public class UpdaterConfiguration {
- @Inject
- JdbcTemplate jdbcTemplate;
- @Inject
- PlatformTransactionManager transactionManager;
-
- @Bean
- @DependsOn({"jdbcTemplate", "transactionManager"})
- public MySqlUpdater updater() {
- return new MySqlUpdater(
- jdbcTemplate,
- transactionManager,
- "update.sql");
- }
-}