New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Patch] custom annotation based injection points #258
Comments
From james.strachan on October 07, 2008 08:27:25 there's a discussion thread about this here : http://groups.google.com/group/google- guice/browse_thread/thread/649f1a24c62a2bae |
From latchkey on October 08, 2008 08:30:20 Wow James, I think it is a really smart idea. This kind of puts Guice at the root of everything. =) |
From james.strachan on October 08, 2008 08:39:08 LOL - all part of my evil plan, mwa-ha-ha-ha! :-) |
From anthony.muller on December 22, 2008 06:03:02 This patch is for Guice 2.x, right? |
From james.strachan on December 22, 2008 06:04:35 Yes |
From jose.illescas on February 06, 2009 06:32:29 Can I use this to redefine "Singleton" guice anotation as custom anotation"MySingleton"? |
From james.strachan on February 06, 2009 07:06:33 This patch only addresses using custom annotations as both a pointcut to inject new values into (e.g. to annotate Its not an attempt to allow custom annotations to replace other Guice annotations. |
From jose.illescas on February 09, 2009 10:25:59 Then, this patch allows "custom injects": Custom annotations to injects values It´s true? |
From james.strachan on February 10, 2009 02:26:28 Thats exactly right Jose. So you can create a Module which defines injection points It also opens up Guice to be a possible dependency injection engine within these I'm sure lots of frameworks would be happy to just reuse Guice as their preferred IoC |
From dhanji on February 10, 2009 06:31:43 Frameworks can already do this with Guice source code directly, if they wish. I'm not sure I see the benefits of As for servlets, Guice already injects components quite comprehensively, as of Guice Servlet 2.0 (see the wiki on Labels: -Type-Defect Type-Extension |
From james.strachan on February 10, 2009 07:03:10 Dhanji, so are you basically saying 'fork off' :). i.e. no way is Guice ever gonna try and be reusable with other frameworks - you're |
From limpbizkit on February 10, 2009 09:02:34 James, your work is fantastic. Keep it up, and I'm intending on taking it all in for consideration as soon as we With respect to supporting custom annotations, my complaint is that it introduces more indirection to Guice, I believe a lot of the motivation for custom annotations is people's distaste for importing 'com.google' |
From dhanji on February 10, 2009 13:58:14
What Jesse said =) There are loads of implications to supporting any annotation or no modules, and we want to provide the best ...Also I think Provider methods make it really easy to support and reuse other frameworks. And the new |
From jose.illescas on February 23, 2009 14:57:19 Limpbizkit, I hate APOJOs (Annotated POJOs) and Anotations of any owner: 'java(x).', I only likes MY custom anotations ( |
From gili.tzabari on February 23, 2009 16:05:49 I highly dislike Jose's request. I think the main point of this RFE is that we should So +1 for James' idea and -1 for Jose. Sorry. |
From stolsvik on February 23, 2009 16:34:04
|
From gili.tzabari on February 23, 2009 17:03:06 Stolsvik, The complaint about having "foreign" package names in your import list is what I find Who cares what the package name is? The vast majority of Java libraries out there are I don't want to come off as an ass, but this entire argument is highly subjective. I |
From stolsvik on February 23, 2009 17:28:20 Definitely highly subjective, I agree. What about this: You'd then be happy with I think there should be a java core (which should have the java package name). What is somewhat absurd here, is that there apparently already exists a patch that Limpbizkit says "[custom annotations] introduces more indirection to Guice, |
From gili.tzabari on February 23, 2009 17:49:01 "You'd then be happy with [...]"? String and URL are bad examples in that they are concrete classes but I get your Furthermore, nothing prevents Guice from implementing standard interfaces in the Look at what happened to Hibernate once JPA came out. You can still use the old |
From stolsvik on February 23, 2009 18:09:51 Regarding java.util.List vs. com.ibm.ArrayList: I agree, and I think that Regarding "no such standard exists today" - read top post. Regarding Hibernate vs. JPA etc: One may argue that one is there today, and that IMO, there is no argument about whether Guice is "intrusive". It is: One have to Annotating with standard annotations, or failing that, with project-specific |
From gili.tzabari on February 23, 2009 18:22:26 I was under the impression that |
From stolsvik on February 23, 2009 18:38:11 http://static.springframework.org/spring/docs/2.5.x/reference/new-in-2.html#new-in-2- ioc-annotations http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans- resource-annotation The semantics are slightly off, but these things are converging. Spring's annotation |
From limpbizkit on February 24, 2009 00:15:33 stolsvik, please embrace the fact that Java uses domain names in imports. You've also criticized the package |
From james.strachan on February 24, 2009 02:01:03 Gili - its a shame you think my comments are silly though I'm not exactly sure what FWIW my motivation for this patch was not because I dislike using com.google.* - its If you work solely inside your corporate firewall and don't have to share code with FWIW many other IoC containers have supported these annotations for years (e.g. For some reason supporting standards that people actually use seems kinda against the Its a shame as Guice was really close to being a contender as a really popular IoC |
From gili.tzabari on February 24, 2009 05:28:14 James, I'm sorry if I misunderstood your comments. I am all in favor of reusing standard |
From stolsvik on February 24, 2009 06:00:26
You are //completely// derailing the discussion, and of course you know it. I do not, in any way, want you to take away com.google from the system aspects of So DO NOT put completely baseless meanings into my mouth. I cannot comprehend why it is problematic for you Googlers to understand that not Spring does not force you to such measures, in any way, and never has - that was its From a bit more abstract view: One big point of the entire IoC stuff was that one |
From limpbizkit on February 24, 2009 09:49:19
Guiceyfruit is awesome and I hope you continue it. And I'm intending to review your patch as soon as we push I'm fairly skeptical of arguments that say "import javax." is good, but "import com." is bad, mostly because |
From gili.tzabari on February 24, 2009 10:13:18 Jesse, I think we've all misunderstood James' point. He doesn't object to the package names |
From jose.illescas on February 24, 2009 14:09:27
I loves Guice Interceptor, based on customs annotations allows me define: But, If I like to change quickly between guice/spring/other? (without lost amounts of note: custom = any Nobody can say: "I use *** framework in the future" |
From bslesinsky on February 24, 2009 19:04:29 It seems like there are two issues here:
Guice is both a (de-facto) standard and an implementation. If you're not using |
From james.strachan on February 25, 2009 01:15:17 To avoid lots of philosophical discussions (what is a standard etc) let me try to be I work on lots of application code which is used by lots of different teams in So my show stopper issue with ever adopting & recommending Guice is to be able to use It might not be the ideal solution - if you could dictate Guice everywhere on a Right now the only IoC container I'm aware of which refuses to allow such a heretical So my choice today is - forget all about Guice, carry on using Spring JavaConfig (no Hey good luck - Guice is a good piece of work and I wish it well. I hope at some |
From bileblog on February 25, 2009 05:02:13 I agree 100% with James' comments, but have far far less patience than he does. I'v jumped off the guice ship months ago, and whenever asked, I recommend that people avoid it. The reasoning is exactly the same as James'. The constant refusal to add support for annotations that are in use by everyone, require no new knowledge, that have become commonplace It's perplexing to me that after being assured a year or two ago that Guice will provide infrastructure to support these common annotations, the solution now has gone to 'sorry, we don't It's become abundantly clear that Guice's priorities are much the same as Google's priorities when it comes to open source that it uses in house, Google first, and if that happens to You keep wondering why people care, and the answer is simple. It's less to learn, it lowers the barrier to entry, and saves you a few extra seconds of thinking 'now how do I do the thing See, the community is perfectly happy for you to maintain your elitist selfish attitude to the codebase, and your refusal to add features that don't personally benefit you. It's the Guice |
From limpbizkit on February 25, 2009 09:11:15 I'm convinced. Sincere apologies for being ivory-tower with my previous arguments. I've certainly underestimated how I didn't fully understand the motivation behind this patch. I foolishly assumed people wanted to use Also, when I said "after 2.0" what I really meant was "immediately after 2.0". Adding new functionality like this Hani, we've done a lot of work to make Guice work better for the community outside of Google, and it makes Labels: -Priority-Medium Priority-High |
From james.strachan on February 25, 2009 10:06:19 Awesome! :) Many thanks! |
From bileblog on February 25, 2009 15:37:16 Well, that's a relief! I still though am grumpy about the lack of 2.0, it's just so much stuff promised, but very little delivered (that I I do hope you get 2.0 out before the boat has passed though, and will definitely revisit once some of these |
From dhanji on February 25, 2009 16:48:21 hooray, everyone is happy again. Also, let's not forget servlet support, which is for the community as much as it is for us internally. I think it's worth appreciating Jesse a little as he's worked extremely hard to make this happen. It may appear |
From mark.renouf on February 25, 2009 18:01:30
Kudos to everyone, google, contributors, and everyone here providing input. I'm glad |
From crazyboblee on February 25, 2009 22:24:05 James, you rock. We really appreciate the contributions. We won't let you down--we'll My single biggest regret about Guice 1 is that I didn't rename the package to "guice" I could go on about the tragedy in "Java standard" becoming synonymous with "JCP", |
From michael.neale on February 26, 2009 18:35:29 Smile on your brother everybody get together gotta love one another right now. |
From jose.illescas on February 27, 2009 03:58:03
It's necesary a Module "binding"? note: this allows me configure providers on my Module |
From james.strachan on April 03, 2009 02:47:33
e.g. using the GuiceyFruit library ( https://code.google.com/p/guiceyfruit/ ) using the current trunk of Guice you can do things like this... bindAnnotationInjector(Resource.class, ResourceMemberProvider.class); For more detail see the JSR 250 module: https://code.google.com/p/guiceyfruit/source/browse/trunk/guiceyfruit- core/src/main/java/org/guiceyfruit/jsr250/Jsr250Module.java |
From james.strachan on April 03, 2009 02:52:43 BTW we can mark this issue closed now IMHO! There's everything you need in Guice trunk now to implement any kind of custom injection strategy. e.g. here's an example of it in use http://tinyurl.com/ch8u4q https://code.google.com/p/guiceyfruit/source/browse/trunk/guiceyfruit- core/src/main/java/org/guiceyfruit/jsr250/Jsr250Module.java and here's how the code works (just a few simple helper methods on standard Guice) http://tinyurl.com/cp9q9g https://code.google.com/p/guiceyfruit/source/browse/trunk/guiceyfruit- core/src/main/java/org/guiceyfruit/support/GuiceyFruitModule.java |
From limpbizkit on April 03, 2009 17:47:01 James, thank you. Status: Fixed |
From christian.bourque on April 06, 2009 14:50:51 Will there be a 2.0-beta-6 release soon (including these patches)? Because the last snapshot is dated October 22, 2008! Thanks |
From james.strachan on April 06, 2009 15:47:26
There should be a 2.0-beta-6 release of guiceyfruit cut this week with Spring |
From christian.bourque on April 07, 2009 11:18:21
I was wondering because it seems there's no nightly builds available, the snapshot Thanks James! |
From james.strachan on April 14, 2009 03:55:00
|
From jose.illescas on May 06, 2009 06:50:37
Thank you |
From james.strachan on October 07, 2008 11:13:11
There are lots of standards and frameworks which define their own custom injection points.
Here's a few off the top of my head; I'm sure there's many more out there...
JSR 250 & EJB3 defines
@
Resouce for injecting objects from JNDIJPA defines
@
PersistenceContext for injecting JPA resources usually prebound to a transactioncontext etc
JAX-RS defines a number of them such as
@
PathParam,@
HeaderParam,@
Context etcWebBeans defines
@
InStripes defines
@
SpringBeanApache Camel defines
@
EndpointInject and@
ProducesThis patch makes it easy to implement these custom injection points in frameworks as follows;
this example supports
@
Resource from JSR 250{{{
@
InjectionAnnotation(Resource.class)public class ResourceProviderFactory<T> implements AnnotationProviderFactory<T> {
private final Context context;
@
Injectpublic ResourceProviderFactory(Context context) {
this.context = context;
}
public Provider<T> createProvider(AnnotatedElement member) {
Resource resource = member.getAnnotation(Resource.class);
Objects.nonNull(resource, "
@
Resource is missing!");String name = getJndiName(resource, member);
return new Provider<T>() {...}
}
}}}}
Rather than going into a long discussion in this issue, I'll bring it up on the mailing list and post
a link here shortly...
Note that this patch also includes these patches... https://code.google.com/p/google-guice/issues/detail?id=62 https://code.google.com/p/google-guice/issues/detail?id=78 given the amount of code I've changed for these 3 patches its been a bit tricky separating them
out into different patches.
Mostly this patch involves changes to InjectionPoint and InjectorImpl along with the new interface AnnotationProviderFactory and annotation InjectionAnnotation along with a new test case in the
jsr250 module called ResourceTest that tests out the injection of
@
Resource for field andmethod injection
Attachment: gist
custom_annotation_injections.patch
Original issue: http://code.google.com/p/google-guice/issues/detail?id=258
The text was updated successfully, but these errors were encountered: