You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "IronCity (GitHub)" <gi...@apache.org> on 2018/12/27 11:27:53 UTC
[GitHub] [incubator-dubbo] IronCity opened issue #3082: 建议注解可以和XML配置一样,直接注入一个springbean,方便业务服务无改动使用
### Environment
* Dubbo version: 2.6.X 2.7.X
* Operating System version: mac
* Java version: 1.8
### 情景
#### 我们正常使用
```Java
@Service
public class DemoService {
@Reference(version = "1.2.3")
private XXService xxService;
}
```
#### 期望使用
```Java
@Configuration
public class DubboConfig {
@ReferenceConsumer(version = "1.2.3")
private XXService xxService;
}
@Service
public class BXXServiceImpl {
@Autowired
private XXService xxService;
}
@Service
public class AXXServiceImpl {
@Autowired
private XXService xxService;
}
```
希望能够用spring的方式去注入对象,目前dubbo通过XML配置是注册到spring的bean,但是@Reference并不是。
想法是加一个PostProcessor去做一次registry一个BeanDefinition
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3082 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] zonghaishang closed issue #3082: 建议注解可以和XML配置一样,直接注入一个springbean,方便业务服务无改动使用
Posted by "zonghaishang (GitHub)" <gi...@apache.org>.
[ issue closed by zonghaishang ]
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3082 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] zonghaishang commented on issue #3082: 建议注解可以和XML配置一样,直接注入一个springbean,方便业务服务无改动使用
Posted by "zonghaishang (GitHub)" <gi...@apache.org>.
只是使用方式问题,自己可以封装一个Bean, 里面持有reference字段就好了
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3082 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] lexburner commented on issue #3082: 建议注解可以和XML配置一样,直接注入一个springbean,方便业务服务无改动使用
Posted by "lexburner (GitHub)" <gi...@apache.org>.
I know that there are some RPC frameworks have the configuration as this issue shown. Maybe we should take this style of configuration into consideration.
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3082 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] chenlushun commented on issue #3082: 建议注解可以和XML配置一样,直接注入一个springbean,方便业务服务无改动使用
Posted by "chenlushun (GitHub)" <gi...@apache.org>.
这个命名我个人觉得,Reference已经具有Consumer的意思,所以我建议@ReferenceBean是不是更好?
当前呢,可以通过以下方式来实现,可能会稍微麻烦一些
```java
@Configuration
public class DubboConfig {
@Reference(version = "${demo.service.version}")
private DemoServie demoService;
@Bean
public DemoServie demoServie() {
return demoService;
}
}
```
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3082 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org
[GitHub] [incubator-dubbo] gudegg commented on issue #3082: 建议注解可以和XML配置一样,直接注入一个springbean,方便业务服务无改动使用
Posted by "gudegg (GitHub)" <gi...@apache.org>.
非常期待加入这种实现,这样远程引用就能集中在某个Config,而不是目前的@Reference散落在不同的类里面
[ Full content available at: https://github.com/apache/incubator-dubbo/issues/3082 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org