Re: Failing Guice builds

2013-10-15 Thread Tim Boudreau
On Monday, September 30, 2013 12:28:37 PM UTC-4, Christian Gruber wrote:

 This quarter I'm hoping to get several Google open-source java projects 
 onto an external continuous integration (of some variety, even if it's 
 just duck-taped) but the net effect is that I hope we will have Guice's 
 tests running on more than one JVM, and more than one platform.


Well, in the meantime I'm happy to provide this build of Guice on a Solaris 
variant: http://timboudreau.com/builds/job/Guice%203/

Any chance the tests will be fixed soon?  It's not the end of the world, 
but I don't really like seeing failing builds on my dashboard ;-)

-Tim

-- 
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 google-guice+unsubscr...@googlegroups.com.
To post to this group, send email to google-guice@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.


Re: creating instance using injector without passing module info again.

2013-10-15 Thread Tim Boudreau
On Tuesday, October 8, 2013 4:56:47 AM UTC-4, kumar santosh wrote:

 1. I have class AModule  where we are binding are the dependencies. 

 2.  In class Test i created Instance of B using Injector. like .
   Injector in = Guice.createInjector(new AModule())
 // getting instance of B  
  in.getInstance(B);

 3. I am in same jvm, In some other class D,  can i get instance of some 
 class C without again  calling Guice.createInjector(new AModule())


Two ways:
 - Create D using the injector, and have B injected into it (this is pretty 
much *the* thing Guice is good for)
 - Pass a reference to the injector from Test to D.

If there is no connection between B and D at all, maybe there is some code 
which instantiates both of them?  I hesitate to say put the injector into 
a static field since that's exactly the pattern Guice exists to eliminate, 
but if it's test code and there's really *no* other way, it would work. 
 But I'd say reconsider your design if that looks like the way you have to 
do it.

-Tim

-- 
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 google-guice+unsubscr...@googlegroups.com.
To post to this group, send email to google-guice@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.


Re: creating instance using injector without passing module info again.

2013-10-15 Thread Tim Boudreau
On Tuesday, October 8, 2013 12:01:40 PM UTC-4, Nate Bauernfeind wrote:

 I tend to avoid using Guice for most tests as I find it hard to actually 
 get decent tests when Guice is in the mix.

Interesting.  As the author of one Guice-based test framework, I'm curious 
what problems you run into.

For any specific class I want to treat I heavily make use of mockito, and 
 so to even use Guice I would create an override module with the mocks and 
 effectively ends up giving a false sense of security related to any Guice 
 code.

How is the sense of security you get from machine-generated mocks different 
from the sense of security you'd get from hand-written mocks? :-)

-Tim

-- 
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 google-guice+unsubscr...@googlegroups.com.
To post to this group, send email to google-guice@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Scopes.SINGLETON uses a global lock issue 183

2013-10-15 Thread Sam Berlin
What is it about production mode that makes you think it isn't necessary
(whereas it would be necessary with development mode)?

sam
On Oct 16, 2013 12:27 AM, Romain Gilles romain.gil...@gmail.com wrote:

 Hi all,
 I add a comment 
 #19https://code.google.com/p/google-guice/issues/detail?id=183#c19 on
 this issue since April. I would like to know if it's a stupid comment or
 not. In fact we fall in some case in a deadlock situation with the class
 level lock used by the Singleton scope. And I think in case of production
 stage the lock and event the volatile instance field are not required. For
 me only development mode require this kind of protection and we always
 create our Injector in production stage.
 Does it make sens for you?

 Here a code snippet of Singleton Scope (guice 3.0) :
   public static final Scope SINGLETON = new Scope() {
 public T ProviderT scope(final KeyT key, final ProviderT
 creator) {
   return new ProviderT() {
 /*
  * The lazily initialized singleton instance. Once set, this will
 either have type T or will
  * be equal to NULL.
  */
 private volatile Object instance;

 // DCL on a volatile is safe as of Java 5, which we obviously
 require.
 @SuppressWarnings(DoubleCheckedLocking)
 public T get() {
   if (instance == null) {
 /*
  * Use a pretty coarse lock. We don't want to run into
 deadlocks
  * when two threads try to load circularly-dependent objects.
  * Maybe one of these days we will identify independent graphs
 of
  * objects and offer to load them in parallel.
  *
  * This block is re-entrant for circular dependencies.
  */
 synchronized (InternalInjectorCreator.class) {
   if (instance == null) {
 T provided = creator.get();

 // don't remember proxies; these exist only to serve
 circular dependencies
 if (provided instanceof CircularDependencyProxy) {
   return provided;
 }

 Object providedOrSentinel = (provided == null) ? NULL :
 provided;
 if (instance != null  instance != providedOrSentinel) {
   throw new ProvisionException(
   Provider was reentrant while creating a singleton);
 }

 instance = providedOrSentinel;
   }
 }
   }

   Object localInstance = instance;
   // This is safe because instance has type T or is equal to NULL
   @SuppressWarnings(unchecked)
   T returnedInstance = (localInstance != NULL) ? (T) localInstance
 : null;
   return returnedInstance;
 }

 Regards,

 Romain.

 --
 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 google-guice+unsubscr...@googlegroups.com.
 To post to this group, send email to google-guice@googlegroups.com.
 Visit this group at http://groups.google.com/group/google-guice.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
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 google-guice+unsubscr...@googlegroups.com.
To post to this group, send email to google-guice@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.