3afba4d22528584380e5b6d03198f80dc46ca4a1.svn-base 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package org.jeecg.config.init;
  2. import lombok.extern.slf4j.Slf4j;
  3. import org.jeecg.common.constant.CacheConstant;
  4. import org.jeecg.config.JeecgCloudCondition;
  5. import org.jeecg.modules.system.service.ISysGatewayRouteService;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.boot.context.event.ApplicationReadyEvent;
  8. import org.springframework.context.ApplicationListener;
  9. import org.springframework.context.annotation.Conditional;
  10. import org.springframework.core.Ordered;
  11. import org.springframework.stereotype.Component;
  12. /**
  13. * @desc: 启动程序,初始化路由配置
  14. * @author: flyme
  15. */
  16. @Slf4j
  17. @Component
  18. @Conditional(JeecgCloudCondition.class)
  19. public class SystemInitListener implements ApplicationListener<ApplicationReadyEvent>, Ordered {
  20. @Autowired
  21. private ISysGatewayRouteService sysGatewayRouteService;
  22. @Override
  23. public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
  24. log.info(" 服务已启动,初始化路由配置 ###################");
  25. if (applicationReadyEvent.getApplicationContext().getDisplayName().indexOf("AnnotationConfigServletWebServerApplicationContext") > -1) {
  26. sysGatewayRouteService.addRoute2Redis(CacheConstant.GATEWAY_ROUTES);
  27. }
  28. }
  29. @Override
  30. public int getOrder() {
  31. return 1;
  32. }
  33. }