bineanzhou / google-guice

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

Compile-time Guice #188

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
For GWT, Android and other environments where reflection is unavailable or 
inefficient, we should 
create another implementation of Guice.createInjector() that uses compile-time 
code generation 
rather than runtime reflection.

Original issue reported on code.google.com by limpbizkit on 14 Apr 2008 at 5:54

GoogleCodeExporter commented 9 years ago
I've been thinking about this for a while and I don't think it would be 
exceptionally
hard. Salve (http://code.google.com/p/salve/) seems to do similar things (at the
bytecode level) and there are open source libraries that provide a Java API to
manipulate Java source code at the AST level or higher. Eclipse JDT core is the 
one I
found (http://tinyurl.com/ynxlde), there might be others. Hmm...

Original comment by robbie.v...@gmail.com on 14 Apr 2008 at 7:42

GoogleCodeExporter commented 9 years ago
In the case of GWT, it should be easier then reading the compiled
bytecode/Javascript. You could use GWT Generators to do the dependency 
injection at
compile time. I'd guess the Generator would do type-tightening during 
compilation to
create Javascript that already has the types that were suppose to be injected 
during
runtime with reflections.

There's a ticket open on the GWT end as well
(http://code.google.com/p/google-web-toolkit/issues/detail?id=1250). A light 
weight
DI framework in GWT is needed badly. If I have some spare time I'll try and 
take a
look at how this might be done. Thank you!

Original comment by arthur.k...@gmail.com on 22 Jul 2008 at 2:17

GoogleCodeExporter commented 9 years ago
I am working on a GWT Guice prototype as we speak. I already have something 
working
(using generators) that does constructor injection for concrete types and 
regular,
annotated (unscoped) bindings.

Currently I'm not sharing any code with Guice, I just duplicated some 
interfaces and
annotations, everything else is custom. I still have to coordinate with Jesse 
on what
the eventual approach will be. He has also prototypes some non-GWT specific 
code that
I should look at.

It would be good to be able to share quite a bit of code with Guice, but on the 
other
hand it could also be useful, and maybe even needed, to use different code for 
other
parts and maybe even remove/add features.

Original comment by robbie.v...@gmail.com on 22 Jul 2008 at 2:25

GoogleCodeExporter commented 9 years ago
Wow, sounds great! I'd love to test it or help out if possible.

Original comment by arthur.k...@gmail.com on 22 Jul 2008 at 3:14

GoogleCodeExporter commented 9 years ago
For those watching the issue, it seems the project has been started already:
http://code.google.com/p/google-gin/

Original comment by arthur.k...@gmail.com on 4 Oct 2008 at 8:48

GoogleCodeExporter commented 9 years ago
We're abandoning this line of development in favor of GIN. Also, issue 268 
addresses Android.

Original comment by limpbizkit on 2 Nov 2008 at 8:43