diff options
author | Alexander Alexeev | 2016-11-18 15:36:16 +0700 |
---|---|---|
committer | Vitaly Takmazov | 2016-11-23 13:02:59 +0300 |
commit | 606e2a8d6fc8af288632e2857d3a89770fdbb69c (patch) | |
tree | f160cbe3f09459f2dd0dff441c5fbb8336c8a3d4 /juick-server/src/main/java/com/juick/configuration/SearchConfiguration.java | |
parent | d64b673c0d69309ff7ad75ffd1d3d7c3f664c8a1 (diff) |
SearchService stub for most cases
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.java | 28 |
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()); } } |