Frage

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

I mean, if you define a class A like

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

And I got class inheritance : 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.

Is that possible ?

War es hilfreich?

Lösung 2

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.

More details here : https://speakerdeck.com/stephanenicolas/blender-boosting-guice-with-annotation-processing

Andere Tipps

I don't think it's possible and I'd bet the gain would be negligible. Guice only need to scan the class hierarchy once in order to collect the injection points and the usually more time-consuming part is the injection itself.

The cost of the injection itself is independent of the class hierarchy, it rather depends on the number of objects to be processed and number of fields to be injected.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top