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.