This is pretty Badass.

One question - could you consider also licensing it under Apache 2.0 or something else the OSI has approved as an open-source license? WTFPL basically means we could never use it in Google, nor could Googlers contribute back to it, owing to its lack of warranty disclaimer and very vague rights grant.

That said, this is a pretty cool extension. Need to look into the performance implications of context sensitive provision, but I like it, conceptually.

c.

On 2 Apr 2014, at 12:18, Tavian Barnes wrote:

Sangria <http://tavianator.com/sangria/> is a project where I'll be
releasing some Guice extensions that I've written. Currently it provides context-sensitive injection, and through that, first-class (constructor)
injection of non-JUL loggers like SLF4J.

The API for context-sensitive injection looks like this:

*public* *interface* ContextSensitiveProvider<T> {
 T getInContext(InjectionPoint injectionPoint);
 T getInUnknownContext();
}

public class YourModule extends AbstractModule {
 @Override
 protected void configure() {
     ContextSensitiveBinder.create(binder())
             .bind(YourType.class)
             .toContextSensitiveProvider(YourProvider.class);
 }
}

The implementation is based on Noctarius's suggestion from an old thread
here to use a ProvisionListener together with a ThreadLocal.

I wrote a blog post about it here<http://tavianator.com/2014/04/announcing-sangria/>.
The code is released under the WTFPL <http://www.wtfpl.net/>, and is
available on GitHub <https://github.com/tavianator/sangria>. Feel free to
comment or send pull requests.

--
You received this message because you are subscribed to the Google Groups "google-guice" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/d/optout.


Christian Gruber :: Google, Inc. :: Java Core Libraries :: Dependency Injection
email: [email protected] :::: mobile: +1 (646) 807-9839

--
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/d/optout.

Reply via email to