Skip to content

Commit

Permalink
Merge pull request #5 from gglaochen/feature_zzt
Browse files Browse the repository at this point in the history
invoke dubbo service success 😄
  • Loading branch information
CengSin authored Nov 1, 2019
2 parents e6ff248 + 6752caa commit 626db97
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.feign.dubbo.example.core;

import feign.Feign;
import org.apache.dubbo.config.AbstractConfig;
import org.apache.dubbo.config.spring.beans.factory.annotation.DubboBuilder;
import org.apache.dubbo.config.spring.beans.factory.annotation.FeignClient2DubboPostProcessor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand All @@ -24,4 +26,9 @@ public FeignClient2DubboPostProcessor feignClient2DubboPostProcessor(Environment
return new FeignClient2DubboPostProcessor(basePackages);
}

@Bean
public Feign.Builder feignDubboBuilder() {
return new DubboBuilder();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
import feign.Feign;
import feign.Target;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.util.ReflectionUtils;

import static org.apache.dubbo.config.spring.util.AnnotationUtils.getAttributes;
import static org.springframework.core.annotation.AnnotationAttributes.fromMap;

@Component
public class DubboBuilder extends Feign.Builder {

private final ApplicationContext applicationContext;
@Autowired
private ApplicationContext applicationContext;

private Reference defaultReference;

Expand All @@ -22,10 +22,9 @@ static final class DefaultReferenceClass {
String field;
}

public DubboBuilder(ApplicationContext applicationContext) {
public DubboBuilder() {
// 产生@Reference 默认配置实例
this.defaultReference = ReflectionUtils.findField(DubboBuilder.DefaultReferenceClass.class, "field").getAnnotation(Reference.class);
this.applicationContext = applicationContext;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ private AbstractBeanDefinition buildServiceBeanDefine(Service service, Class<?>
builder.addPropertyReference("ref", environment.resolvePlaceholders(annotatedServiceBeanName));
}

if (StringUtils.hasText(interfaceClass.getName())) {
builder.addPropertyValue("interface", interfaceClass.getName());
}

if (null != service) {
if (StringUtils.hasText(service.provider())) {
builder.addPropertyValue("provider", service.provider());
Expand Down

0 comments on commit 626db97

Please sign in to comment.