Revision: 1060
Author: limpbizkit
Date: Mon Aug 10 16:57:56 2009
Log: Including sources in providers wrapped for scoping. This fixes a  
problem reported by Isaac on bug 271.
http://code.google.com/p/google-guice/source/detail?r=1060

Modified:
  /trunk/src/com/google/inject/internal/BindingProcessor.java
  /trunk/src/com/google/inject/internal/ConstructorBindingImpl.java
  /trunk/src/com/google/inject/internal/InjectorImpl.java
  /trunk/src/com/google/inject/internal/InternalFactoryToProviderAdapter.java
  /trunk/src/com/google/inject/internal/Scoping.java
  /trunk/test/com/google/inject/NullableInjectionPointTest.java

=======================================
--- /trunk/src/com/google/inject/internal/BindingProcessor.java Sun Jun 21  
17:14:02 2009
+++ /trunk/src/com/google/inject/internal/BindingProcessor.java Mon Aug 10  
16:57:56 2009
@@ -104,7 +104,8 @@
          Initializable<T> ref = initializer.requestInjection(
              injector, instance, source, injectionPoints);
          ConstantFactory<? extends T> factory = new ConstantFactory<T>(ref);
-        InternalFactory<? extends T> scopedFactory = Scoping.scope(key,  
injector, factory, scoping);
+        InternalFactory<? extends T> scopedFactory
+            = Scoping.scope(key, injector, factory, source, scoping);
          putBinding(new InstanceBindingImpl<T>(injector, key, source,  
scopedFactory, injectionPoints,
              instance));
          return null;
@@ -116,7 +117,8 @@
          Initializable<Provider<? extends T>> initializable = initializer
              .<Provider<? extends T>>requestInjection(injector, provider,  
source, injectionPoints);
          InternalFactory<T> factory = new  
InternalFactoryToProviderAdapter<T>(initializable, source);
-        InternalFactory<? extends T> scopedFactory = Scoping.scope(key,  
injector, factory, scoping);
+        InternalFactory<? extends T> scopedFactory
+            = Scoping.scope(key, injector, factory, source, scoping);
          putBinding(new ProviderInstanceBindingImpl<T>(injector, key,  
source, scopedFactory, scoping,
              provider, injectionPoints));
          return null;
@@ -128,7 +130,7 @@
              = new BoundProviderFactory<T>(injector, providerKey, source);
          creationListeners.add(boundProviderFactory);
          InternalFactory<? extends T> scopedFactory = Scoping.scope(
-            key, injector, (InternalFactory<? extends T>)  
boundProviderFactory, scoping);
+            key, injector, (InternalFactory<? extends T>)  
boundProviderFactory, source, scoping);
          putBinding(new LinkedProviderBindingImpl<T>(
              injector, key, source, scopedFactory, scoping, providerKey));
          return null;
@@ -142,7 +144,8 @@

          FactoryProxy<T> factory = new FactoryProxy<T>(injector, key,  
linkedKey, source);
          creationListeners.add(factory);
-        InternalFactory<? extends T> scopedFactory = Scoping.scope(key,  
injector, factory, scoping);
+        InternalFactory<? extends T> scopedFactory
+            = Scoping.scope(key, injector, factory, source, scoping);
          putBinding(
              new LinkedBindingImpl<T>(injector, key, source, scopedFactory,  
scoping, linkedKey));
          return null;
=======================================
--- /trunk/src/com/google/inject/internal/ConstructorBindingImpl.java   Sun  
Jun 21 11:13:01 2009
+++ /trunk/src/com/google/inject/internal/ConstructorBindingImpl.java   Mon  
Aug 10 16:57:56 2009
@@ -102,7 +102,7 @@

      Factory<T> factoryFactory = new Factory<T>();
      InternalFactory<? extends T> scopedFactory
-        = Scoping.scope(key, injector, factoryFactory, scoping);
+        = Scoping.scope(key, injector, factoryFactory, source, scoping);

      return new ConstructorBindingImpl<T>(
          injector, key, source, scopedFactory, scoping, factoryFactory,  
constructorInjector);
=======================================
--- /trunk/src/com/google/inject/internal/InjectorImpl.java     Sat Jul 25  
19:01:55 2009
+++ /trunk/src/com/google/inject/internal/InjectorImpl.java     Mon Aug 10  
16:57:56 2009
@@ -495,11 +495,12 @@
        }
      };

+    Object source = rawType;
      return new LinkedProviderBindingImpl<T>(
          this,
          key,
-        rawType /* source */,
-        Scoping.<T>scope(key, this, internalFactory, scoping),
+        source,
+        Scoping.<T>scope(key, this, internalFactory, source, scoping),
          scoping,
          providerKey);
    }
@@ -536,11 +537,12 @@
        }
      };

+    Object source = rawType;
      return new LinkedBindingImpl<T>(
          this,
          key,
-        rawType /* source */,
-        Scoping.<T>scope(key, this, internalFactory, scoping),
+        source,
+        Scoping.<T>scope(key, this, internalFactory, source, scoping),
          scoping,
          targetKey);
    }
=======================================
---  
/trunk/src/com/google/inject/internal/InternalFactoryToProviderAdapter.java     
 
Sat Jun  6 10:51:27 2009
+++  
/trunk/src/com/google/inject/internal/InternalFactoryToProviderAdapter.java     
 
Mon Aug 10 16:57:56 2009
@@ -28,10 +28,6 @@
    private final Initializable<Provider<? extends T>> initializable;
    private final Object source;

-  public InternalFactoryToProviderAdapter(Initializable<Provider<? extends  
T>> initializable) {
-    this(initializable, SourceProvider.UNKNOWN_SOURCE);
-  }
-
    public InternalFactoryToProviderAdapter(
        Initializable<Provider<? extends T>> initializable, Object source) {
      this.initializable = checkNotNull(initializable, "provider");
=======================================
--- /trunk/src/com/google/inject/internal/Scoping.java  Sat Jun  6 10:51:27  
2009
+++ /trunk/src/com/google/inject/internal/Scoping.java  Mon Aug 10 16:57:56  
2009
@@ -211,7 +211,7 @@

    /** Scopes an internal factory. */
    static <T> InternalFactory<? extends T> scope(Key<T> key, InjectorImpl  
injector,
-      InternalFactory<? extends T> creator, Scoping scoping) {
+      InternalFactory<? extends T> creator, Object source, Scoping  
scoping) {

      if (scoping.isNoScope()) {
        return creator;
@@ -222,7 +222,7 @@
      Provider<T> scoped
          = scope.scope(key, new  
ProviderToInternalFactoryAdapter<T>(injector, creator));
      return new InternalFactoryToProviderAdapter<T>(
-        Initializables.<Provider<? extends T>>of(scoped));
+        Initializables.<Provider<? extends T>>of(scoped), source);
    }

    /**
=======================================
--- /trunk/test/com/google/inject/NullableInjectionPointTest.java       Fri Feb 
 
20 16:25:27 2009
+++ /trunk/test/com/google/inject/NullableInjectionPointTest.java       Mon Aug 
 
10 16:57:56 2009
@@ -156,8 +156,8 @@

      try {
        injector.getInstance(FooField.class);
-    }
-    catch(ProvisionException expected) {
+      fail();
+    } catch(ProvisionException expected) {
        assertContains(expected.getMessage(), "null returned by binding "
            + "at com.google.inject.NullableInjectionPointTest");
      }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to