是否可以使用Guice限制类型层次扫描? [英] Is it possible to limit type hierarchy scanning with Guice?

查看:157
本文介绍了是否可以使用Guice限制类型层次扫描?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用Google的Guice注入器在扫描类以查找其依赖项时限制继承深度时,有什么办法吗?

Is there any way, when using Google's Guice injector to limit inheritance depth when scanning a class to find its dependencies ?

我的意思是,如果你定义一个A类喜欢

I mean, if you define a class A like

class A extends X {
 @Inject
 private B a;
}

我得到了类继承:A - > X - > Y - - > Z

And I got class inheritance : A --> X --> Y --> Z

我只想要扫描A和X,而不是Y和Z等上层类。我很确定两个类都不能注入任何字段。

I just want A to be scanned, and X, but not upper classes like Y and Z. I am pretty certain no fields can be injected in neither classes.

我的目标是提升启动阶段。

My goal is to boost startup phase.

这可能吗?

推荐答案

RoboGuice团队正在这个领域积极开展工作。对于那些感兴趣的人,RG 3.0将包含一个基于这种技术的guice。

The RoboGuice team is actively working in this area. For those who are interested, RG 3.0 will include a fork of guice based on this technique.

此处有更多详情: https://speakerdeck.com/stephanenicolas/blender-boosting-guice-with-annotation-processing

这篇关于是否可以使用Guice限制类型层次扫描?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆