vipx / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 0 forks source link

Marker annotations to enhance performance of InjectionPoint#getInjectionPoints() method #733

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'd like a way to mark certain classes as not needing injection (or at least 
not needing Field injection or Member injection) to save some time in the 
InjectionPoint#getInjectionPoints() method.

I would like to be able to annotate a class as follows:

@NoFieldInjection(lookInParents=false);
@NoMethodInjection(lookInParents=false);
class DoesntNeedInjection {

   @Inject
   public DoesntNeedInjection(SomeDependency dependency) {
   }
}

@NoFieldInjection(lookInParents = true);
@NoMethodInjection(lookInParents = true);
class DoesntNeedInjection2 extends SomeParentClass {
  //uses default constructor, and JIT binding
  //this class has no fields/methods but the parent class does
}

-------

My reasoning is that for systems (i.e. RoboGuice) injection start up time takes 
a non trivial amount of time and is done in the UI thread (separate issue, I 
know, but I'd like to get better performance anyways).  

With these marker attributes, we could save crawling the entire inheritance 
tree, which could be large if you are using some type of 3rd party library.

Original issue reported on code.google.com by rich...@winograd.ca on 11 Oct 2012 at 5:34

GoogleCodeExporter commented 9 years ago
Sorry that first class should probably be called: "DoesntNeedMemberInjection"

Original comment by rich...@winograd.ca on 11 Oct 2012 at 5:35