The annotation way just a common use case in Spring. I don't think it will
slow down your application startup processing too much.

You don't need to do the work yourself, Spring support it out of box.
we could add @Service  to specify the instance of HealthChecker.
We could use the @Autowire to inject the instance to registry without
changing anything.




Willem Jiang

Blog: http://willemjiang.blogspot.com (English)
          http://jnn.iteye.com  (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem

On Mon, Jan 8, 2018 at 3:15 PM, 郑扬勇 <yangyong.zh...@qq.com> wrote:

> Hi everyone:
>    Current we support user use "HealthCheckerManager.register(HealthChecker
> checker)" to register his own health checker,and I think we may make this
> registration more easier.
>    1. The first way is implement an Annotation like @Health,like this :
>
>               @Health
>               public class CustomHealthCheckerAnnotation implements
> HealthChecker {...}
>
>    This way don't need any more config,but the disadvantage is that we
> need scan all package find out those checkers like :
>
>               ClassPathScanningCandidateComponentProvider scanner = new
> ClassPathScanningCandidateComponentProvider(false);
>              scanner.addIncludeFilter(new AnnotationTypeFilter(Health.
> class));
>              for (BeanDefinition definition : 
> scanner.findCandidateComponents("./"))
> { ...}
>
>    this stage may slow.
>
>    2.The second way is use java SPI, use declare checkers in
> META-INF/services/xxx,It's more fast but need config.
>
>    Any suggestion is welcome!
>
>  Best Regards & Thanks!
>  zhengyangyong

Reply via email to