當前位置: 首頁>>代碼示例>>Java>>正文


Java FeignClient類代碼示例

本文整理匯總了Java中org.springframework.cloud.netflix.feign.FeignClient的典型用法代碼示例。如果您正苦於以下問題:Java FeignClient類的具體用法?Java FeignClient怎麽用?Java FeignClient使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FeignClient類屬於org.springframework.cloud.netflix.feign包,在下文中一共展示了FeignClient類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: after

import org.springframework.cloud.netflix.feign.FeignClient; //導入依賴的package包/類
/**
 * @param data
 * @throws ClassNotFoundException
 * @throws HttpMessageNotWritableException
 * @throws IOException
 */
@AfterReturning(pointcut = "point()", returning = "data")
public void after(JoinPoint jp, Object data) throws Exception {
    MethodInvocationProceedingJoinPoint joinPoint = (MethodInvocationProceedingJoinPoint) jp;
    Class<?> clazz = joinPoint.getSignature().getDeclaringType();
    if (AnnotationUtils.findAnnotation(clazz, FeignClient.class) == null) {
        log.debug("未找到feign 客戶端");
        return;
    }
    CustomSecurityContext securityContext = SecurityContextHystrixRequestVariable.getInstance().get();
    ErrorResult errorResult = null;
    if (securityContext != null && (errorResult = securityContext.getErrorResult()) != null) {
        if (errorResult.getHttpStatus() != HttpStatus.OK.value()) {
            Class<?> exceptionClass = Class.forName(errorResult.getException());
            Constructor<?> constructor = exceptionClass.getConstructor(new Class[]{String.class, String.class});
            throw (CustomException) constructor
                    .newInstance(new Object[]{errorResult.getMessage(), errorResult.getCode()});
        }
    }
    SecurityContextHystrixRequestVariable.getInstance().remove();
}
 
開發者ID:zhaoqilong3031,項目名稱:spring-cloud-samples,代碼行數:27,代碼來源:DefaultFeignExceptionHandlerInterceptor.java

示例2: feignWebRegistrations

import org.springframework.cloud.netflix.feign.FeignClient; //導入依賴的package包/類
@Bean
public WebMvcRegistrations feignWebRegistrations() {
    return new WebMvcRegistrationsAdapter() {
        @Override
        public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
            return new RequestMappingHandlerMapping() {
                @Override
                protected boolean isHandler(Class<?> beanType) {
                    return super.isHandler(beanType) && (AnnotationUtils.findAnnotation(beanType, FeignClient.class) == null);
                }
            };
        }
    };
}
 
開發者ID:richterplus,項目名稱:spring-cloud-sample,代碼行數:15,代碼來源:FeignConfig.java

示例3: isHandler

import org.springframework.cloud.netflix.feign.FeignClient; //導入依賴的package包/類
@Override
protected boolean isHandler(Class<?> beanType) {
	//避免springmvc 把抽象出來的帶有RequestMapping注解的client接口掃描到controller注冊
	if(BootCloudUtils.isNetflixFeignClientPresent() && AnnotatedElementUtils.hasAnnotation(beanType, FeignClient.class)){
		if(log.isInfoEnabled()){
			log.info("ignore FeignClient: {}", beanType);
		}
		return false;
	}
	return super.isHandler(beanType);
}
 
開發者ID:wayshall,項目名稱:onetwo,代碼行數:12,代碼來源:FixFeignClientsHandlerMapping.java

示例4: processAnnotationOnClass

import org.springframework.cloud.netflix.feign.FeignClient; //導入依賴的package包/類
@Override
protected void processAnnotationOnClass(MethodMetadata data, Class<?> clz) {
	super.processAnnotationOnClass(data, clz);
	if (clz.isAnnotationPresent(FeignClient.class)) {
		EnhanceFeignClient classAnnotation = findMergedAnnotation(clz, EnhanceFeignClient.class);
		Optional<String> basePathOpt = getFeignBasePath(clz, classAnnotation);
		if(basePathOpt.isPresent()){
			data.template().insert(0, basePathOpt.get());
		}
	}
}
 
開發者ID:wayshall,項目名稱:onetwo,代碼行數:12,代碼來源:EnhanceSpringMvcContract.java

示例5: getFeignBasePath

import org.springframework.cloud.netflix.feign.FeignClient; //導入依賴的package包/類
@SuppressWarnings("deprecation")
	private Optional<String> getFeignBasePath(Class<?> clz, EnhanceFeignClient classAnnotation){
		if (classAnnotation == null){
			return Optional.empty();
		}
		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);
		}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);
	}
 
開發者ID:wayshall,項目名稱:onetwo,代碼行數:31,代碼來源:EnhanceSpringMvcContract.java

示例6: apply

import org.springframework.cloud.netflix.feign.FeignClient; //導入依賴的package包/類
@Override
public JAnnotationUse apply(ApiResourceMetadata controllerMetadata, JDefinedClass generatableType) {
    JAnnotationUse feignClient = generatableType.annotate(FeignClient.class);
    
    feignClient.param("url", controllerMetadata.getControllerUrl());
    feignClient.param("name", getClientName(controllerMetadata));

    return feignClient;
}
 
開發者ID:phoenixnap,項目名稱:springmvc-raml-plugin,代碼行數:10,代碼來源:SpringFeignClientClassAnnotationRule.java

示例7: testAnnnotations

import org.springframework.cloud.netflix.feign.FeignClient; //導入依賴的package包/類
@Test
public void testAnnnotations() throws Exception {
	Map<String, Object> beans = this.context
			.getBeansWithAnnotation(FeignClient.class);
	assertTrue("Wrong clients: " + beans,
			beans.containsKey(TestClient.class.getName()));
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-netflix,代碼行數:8,代碼來源:FeignClientTests.java

示例8: FeignClientAnnotationRelationshipDetector

import org.springframework.cloud.netflix.feign.FeignClient; //導入依賴的package包/類
public FeignClientAnnotationRelationshipDetector() {
    super(FeignClient.class);
}
 
開發者ID:cereebro,項目名稱:cereebro,代碼行數:4,代碼來源:FeignClientAnnotationRelationshipDetector.java

示例9: extractFromAnnotation

import org.springframework.cloud.netflix.feign.FeignClient; //導入依賴的package包/類
@Override
protected Set<Relationship> extractFromAnnotation(FeignClient annotation) {
    Dependency dependency = Dependency.on(Component.of(annotation.name(), ComponentType.HTTP_APPLICATION));
    return dependency.asRelationshipSet();
}
 
開發者ID:cereebro,項目名稱:cereebro,代碼行數:6,代碼來源:FeignClientAnnotationRelationshipDetector.java

示例10: isHandler

import org.springframework.cloud.netflix.feign.FeignClient; //導入依賴的package包/類
@Override
protected boolean isHandler(Class<?> beanType) {
    return super.isHandler(beanType) && !AnnotatedElementUtils.hasAnnotation(beanType, FeignClient.class);
}
 
開發者ID:hulvyou,項目名稱:spring-cloud-template,代碼行數:5,代碼來源:FeignConfig.java


注:本文中的org.springframework.cloud.netflix.feign.FeignClient類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。