Spring config
This commit is contained in:
@@ -33,16 +33,9 @@ import java.util.*;
|
||||
public class WebAppController {
|
||||
@Autowired
|
||||
private ServletContext webAppContext;
|
||||
@Autowired
|
||||
private ApplicationContext coreContext;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
this.coreContext = new AnnotationConfigApplicationContext(
|
||||
"kinosearch.core.browser",
|
||||
"kinosearch.core.warez"
|
||||
);
|
||||
}
|
||||
|
||||
private void setDefaultModel(ModelMap model) {
|
||||
model.addAttribute("basedir", webAppContext.getContextPath());
|
||||
model.addAttribute("version", "2.0.8");
|
||||
@@ -69,10 +62,10 @@ public class WebAppController {
|
||||
|
||||
private void search(String search, ModelMap model, boolean strong) {
|
||||
List<Kino> list = Collections.synchronizedList(new LinkedList<>());
|
||||
Set<KinoWarez> kinoWarezSet = Tools.getKinoWarezSet();
|
||||
Map<String, KinoWarez> kinoWarezMap = coreContext.getBeansOfType(KinoWarez.class);
|
||||
|
||||
ThreadGroup threadGroup = new ThreadGroup("");
|
||||
for (KinoWarez kinoWarez : kinoWarezSet) { //TODO на будущее надо ограничить количество одновременных потоков
|
||||
for (KinoWarez kinoWarez : kinoWarezMap.values()) { //TODO на будущее надо ограничить количество одновременных потоков
|
||||
new Thread(threadGroup, () -> {
|
||||
List<Kino> outList = kinoWarez.search(search, strong);
|
||||
|
||||
@@ -158,7 +151,10 @@ public class WebAppController {
|
||||
setDefaultModel(model);
|
||||
setDefaultResponse(response);
|
||||
|
||||
KinoWarez kinoWarez = new Onlinelife();
|
||||
KinoWarez kinoWarez = coreContext.getBean(warez, KinoWarez.class);
|
||||
if (kinoWarez == null) {
|
||||
return "redirect:/";
|
||||
}
|
||||
String json = kinoWarez.player(request.getServletPath().substring(("/player/"+warez).length()));
|
||||
model.put("json", json);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user