-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SOFABoot quick start documentation issue #1031
Comments
@SofaService(interfaceType = HelloSyncService.class, bindings = {@SofaServiceBinding(bindingType = "bolt")})
@Component
public class HelloSyncServiceImpl implements HelloSyncService {
...
} We can make it a community task. Update 11.19: This task will be assigned to @IrvingOS |
如果类上 |
@Kunple-w 恩恩 我理解是想改成这样的。用户只需要写 |
@seeflood 我的想法是类似于Spring的 |
after the @SofaService is annotated, the @component should not be necessary |
@Kunple-w 不能向下兼容的话,就不合适了~因为有很多生产用户在用,不兼容的话用户体验比较差。 |
Cool ! Could u please describe your design on how to implement it? |
@seeflood 实现方式有多种,
|
@Kunple-w 考虑的还是很全面的,这个目前非开源版也做了些尝试,是通过组合注解的方式来实现的。因为SOFABoot中主要也是会强依赖spring相关的组件,所以推荐方式一,简单可行。 |
一开始我想认领这个 我的想法是,
扫描要实现,对对应的包进行扫描。有两种实现方式。
其实我比较倾向于 用 可以讨论一下是否可以添加对应的依赖,然后,这个方案是否可以尝试着做一下的必要。:smile: @EvenLjj E @seeflood 至于说用组合注解的方式的话,和 Spring 绑定的太深了。 |
@Darian1996 你的方案应该就是倾向于 @Kunple-w 上面所讲到的方案二,扫描注解已经在 |
扫描注解没有是前提@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
Arrays.stream(beanFactory.getBeanDefinitionNames())
.collect(Collectors.toMap(Function.identity(), beanFactory::getBeanDefinition))
.forEach((key, value) -> transformSofaBeanDefinition(key, value, beanFactory));
} 这里是通过 private void transformSofaBeanDefinition(String beanId, BeanDefinition beanDefinition,
ConfigurableListableBeanFactory beanFactory) {
if (BeanDefinitionUtil.isFromConfigurationSource(beanDefinition)) {
generateSofaServiceDefinitionOnMethod(beanId, (AnnotatedBeanDefinition) beanDefinition,
beanFactory);
} else {
Class<?> beanClassType = BeanDefinitionUtil.resolveBeanClassType(beanDefinition);
if (beanClassType == null) {
SofaLogger.warn("Bean class type cant be resolved from bean of {}", beanId);
return;
}
generateSofaServiceDefinitionOnClass(beanId, beanClassType, beanDefinition, beanFactory);
}
} 所以,是没有缺失了先扫描
旧方法以前的方法 新方式扫描 直到这个,才能到我的提出的需要扫描 包的方案,继续往下讨论。 所以,前提是去掉
|
直接给SofaService类加上 |
学习了,没必要搞扫描那些,太复杂了 |
这只是实现的方式,前提是,想不想把 Sofa 和 Spring 绑定在一起 |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Is there any update to this issue? |
I walked through the SOFABoot quick start guides and have some suggestions.
1. It's not always easy to change the parent pom, so it's better to document an alternative way, e.g. import the
sofaboot-dependencies
in dependencyManagement2. XML configuration is not widely used now, we'd better update the quick start documents using annotation examples
3. The annotation should be more user friendly
Take the example below:
@SofaService
is annotated, the@Component
should not be necessaryinterfaceType
is not mandatory, our sample could remove it4. Registry instructions should be added in the quick start doc
Currently there is no such instruction, so the user could not run the demo following the quick start doc from scratch.
The text was updated successfully, but these errors were encountered: