убрали лишнюю spring-конфигурацию
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* DmitriyMX <dmitriymx@yandex.ru>
|
||||
* 2017-01-04
|
||||
*/
|
||||
package kinosearch.core;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import kinosearch.core.browser.ApacheHttpBrowser;
|
||||
import kinosearch.core.browser.Browser;
|
||||
import kinosearch.webapp.KinoPlaySerializer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan(basePackages = {"kinosearch.core.browser", "kinosearch.core.warez"})
|
||||
public class SpringConfig {
|
||||
@Bean
|
||||
@Scope("prototype")
|
||||
public Browser browser() {
|
||||
return new ApacheHttpBrowser();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Scope("singleton")
|
||||
public Gson gson() {
|
||||
return new GsonBuilder().registerTypeAdapter(KinoPlay.class, new KinoPlaySerializer()).create();
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@ import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
@@ -21,6 +23,8 @@ import java.io.InputStreamReader;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Component("browser")
|
||||
@Scope("prototype")
|
||||
public class ApacheHttpBrowser implements Browser {
|
||||
private Set<Header> headers = new HashSet<>();
|
||||
private String encoding = "UTF-8";
|
||||
|
||||
@@ -4,19 +4,25 @@
|
||||
*/
|
||||
package kinosearch.webapp;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import kinosearch.core.KinoPlay;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.context.annotation.*;
|
||||
import org.springframework.web.servlet.ViewResolver;
|
||||
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
|
||||
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
|
||||
|
||||
@Configuration
|
||||
@Import(kinosearch.core.SpringConfig.class)
|
||||
@ComponentScan(basePackages = {"kinosearch.core.browser", "kinosearch.core.warez"})
|
||||
@PropertySource("classpath:/application.properties")
|
||||
public class SpringConfig {
|
||||
@Bean
|
||||
@Scope("singleton")
|
||||
public Gson gson() {
|
||||
return new GsonBuilder().registerTypeAdapter(KinoPlay.class, new KinoPlaySerializer()).create();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public WebApp webapp(@Value("${webapp.host}") String host, @Value("${webapp.port}") int port) {
|
||||
return new WebApp(host, port);
|
||||
|
||||
@@ -2,9 +2,7 @@ package kinosearch.core.browser;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import kinosearch.core.SpringConfig;
|
||||
import kinosearch.core.browser.Browser;
|
||||
import static org.junit.Assert.*;
|
||||
import kinosearch.webapp.SpringConfig;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -13,6 +11,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {SpringConfig.class})
|
||||
public class TestBrowser {
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
*/
|
||||
package kinosearch.core.warez;
|
||||
|
||||
import kinosearch.core.KinoPlay;
|
||||
import kinosearch.core.SpringConfig;
|
||||
import kinosearch.webapp.SpringConfig;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
package kinosearch.core.warez;
|
||||
|
||||
import kinosearch.core.SpringConfig;
|
||||
import kinosearch.webapp.SpringConfig;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
Reference in New Issue
Block a user