aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/configuration/SearchConfiguration.java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com/juick/configuration/SearchConfiguration.java')
-rw-r--r--juick-server/src/main/java/com/juick/configuration/SearchConfiguration.java28
1 files changed, 7 insertions, 21 deletions
diff --git a/juick-server/src/main/java/com/juick/configuration/SearchConfiguration.java b/juick-server/src/main/java/com/juick/configuration/SearchConfiguration.java
index 40473433..1cf5c1a1 100644
--- a/juick-server/src/main/java/com/juick/configuration/SearchConfiguration.java
+++ b/juick-server/src/main/java/com/juick/configuration/SearchConfiguration.java
@@ -9,8 +9,6 @@ import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import javax.annotation.Resource;
-import java.util.Collections;
-import java.util.List;
/**
* Created by aalexeev on 11/18/16.
@@ -21,34 +19,22 @@ 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 SearchService searchService() {
+ public BasicDataSource searchDataSource() {
BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(env.getProperty("sphinx_driver", "com.mysql.jdbc.Driver"));
- dataSource.setUrl(env.getProperty("sphinx_url", "jdbc:mysql://127.0.0.1:9306?autoReconnect=true&useUnicode=yes&characterEncoding=utf8&maxAllowedPacket=512000"));
+ dataSource.setUrl(env.getProperty("sphinx_url"));
dataSource.setUsername(env.getProperty("sphinx_user", ""));
dataSource.setPassword(env.getProperty("sphinx_password", ""));
- return new SphinxSearchServiceImpl(dataSource);
+ return 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();
- }
- };
+ public SearchService searchService() {
+ return new SphinxSearchServiceImpl(searchDataSource());
}
}