Re: Feature request: allow annotation meta in provider method

2015-10-25 Thread Tim Peierls
ider) { img = imgProvider.get(IMG_NAME); } } Then a static analysis tool could go through a jar and know from which things need to be "preconfigured", whatever that means. On Sunday, October 18, 2015 at 7:30:06 AM UTC-7, Tim Peierls wrote: >> >> What benefits would this ha

Re: Feature request: allow annotation meta in provider method

2015-10-18 Thread Tim Peierls
What benefits would this have over what I imagine your colleagues are doing? public interface ResourceEnvironment { Image getImage(String name); // ... other resource-providing methods ... } public class SomeService { private final Image image; @Inject public

Re: The never-ending beta of Guice 4

2015-04-28 Thread Tim Peierls
Whoa! On Apr 28, 2015 6:33 PM, Ben McCann b...@benmccann.com wrote: Woohoo! Thank you guys so much!!! On Tue, Apr 28, 2015 at 3:29 PM, 'Colin Decker' via google-guice google-guice@googlegroups.com wrote: Hey all, you'll be happy to know that Guice 4.0 is at long last released!

Re: Using thread local to determine who is calling a component?

2014-10-25 Thread Tim Peierls
It's easy to go overboard with custom scopes, but sometimes they're just what you need. Check out Tim Boudreau's custom scopes framework. https://github.com/timboudreau/scopes --tim On Fri, Oct 24, 2014 at 11:26 PM, Kevin Burton burtona...@gmail.com wrote: I have a complex stats system to

Re: @Provides, Providers (and singleton objects vs factories)...

2014-10-17 Thread Tim Peierls
On Thu, Oct 16, 2014 at 7:19 PM, Kevin Burton burtona...@gmail.com wrote: I humbly propose that these concepts are rather confusing in Guice @Provides vs Providers They both use similar mechanisms... IE providing the value of an object, but they do it differently and the semantics are

Re: Java 8 Type Annotations and Guice

2014-04-08 Thread Tim Peierls
On Mon, Apr 7, 2014 at 5:47 PM, Sam Berlin sber...@gmail.com wrote: I'd be open to any of the following: a) Hard-error on a qualifer/bindingannotation on types b) Support qualifer/bindingannotation on types, but fail if it also exists on the variable Though, since this'd be a change to

Re: Configuration Contribution How?

2013-12-19 Thread Tim Peierls
If you can abstract the kinds of configuring that you need to do as configuration elements, you can use Multibinder. In modules that contribute to the configuration (e.g., your ModuleA and ModuleB): Multibinder.newSetBinder(binder(), ConfigurationElement.class)

Re: Open Question / Poll: Guava dependency and Java5 minimum requirement.

2013-12-09 Thread Tim Peierls
On Mon, Dec 9, 2013 at 10:32 AM, Sam Berlin sber...@gmail.com wrote: 1) Do you want Guice to embed Guava or to make it a real dependency? Real dep. 2) Is it OK for Guice to bump its minimum requirements up to Java6? Yes, it's OK. --tim -- You received this message because you are

Re: Discussion: Some questions and concerns about Dependency Injection

2013-11-24 Thread Tim Peierls
On Sun, Nov 24, 2013 at 1:24 PM, Cédric Beust ♔ ced...@beust.com wrote: I would be totally on board with constructor injection if finalguaranteed structural immutability, but all it does is guarantee reference immutability (“this field is only assigned once”), ... That's *not* all it does.

Re: Discussion: Some questions and concerns about Dependency Injection

2013-11-24 Thread Tim Peierls
On Sun, Nov 24, 2013 at 2:20 PM, Cédric Beust ♔ ced...@beust.com wrote: On Sun, Nov 24, 2013 at 10:57 AM, Tim Peierls t...@peierls.net wrote: On Sun, Nov 24, 2013 at 1:24 PM, Cédric Beust ♔ ced...@beust.com wrote: I would be totally on board with constructor injection if finalguaranteed

Re: Discussion: Some questions and concerns about Dependency Injection

2013-11-24 Thread Tim Peierls
On Sun, Nov 24, 2013 at 4:06 PM, Cédric Beust ♔ ced...@beust.com wrote: Let's be concrete: can you write a program that gets initialized correctly with constructor injection and incorrectly with field injection? I've tried to come up with one with various techniques (misusing volatile,

Re: Discussion: Some questions and concerns about Dependency Injection

2013-11-24 Thread Tim Peierls
What I'm hearing in this exchange is akin to: I do this all the time, and I've never had a problem, so you shouldn't worry about doing it, either. That's a dangerous attitude to take with anything in general and with concurrency in particular. Even if you could show that no current JVM for x86

Re: a binding to @Named(xxx) was already configured at Rocoto.configure

2013-04-30 Thread Tim Peierls
On Tue, Apr 30, 2013 at 12:24 PM, Charles huang@gmail.com wrote: I tried to assign an environment variable to a property i.e. xxx.xxx.db.username = ${env.USERNAME} and got the error a binding to @Named(xxx) was already configured at Rocoto.configure Whenever I've seen the a binding to

Re: Help with the basics - Injecting field in a new class

2013-04-11 Thread Tim Peierls
Are you talking about com.google.inject.Provider or javax.inject.Provider or both? Calling javax.inject.Provider an internal type seems a bit harsh. --tim On Thu, Apr 11, 2013 at 3:06 AM, Christian Gruber cgru...@google.comwrote: It is easier, but please don't. While the two are practically

Re: Guice and constructors-as-function-objects

2013-04-08 Thread Tim Peierls
On Mon, Apr 8, 2013 at 7:18 AM, Tim Boudreau niftin...@gmail.com wrote: I just moved a framework for working with Netty, which relies on Guice very heavily, to GitHub. It's called Acteur. It has a somewhat unusual programming model, as it's more-or-less functional programming in Java, using

Re: Injecting field value before @BeforeSuite of testNG executes.

2013-01-08 Thread Tim Peierls
Right, but the question was whether there is way to inject before @BeforeSuite, and that's a TestNG question. --tim On Tue, Jan 8, 2013 at 12:10 PM, Cédric Beust ♔ ced...@beust.com wrote: TestNG supports Guice: http://beust.com/weblog/2010/12/10/testng-and-guice-a-marriage-made-in-heaven/

Re: How could I manage Lifecycle control ?

2012-12-12 Thread Tim Peierls
At least they aren't guilty of the sin of Onami! :-) On Wed, Dec 12, 2012 at 2:31 PM, Cédric Beust ♔ ced...@beust.com wrote: The Onami maintainers might want to rephrase this section: [image: Inline image 1] :-) (+cc Simone) -- Cédric On Wed, Dec 12, 2012 at 12:59 AM, Michael

Re: Determine an Injected Instance @Named Value

2012-07-24 Thread Tim Peierls
On Tue, Jul 24, 2012 at 2:44 PM, MarvinToll.com marvint...@gtcgroup.comwrote: The Rocoto example enables access to a property value via @Inject as follows: public final class JdbcConfiguration { @Inject @Named( JDBC.url ) private String jdbcUrl; //

Re: Determine an Injected Instance @Named Value

2012-07-24 Thread Tim Peierls
I'm still a little lost, but I think you should probably either be looking at AssistedInject or MapBinder. I agree with Craig McClanahan that @Named is probably not the right construct. It's just a way to create a distinct qualifier that you can use at the binding site and at the injection site.

Re: Lazy init of access objects for run-once computations

2012-07-23 Thread Tim Peierls
On Mon, Jul 23, 2012 at 12:25 PM, Leigh Klotz, Jr. leigh.kl...@gmail.com wrote: @LazySingleton @Provides CachedThings cachedThings(DB db) { MapString, String cache = readCache(db); return new CachedThings(cache); } This last seems like the nicest approach because

Re: Lazy init of access objects for run-once computations

2012-07-20 Thread Tim Peierls
I didn't know about a Guice prohibition on doing things in constructors, unless it was to avoid problems with circular dependencies. (So don't have circular dependencies!) I don't see a problem with Proposals A or D. I have yet to see it documented this way, but the Guice folks have assured me

Re: binding date using properties

2012-01-31 Thread Tim Peierls
I recommend using Rocoto, too, but here's an example that shows how to do it yourself, expressed as a JUnit test: http://pastebin.com/mWx9xG4M --tim On Tue, Jan 31, 2012 at 10:10 AM, Stuart McCulloch mccu...@gmail.comwrote: On 31 Jan 2012, at 14:42, egolan wrote: Hi, I am using

Re: problem on using injections within GuiceServletContextListener.contextInitialized

2012-01-23 Thread Tim Peierls
On Mon, Jan 23, 2012 at 6:35 AM, ich du tantea...@hotmail.com wrote: i try to sort up the deployment of my webapp. so i need to override contextInitilaized in GuiceServletContextListener. there i need to check the state of some module-bound objects. but i get problems: i field-injected the

Re: Multiple childinjectors and private modules

2011-10-20 Thread Tim Peierls
Sam, This is great. It should become part of the documentation, color-coding and all. --tim On Thu, Oct 20, 2011 at 11:26 AM, Sam Berlin sber...@gmail.com wrote: Do you have a concrete example of a few bindings and how you want them organized? I'm having trouble understanding what you're

Re: Eager initialization of singleton in a separate thread

2011-10-16 Thread Tim Peierls
http://tembrel.blogspot.com/2009/11/concurrently-initialized-singletons-in.html On Sun, Oct 16, 2011 at 10:04 AM, Noel noel@gmail.com wrote: I would like to do eager initialization of multiple singletons but the initialization can take on the order of minutes so I would like the

Re: Eager initialization of singleton in a separate thread

2011-10-16 Thread Tim Peierls
On Sun, Oct 16, 2011 at 5:08 PM, Noel Yap noel@gmail.com wrote: This looks really good! Can it work with Providers? I don't know what you mean. It works just like any other scope annotation. And what about diamond dependencies (ie what happens if both A and B depend upon C)? As long

Re: Guice + Swing + SwingWorker + background threads

2011-06-27 Thread Tim Peierls
On Fri, Jun 24, 2011 at 3:03 AM, Aekold helbr...@gmail.com wrote: SwingWorker is supposed to be constructed in EDT too, Really? I can't find anything that supports that, and a sentence in the javadochttp://download.oracle.com/javase/6/docs/api/javax/swing/SwingWorker.html, Often, the Current

Scope, ScopeAnnotation naming

2011-05-18 Thread Tim Peierls
Has anyone else been bitten by the fact that javax.inject.Scope is like com.google.inject.ScopeAnnotation and not like com.google.inject.Scope? Who serves on these so-called Expert Groups, anyway? :-) --tim -- You received this message because you are subscribed to the Google Groups

Re: Google Guice 3.0 Release

2010-11-10 Thread Tim Peierls
On Wed, Nov 10, 2010 at 1:17 PM, Sam Berlin sber...@gmail.com wrote: The more people who use the guice3 snapshot report back how it worked for them (either good or bad), the sooner a release will come. I was delighted to discover that a library that I want to use (jclouds) that previously

Re: OutOfScopeException injecting RequestScoped object manually inside a thread

2010-09-07 Thread Tim Peierls
How about removing the @Inject annotation from the B field of C and adding c.b = b after the injectMembers call? --tim On Tue, Sep 7, 2010 at 5:17 PM, Mauricio gmauricio.mu...@gmail.com wrote: I'm using Guice on a restful web service. I'm binding some object instances as RequestScoped. One of

Re: Mixing Guice and Swing

2010-08-07 Thread Tim Peierls
Guice guarantees that a *happens-before* edge exists between injection actions that arise as the result of a call to Injector.getInstance and actions in the thread following that call in program order, so if you only call getInstance in the EDT when injecting Swing components it doesn't matter

Re: Slow start up with ~500 bindings.

2010-08-01 Thread Tim Peierls
If you can decompose the expensive start-up operations into a set of independent (or weakly interdependent) singleton services, you can inject those services concurrently (in spite of the single-threadedness of injector creation). I wrote a blog entry about this:

Re: Initializing expensive resources in parallel?

2009-11-27 Thread Tim Peierls
I decided this was worth blogging about: http://tembrel.blogspot.com/2009/11/concurrently-initialized-singletons-in.html --tim On Nov 26, 11:36 pm, Tim Peierls tpeie...@gmail.com wrote: William, It bothered me to be so close to a solution and not get it, so I tried again, and this time I

Re: Initializing expensive resources in parallel?

2009-11-26 Thread Tim Peierls
try the experimental lifecycle module which takes an executor and calls a bunch of services in parallel. Tim Peierls wrote: [...] I don't see how you would deal with interdependencies between Startables, and it seemed like that was the main issue you were hoping Guice could quasi-magically

Re: Initializing expensive resources in parallel?

2009-11-23 Thread Tim Peierls
On Nov 20, 11:24 am, William Pietri will...@scissor.com wrote: Do you have an opinion on Jesse's proposed solution, the one involving Guava? I don't yet know enough about Guice's internals to know whether your discovery means that his approach would also founder on the same rocks you

Re: Initializing expensive resources in parallel?

2009-11-19 Thread Tim Peierls
to proceed. --tim On Nov 19, 11:48 pm, Tim Peierls tpeie...@gmail.com wrote: I've sketched an approach here that might work for you:http://pastie.org/707072 The idea is that ConcurrentSingletonScope, when the injector is created, eagerly starts computing in background the instances

Re: Guice 2.0 + DWR

2009-10-29 Thread Tim Peierls
the things you'd do different this time? I might take a stab at some of them... On Oct 28, 4:21 am, Tim Peierls tpeie...@gmail.com wrote: I don't have time to do it, and I don't think anyone else is working on it ... go for it! (I gave up when it wasn't a simple recompile

Re: Guice 2.0 + DWR

2009-10-28 Thread Tim Peierls
I don't have time to do it, and I don't think anyone else is working on it ... go for it! (I gave up when it wasn't a simple recompile.) There are a number of things I would do differently given the new features of Guice 2.0, but maybe a minimal patch that works is the best thing for now. --tim

Re: Guice Emacs Hacks

2009-08-26 Thread Tim Peierls
Pass. I'm waiting for the Guice vi hacks. :-) :-) --tim On Aug 25, 2:16 pm, Leigh Klotz leigh.kl...@gmail.com wrote: I've started collecting some Guice Emacs hacks. Here's one, M-x guice-inject-dependency   Position point inside constructor arglist   Pick your class name or generic type

Re: Request Scope when using child threads and cached executors

2009-08-05 Thread Tim Peierls
On Aug 3, 9:16 pm, Paul Lindner lind...@inuus.com wrote: I've been looking into Reqest Scopes and GuiceFilter and noticed that it uses a ThreadLocal to store the request state.  This works fine for single threaded request/response model.  However if an application uses a cached thread pool or

Re: @Singleton indicates that the class is intended to be threadsafe

2009-04-27 Thread Tim Peierls
That makes it sound like a particular deficiency of Java, but it's a concern in any language/environment where thread-safety is the responsibility of the programmer. If multiple threads access a mutable object, either the object is thread-safe or the code is broken. If you can arrange for access

Re: Servlet injection before init() in Guice 2 prerelease snapshot 20090205

2009-03-07 Thread Tim Peierls
On Mar 5, 8:14 pm, Dhanji R. Prasanna dha...@gmail.com wrote: - It makes it difficult for me to get the Injector for use by Tim Peierls' Restlet integration Hmm, I'll ask Tim if I can update his restlet thing for GS2. He will be loads happier to use ctor injection I am sure! (Tim