Skip to content
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

add annotation for spring #101

Merged
merged 7 commits into from
Jul 20, 2016
Merged

add annotation for spring #101

merged 7 commits into from
Jul 20, 2016

Conversation

feilaoda
Copy link
Contributor

@feilaoda feilaoda commented Jun 1, 2016

增加ApiService和ApiReference注解,目前已经在自己项目中使用。
注解名可以商量一下这个命名是否合适。

@half-dead
Copy link
Collaborator

首先非常感谢您的参与!

代码中发现了几个小问题:
1,请补充JavaDoc风格的类及方法说明
2,System.out.println,请改为其他的日志记录方式或者去掉

@rayzhang0603
Copy link
Collaborator

非常感谢您为motan添加注解配置功能!
因为日志风格需要保持统一,请使用com.weibo.api.motan.util.LoggerUtil统一记录log。
另外,可以考虑一下能否支持protocol也可以注解配置

@feilaoda
Copy link
Contributor Author

feilaoda commented Jun 1, 2016

@half-dead @rayzhang0603
抱歉,忘删了。我再改改。

@beldon
Copy link

beldon commented Jun 3, 2016

或许你能写得更好点

@lordzoucl
Copy link

关于注解名可否考虑增加metaAnnotation,就是可以根据使用者需求调整注解名

@rayzhang0603
Copy link
Collaborator

hi, @feilaoda 我们希望的注解功能最好有如下特点:
1、注解中的属性名称、功能与xml方式的完全一致
2、能够仅通过注解方式配置服务,并且尽量能够支持所有的配置项
3、注解方式生成的bean可以被xml方式正常引用

目前代码中还有一些功能方面的问题,例如一些常用配置没有处理,例如service端的export、filter等,还有只能通过xml方式配置registry、protocol,对于简单的服务来说还不太方便,最好能支持完全注解配置
加载protocol等配置时,可以按照优先使用存在的bean,如果对应bean不存在时新建配置的方式进行处理。类似这样的配置:
@MotanService( id = "fooService",
interfaceName = "test.FooService",
...
serviceConfig = {@ConfigParam(key = "serviceParam1", value = "serviceValue1")},
protocolConfig = {@ConfigParam(key = "protocolParam1", value = "protocolValue1")},
registryConfig = {@ConfigParam(key = "registryParam1", value = "registryValue1")})

@feilaoda
Copy link
Contributor Author

@rayzhang0603 了解

@feilaoda
Copy link
Contributor Author

feilaoda commented Jun 24, 2016

现在可以用注解,也可以用xml定义service,引用service了,并且注解的bean也可以被xml引用
注解名称改成了MotanService和MotanReferer

@rayzhang0603
Copy link
Collaborator

@feilaoda 已经测试过了,非常棒!
还有2个小问题需要稍微处理一下,就可以了。
1、去掉无用的import声明。
2、AnnotationBean.class的throwException、shareChannel、protocol属性有重复处理(line422-439),需要删掉

另外有两个建议
1、springsupport模块新增类最好加上@author 声明
2、AnnotationBean、BasicRefererConfigBean、BasicServiceConfigBean类在处理protocol、registry时有很多类似代码,我觉得可以新建一个SpringBeanUtil工具类,专门处理这种获取多个bean的情况。
例如

public static <T> List<T> getMultiBeans(BeanFactory beanFactory, String names, String regex, Class<T> clazz){
    //TODO
    return null;
}

@feilaoda
Copy link
Contributor Author

@rayzhang0603 不好意思,刚看到。已经修改好了。

@rayzhang0603 rayzhang0603 merged commit fe71fd8 into weibocom:master Jul 20, 2016
@rayzhang0603
Copy link
Collaborator

非常感谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants