dpolishuk / atinject

Automatically exported from code.google.com/p/atinject
0 stars 0 forks source link

Allow annotationless injection #4

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
IMHO, JSR 330 should support annotationless injection. The main reason is 
to to use DI in existing classes that we can't or don't want to change the 
source and recompile it. By the way, as far as I know, this was one of the 
main reasons to develop Spring.

Both Spring and Tapestry-IoC support this now, both using external 
configuration (XML or Java code). The T-IoC difference is that it sets 
some very well-defined rules for configurationless injection. They can be 
found in http://tapestry.apache.org/tapestry5.1/tapestry-ioc/
overview.html, section "Dependency Injection". This could be used as a 
starting point for JSR 330's annotationless injection.

Original issue reported on code.google.com by thiag...@gmail.com on 17 Jun 2009 at 12:46

GoogleCodeExporter commented 8 years ago
For what it's worth, Guice supports this also.
  http://code.google.com/p/google-guice/wiki/CustomInjections

Original comment by limpbizkit on 17 Jun 2009 at 7:45

GoogleCodeExporter commented 8 years ago
It does, but not in an automatic way. As the linked page states, you need to 
create 
a TypeListener and a MembersInjector. For example, I was talking about having 
dependencies injected automatically in DatabaseTransactionLog just by calling 
bind
(TransactionLog.class).to(DatabaseTransactionLog.class), not needing any 
additional 
code.

Original comment by thiag...@gmail.com on 17 Jun 2009 at 12:32

GoogleCodeExporter commented 8 years ago
Is a language for .bind(..).to(..) in this JSR ?

Original comment by PaulHamm...@gmail.com on 17 Jun 2009 at 1:29

GoogleCodeExporter commented 8 years ago
I guess so, as this JSR was expanded to have a configuration API.
From the JSR page:
"This JSR will standardize:

* A set of annotations for use on injectable classes
* A typesafe, user-friendly injector configuration API that provides an 
integration 
point for higher level dependency injection configuration approaches

Original comment by thiag...@gmail.com on 17 Jun 2009 at 6:50

GoogleCodeExporter commented 8 years ago
Something I'd not spotted in the draft. Thanks for pointing it out. 

Original comment by PaulHamm...@gmail.com on 17 Jun 2009 at 11:39

GoogleCodeExporter commented 8 years ago
This is probably fodder for part #2 of the spec, i.e not necessarily pertinent 
to the
annotations section, perhaps with the exception of the wording of @Inject which 
may 
have to ensure that it does not preclude annotationless injection ...

Original comment by Larry.Ca...@gmail.com on 24 Jun 2009 at 12:29

GoogleCodeExporter commented 8 years ago
I'm currently using Tapestry 5 and noticed, it's @Inject or other annotations 
are not yet JSR-330. Is there any progress on this issue?

Original comment by werner.k...@gmail.com on 19 Aug 2010 at 4:41

GoogleCodeExporter commented 8 years ago
There's a JIRA for that, but no work was done. Annotations are mostly used for 
injections in classes controlled by Tapestry (pages, components, mixins), not 
beans (services), which mostly use injection by constructor without annotations.

Original comment by thiag...@gmail.com on 19 Aug 2010 at 5:24