Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Comment on UntargettedBindings in google-guice

Received: by 10.150.131.1 with SMTP id e1mr4670185ybd.8.1280337199661;
        Wed, 28 Jul 2010 10:13:19 -0700 (PDT)
X-BeenThere: google-guice-dev@googlegroups.com
Received: by 10.150.69.26 with SMTP id r26ls1903478yba.5.p; Wed, 28 Jul 2010 
	10:13:19 -0700 (PDT)
Received: by 10.151.62.9 with SMTP id p9mr7358959ybk.13.1280337199056;
        Wed, 28 Jul 2010 10:13:19 -0700 (PDT)
Received: by 10.151.62.9 with SMTP id p9mr7358958ybk.13.1280337199031;
        Wed, 28 Jul 2010 10:13:19 -0700 (PDT)
Return-Path: <3LmVQTAwOADASaaSXQ-SgUOQSaaSXQOaPQ....@codesite.bounces.google.com>
Received: from mail-gx0-f204.google.com (mail-gx0-f204.google.com [209.85.161.204])
        by gmr-mx.google.com with ESMTP id d3si6636475ybi.13.2010.07.28.10.13.18;
        Wed, 28 Jul 2010 10:13:19 -0700 (PDT)
Received-SPF: pass (google.com: domain of 3LmVQTAwOADASaaSXQ-SgUOQSaaSXQOaPQ....@codesite.bounces.google.com designates 209.85.161.204 as permitted sender) client-ip=209.85.161.204;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of 3LmVQTAwOADASaaSXQ-SgUOQSaaSXQOaPQ....@codesite.bounces.google.com designates 209.85.161.204 as permitted sender) smtp.mail=3LmVQTAwOADASaaSXQ-SgUOQSaaSXQOaPQ....@codesite.bounces.google.com
Received: by gxk26 with SMTP id 26so70378gxk.1
        for <google-guice-dev@googlegroups.com>; Wed, 28 Jul 2010 10:13:18 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.100.47.17 with SMTP id u17mr6928822anu.10.1280337198733; Wed, 
	28 Jul 2010 10:13:18 -0700 (PDT)
Reply-To: codesite-nore...@google.com
X-Generated-By: Google Code
X-GoogleCode-Project: google-guice
References: <1-1492727805935382846-122822679381629377-google-guice=googlecode.com@googlecode.com> 
	<0-1492727805935382846-122822679381629377-google-guice=googlecode.com@googlecode.com>
In-Reply-To: <1-1492727805935382846-122822679381629377-google-guice=googlecode.com@googlecode.com>
Message-ID: <2-1492727805935382846-122822679381629377-google-guice=googlecode.com@googlecode.com>
Date: Wed, 28 Jul 2010 17:13:18 +0000
Subject: Re: Comment on UntargettedBindings in google-guice
From: google-gu...@googlecode.com
To: google-guice-dev@googlegroups.com
Content-Type: text/plain; charset=ISO-8859-1; format=flowed; delsp=yes

Comment by drew.mclaughlin:

No.

An untargetted binding simply tells the injector that whenever an instance  
of MyConcreteClass is requested it should create one and inject it. Whereas  
the provides method tells the injector that this method should be invoked  
whenever an instance of MyConcreteClass is requested and use the returned  
value to inject.

The key difference is that the instance will be created by Guice in one  
case and by your code in the other. There are a few things that will only  
work for instance created by Guice - AOP method interception being the main  
one.

In general I'd recommend that you only use provider methods when you've got  
non-trivial logic required to create the instance. Usually this means that  
you'll have a non-zero number of parameters to the provider method that  
you'd use to create the instance.


For more information:
http://code.google.com/p/google-guice/wiki/UntargettedBindings