IndexController.java 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package com.uas.search.console.controller;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.stereotype.Controller;
  4. import org.springframework.web.bind.annotation.RequestMapping;
  5. import org.springframework.web.bind.annotation.ResponseBody;
  6. import com.uas.search.console.jms.AQListener;
  7. import com.uas.search.console.service.IndexService;
  8. /**
  9. * 索引创建相关请求
  10. * @author sunyj
  11. * @since 2016年8月5日 上午11:42:54
  12. */
  13. @Controller
  14. @RequestMapping("/index")
  15. public class IndexController {
  16. @Autowired
  17. private IndexService indexService;
  18. @Autowired
  19. private AQListener aqListener;
  20. /**
  21. * 初始化创建索引文件
  22. *
  23. * @return 所用时间 ms
  24. */
  25. @RequestMapping("/create")
  26. @ResponseBody
  27. public String initIndexes() {
  28. return "Indexes created success in " + indexService.createIndexs() + " ms.";
  29. }
  30. /**
  31. * 实时更新索引
  32. * @return
  33. */
  34. @RequestMapping("/listen")
  35. @ResponseBody
  36. public String listen(){
  37. new Thread(){
  38. public void run() {
  39. aqListener.execute();
  40. };
  41. }.start();
  42. return "Listen...";
  43. }
  44. }