038815099ed7cb8ccae1eab81f79c78cbf5bfc7e.svn-base 743 B

12345678910111213141516171819202122
  1. package org.jeecg.config;
  2. import org.jeecg.common.constant.CommonConstant;
  3. import org.springframework.context.annotation.Condition;
  4. import org.springframework.context.annotation.ConditionContext;
  5. import org.springframework.core.type.AnnotatedTypeMetadata;
  6. /**
  7. * 跨域配置加载条件
  8. */
  9. public class CorsFilterCondition implements Condition {
  10. @Override
  11. public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
  12. Object object = context.getEnvironment().getProperty(CommonConstant.CLOUD_SERVER_KEY);
  13. //如果没有服务注册发现的配置 说明是单体应用 则加载跨域配置 返回true
  14. if(object==null){
  15. return true;
  16. }
  17. return false;
  18. }
  19. }