org.springframework.cloud.netflix.feign.FeignClient Java Examples
The following examples show how to use
org.springframework.cloud.netflix.feign.FeignClient.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FixFeignClientsHandlerMapping.java From onetwo with Apache License 2.0 | 5 votes |
@Override protected boolean isHandler(Class<?> beanType) { //避免springmvc 把抽象出来的带有RequestMapping注解的client接口扫描到controller注册 boolean isFeignClient = AnnotatedElementUtils.hasAnnotation(beanType, FeignClient.class); if(BootCloudUtils.isNetflixFeignClientPresent() && isFeignClient){ if(log.isInfoEnabled()){ log.info("ignore FeignClient: {}", beanType); } return false; } return super.isHandler(beanType); }
Example #2
Source File: ExtFeignConfiguration.java From onetwo with Apache License 2.0 | 5 votes |
@Bean // @ConditionalOnMissingBean(Logger.Level.class) // @ConditionalOnProperty("jfish.cloud.feign.logger.level") public Logger.Level feignLoggerLevel(){ Logger.Level level = feignProperties.getLogger().getLevel(); if(level==null){ if(bootSpringConfig.isDev()){ level = Logger.Level.FULL; }else if(bootSpringConfig.isTest()){ level = Logger.Level.BASIC; }else{ level = Logger.Level.NONE; } } if(level!=Logger.Level.NONE && feignProperties.getLogger().isAutoChangeLevel()){ Set<String> apiNames = Stream.of(Springs.getInstance().getAppContext().getBeanDefinitionNames()) .filter(beanName->applicationContext.findAnnotationOnBean(beanName, FeignClient.class)!=null) .collect(Collectors.toSet()); simpleLoggerManager.changeLevels("DEBUG", apiNames.toArray(new String[0])); } /*if(level!=Logger.Level.NONE && feignProperties.getLogger().isAutoChangeLevel()){ Set<String> apiNames = SpringUtils.getBeansWithAnnotation(applicationContext, FeignClient.class) .stream().map(d -> { return d.getName(); }) .collect(Collectors.toSet()); simpleLoggerManager.changeLevels("DEBUG", apiNames.toArray(new String[0])); }*/ return level; }
Example #3
Source File: EnhanceSpringMvcContract.java From onetwo with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") private Optional<String> getFeignBasePath(Class<?> clz, EnhanceFeignClient classAnnotation){ if (classAnnotation == null){ return Optional.empty(); } /*if(clz.getName().contains("ProductApiClient") || clz.getName().contains("ProductApi")){ System.out.println("test"); }*/ String pathValue = classAnnotation.basePath(); if(StringUtils.isBlank(pathValue)){ FeignClient feignClient = findMergedAnnotation(clz, FeignClient.class); String serviceName = StringUtils.isNotBlank(feignClient.name())?feignClient.name():feignClient.serviceId(); serviceName = SpringUtils.resolvePlaceholders(applicationContext, serviceName); //不填,默认查找对应的配置 -> jfish.cloud.feign.basePath.serviceName /*pathValue = FEIGN_BASE_PATH_KEY + serviceName; pathValue = this.relaxedPropertyResolver.getProperty(pathValue);*/ ServiceProps serviceProps = this.feignProperties.getServices().get(serviceName); if (serviceProps!=null) { pathValue = serviceProps.getBasePath(); } if(StringUtils.isBlank(pathValue)){ // jfish.cloud.feign.base.contextPath pathValue = this.relaxedPropertyResolver.getProperty(FeignProperties.FEIGN_CONTEXT_PATH_KEY); //兼容旧配置 if(StringUtils.isBlank(pathValue)){ pathValue = this.relaxedPropertyResolver.getProperty(FEIGN_CONTEXT_PATH_KEY2); } } }/*else if(pathValue.startsWith(FEIGN_BASE_PATH_TAG)){ //:serviceName -> jfish.cloud.feign.basePath.serviceName pathValue = FEIGN_BASE_PATH_KEY + pathValue.substring(1); pathValue = this.relaxedPropertyResolver.getProperty(pathValue); }*/else if(ExpressionFacotry.DOLOR.isExpresstion(pathValue)){ //${basePath} pathValue = SpringUtils.resolvePlaceholders(applicationContext, pathValue); } if(StringUtils.isBlank(pathValue)){ return Optional.empty(); } if (!pathValue.startsWith("/")) { pathValue = "/" + pathValue; } // data.template().insert(0, pathValue); return Optional.ofNullable(pathValue); }