Author: limpbizkit
Date: Wed May 13 13:44:42 2009
New Revision: 945

Added:
    tags/snapshot20090512/
       - copied from r943, /trunk/
    tags/snapshot20090512/src/com/google/inject/commands/
    tags/snapshot20090512/src/com/google/inject/commands/intercepting/
     
tags/snapshot20090512/src/com/google/inject/commands/intercepting/InterceptingInjectorBuilder.java
     
tags/snapshot20090512/src/com/google/inject/commands/intercepting/ProvisionInterceptor.java
    tags/snapshot20090512/src/com/google/inject/internal/base/
     
tags/snapshot20090512/src/com/google/inject/internal/base/Preconditions.java
    tags/snapshot20090512/src/com/google/inject/internal/collect/
     
tags/snapshot20090512/src/com/google/inject/internal/collect/Iterables.java
    tags/snapshot20090512/src/com/google/inject/internal/collect/Lists.java
    tags/snapshot20090512/src/com/google/inject/internal/collect/Maps.java
    tags/snapshot20090512/src/com/google/inject/internal/collect/Sets.java
Modified:
    tags/snapshot20090512/guice.iml
    tags/snapshot20090512/guice.ipr
     
tags/snapshot20090512/servlet/src/com/google/inject/servlet/ManagedFilterPipeline.java
     
tags/snapshot20090512/servlet/src/com/google/inject/servlet/ManagedServletPipeline.java
    tags/snapshot20090512/src/com/google/inject/AbstractModule.java
    tags/snapshot20090512/src/com/google/inject/ConfigurationException.java
    tags/snapshot20090512/src/com/google/inject/ProvisionException.java
    tags/snapshot20090512/src/com/google/inject/internal/Errors.java
    tags/snapshot20090512/src/com/google/inject/internal/Iterables.java
    tags/snapshot20090512/src/com/google/inject/internal/Lists.java
    tags/snapshot20090512/src/com/google/inject/internal/Maps.java
    tags/snapshot20090512/src/com/google/inject/internal/Preconditions.java
    tags/snapshot20090512/src/com/google/inject/internal/Sets.java
     
tags/snapshot20090512/src/com/google/inject/spi/DefaultBindingTargetVisitor.java
     
tags/snapshot20090512/src/com/google/inject/spi/DefaultElementVisitor.java

Log:

Changes since 20090205

Pre-release API tidy-up. AbstractModule.requestInjection() no longer  
supports varargs, visitor methods have been renamed to visit(), and  
constructor bindings have new methods to expose their dependencies. In most  
cases, the snapshot leaves hook methods to ease migration.

Replace jarjar'd collections with a private copy. This shrinks our .jar  
size substantially. If you had a broken import to a  
com.google.inject.internal package, we've tried quite hard to fix these.  
Thanks to ilyaf for helping out here.

Support 0-arg parameterized types.

Support parameterized factories (ie. Factory<T>) for assisted inject.  
Thanks to ilyaf for this patch.

New APIs: MembersInjector and InjectionListeners. This is intended to ease  
integration between Guice and other frameworks.

Optimized injection with help from YourKit. Provider.get() is 50% faster!

Avoid wrapping servlet requests unnecessarily.

Make AOP optional in the Guice build. The AOP build is still the default,  
so this should have minimal impact.

Tweaking bytecode gen for AppEngine. Also updating to the latest MapMaker.




Modified: tags/snapshot20090512/guice.iml
==============================================================================
--- /trunk/guice.iml    (original)
+++ tags/snapshot20090512/guice.iml     Wed May 13 13:44:42 2009
@@ -1,5 +1,10 @@
  <?xml version="1.0" encoding="UTF-8"?>
  <module relativePaths="true" type="JAVA_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="Spring" name="Spring">
+      <configuration />
+    </facet>
+  </component>
    <component name="NewModuleRootManager" inherit-compiler-output="true">
      <exclude-output />
      <content url="file://$MODULE_DIR$">

Modified: tags/snapshot20090512/guice.ipr
==============================================================================
--- /trunk/guice.ipr    (original)
+++ tags/snapshot20090512/guice.ipr     Wed May 13 13:44:42 2009
@@ -11,6 +11,16 @@
        <properties />
      </buildFile>
    </component>
+  <component name="BlazePluginSettings" buildBeforeRefresh="true" />
+  <component name="Build editor project-level loader">
+    <settings>
+      <class-settings  
class="com.google.devtools.intellig.configcheck.ClearOutputChecker" />
+      <class-settings  
class="com.google.devtools.intellig.configcheck.JavacHeapChecker" />
+      <class-settings  
class="com.google.devtools.intellig.configcheck.ProjectJdkChecker" />
+      <class-settings  
class="com.google.devtools.intellig.configcheck.ProjectPathChecker" />
+      <class-settings  
class="com.google.devtools.intellig.configcheck.PythonSdkChecker" />
+    </settings>
+  </component>
    <component name="BuildJarProjectSettings">
      <option name="BUILD_JARS_ON_MAKE" value="false" />
    </component>
@@ -102,7 +112,25 @@
          <option name="VARIABLE_ANNOTATION_WRAP" value="1" />
          <option name="ENUM_CONSTANTS_WRAP" value="1" />
          <ADDITIONAL_INDENT_OPTIONS fileType="">
-          <option name="INDENT_SIZE" value="4" />
+          <option name="INDENT_SIZE" value="2" />
+          <option name="CONTINUATION_INDENT_SIZE" value="8" />
+          <option name="TAB_SIZE" value="4" />
+          <option name="USE_TAB_CHARACTER" value="false" />
+          <option name="SMART_TABS" value="false" />
+          <option name="LABEL_INDENT_SIZE" value="0" />
+          <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+        </ADDITIONAL_INDENT_OPTIONS>
+        <ADDITIONAL_INDENT_OPTIONS fileType="groovy">
+          <option name="INDENT_SIZE" value="2" />
+          <option name="CONTINUATION_INDENT_SIZE" value="8" />
+          <option name="TAB_SIZE" value="4" />
+          <option name="USE_TAB_CHARACTER" value="false" />
+          <option name="SMART_TABS" value="false" />
+          <option name="LABEL_INDENT_SIZE" value="0" />
+          <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+        </ADDITIONAL_INDENT_OPTIONS>
+        <ADDITIONAL_INDENT_OPTIONS fileType="gsp">
+          <option name="INDENT_SIZE" value="2" />
            <option name="CONTINUATION_INDENT_SIZE" value="8" />
            <option name="TAB_SIZE" value="4" />
            <option name="USE_TAB_CHARACTER" value="false" />
@@ -137,6 +165,24 @@
            <option name="LABEL_INDENT_SIZE" value="0" />
            <option name="LABEL_INDENT_ABSOLUTE" value="false" />
          </ADDITIONAL_INDENT_OPTIONS>
+        <ADDITIONAL_INDENT_OPTIONS fileType="sql">
+          <option name="INDENT_SIZE" value="2" />
+          <option name="CONTINUATION_INDENT_SIZE" value="8" />
+          <option name="TAB_SIZE" value="4" />
+          <option name="USE_TAB_CHARACTER" value="false" />
+          <option name="SMART_TABS" value="false" />
+          <option name="LABEL_INDENT_SIZE" value="0" />
+          <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+        </ADDITIONAL_INDENT_OPTIONS>
+        <ADDITIONAL_INDENT_OPTIONS fileType="txt">
+          <option name="INDENT_SIZE" value="2" />
+          <option name="CONTINUATION_INDENT_SIZE" value="8" />
+          <option name="TAB_SIZE" value="4" />
+          <option name="USE_TAB_CHARACTER" value="false" />
+          <option name="SMART_TABS" value="false" />
+          <option name="LABEL_INDENT_SIZE" value="0" />
+          <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+        </ADDITIONAL_INDENT_OPTIONS>
          <ADDITIONAL_INDENT_OPTIONS fileType="xml">
            <option name="INDENT_SIZE" value="4" />
            <option name="CONTINUATION_INDENT_SIZE" value="8" />
@@ -156,6 +202,11 @@
      <resourceExtensions />
      <wildcardResourcePatterns />
    </component>
+  <component name="ContinuousBuildConfigurationComponent">
+    <builds>
+      <build intervalToCheckBuild="1" buildKey="" buildLabel=""  
enabled="false" />
+    </builds>
+  </component>
    <component name="CopyrightManager" default="">
      <module2copyright />
    </component>
@@ -387,6 +438,7 @@
      <option name="FILTER_INFO" value="true" />
      <option name="CUSTOM_FILTER" />
    </component>
+  <component name="Mach LOCAL_PREFIX stripper" stripping="true" />
    <component name="Palette2">
      <group name="Swing">
        <item class="com.intellij.uiDesigner.HSpacer"  
tooltip-text="Horizontal Spacer"  
icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false"  
auto-create-binding="false" can-attach-label="false">
@@ -513,7 +565,7 @@
    </component>
    <component name="ProjectFileVersion" converted="true" />
    <component name="ProjectKey">
-    <option name="state"  
value="https://google-guice.googlecode.com/svn/trunk/guice.ipr"; />
+    <option name="state"  
value="https://google-guice.googlecode.com/svn/tags/snapshot20090512/guice.ipr"; 
 
/>
    </component>
    <component name="ProjectModuleManager">
      <modules>
@@ -528,7 +580,7 @@
        <module  
fileurl="file://$PROJECT_DIR$/extensions/throwingproviders/throwingproviders.iml"
  
filepath="$PROJECT_DIR$/extensions/throwingproviders/throwingproviders.iml"  
/>
      </modules>
    </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_5"  
assert-keyword="true" jdk-15="true" project-jdk-name="1.5"  
project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_5"  
assert-keyword="true" jdk-15="true" project-jdk-name="java version  
&quot;1.5.0_06&quot;" project-jdk-type="JavaSDK">
      <output url="file://$PROJECT_DIR$/classes" />
    </component>
    <component name="ResourceManagerContainer">

Modified:  
tags/snapshot20090512/servlet/src/com/google/inject/servlet/ManagedFilterPipeline.java
==============================================================================
--- /trunk/servlet/src/com/google/inject/servlet/ManagedFilterPipeline.java     
 
(original)
+++  
tags/snapshot20090512/servlet/src/com/google/inject/servlet/ManagedFilterPipeline.java
   
Wed May 13 13:44:42 2009
@@ -141,6 +141,13 @@

      HttpServletRequest request = (HttpServletRequest) servletRequest;

+    // don't wrap the request if there are no servlets mapped. This  
prevents us from inserting our
+    // wrapper unless it's actually going to be used. This is necessary  
for compatibility for apps
+    // that downcast their HttpServletRequests to a concrete  
implementation.
+    if (!servletPipeline.hasServletsMapped()) {
+      return servletRequest;
+    }
+
      //noinspection OverlyComplexAnonymousInnerClass
      return new HttpServletRequestWrapper(request) {


Modified:  
tags/snapshot20090512/servlet/src/com/google/inject/servlet/ManagedServletPipeline.java
==============================================================================
---  
/trunk/servlet/src/com/google/inject/servlet/ManagedServletPipeline.java        
 
(original)
+++  
tags/snapshot20090512/servlet/src/com/google/inject/servlet/ManagedServletPipeline.java
  
Wed May 13 13:44:42 2009
@@ -53,6 +53,10 @@
      this.servletDefinitions =  
Collections.unmodifiableList(collectServletDefinitions(injector));
    }

+  boolean hasServletsMapped() {
+    return !servletDefinitions.isEmpty();
+  }
+
    /**
     * Introspects the injector and collects all instances of bound {...@code  
List<ServletDefinition>}
     * into a master list.

Modified: tags/snapshot20090512/src/com/google/inject/AbstractModule.java
==============================================================================
--- /trunk/src/com/google/inject/AbstractModule.java    (original)
+++ tags/snapshot20090512/src/com/google/inject/AbstractModule.java     Wed May 
 
13 13:44:42 2009
@@ -149,6 +149,16 @@
    }

    /**
+   * @deprecated use multiple calls to {...@link #requestInjection}.
+   */
+  @Deprecated
+  protected void requestInjection(Object... objects) {
+    for (Object o : objects) {
+      requestInjection(o);
+    }
+  }
+
+  /**
     * @see Binder#requestStaticInjection(Class[])
     */
    protected void requestStaticInjection(Class<?>... types) {

Modified:  
tags/snapshot20090512/src/com/google/inject/ConfigurationException.java
==============================================================================
--- /trunk/src/com/google/inject/ConfigurationException.java    (original)
+++ tags/snapshot20090512/src/com/google/inject/ConfigurationException.java     
 
Wed May 13 13:44:42 2009
@@ -26,18 +26,17 @@
   * Thrown when a programming error such as a misplaced annotation, illegal  
binding, or unsupported
   * scope is found. Clients should catch this exception, log it, and stop  
execution.
   *
+ * <strong>Note:</strong> this class temporarily extends  
ProvisionException to ease migration.
   * @author [email protected] (Jesse Wilson)
   * @since 2.0
   */
-public final class ConfigurationException extends RuntimeException {
+public final class ConfigurationException extends ProvisionException {

-  private final ImmutableSet<Message> messages;
    private Object partialValue = null;

    /** Creates a ConfigurationException containing {...@code messages}. */
    public ConfigurationException(Iterable<Message> messages) {
-    this.messages = ImmutableSet.copyOf(messages);
-    initCause(Errors.getOnlyCause(this.messages));
+    super(messages);
    }

    /** Returns a copy of this configuration exception with the specified  
partial value. */

Modified:  
tags/snapshot20090512/src/com/google/inject/ProvisionException.java
==============================================================================
--- /trunk/src/com/google/inject/ProvisionException.java        (original)
+++ tags/snapshot20090512/src/com/google/inject/ProvisionException.java Wed  
May 13 13:44:42 2009
@@ -30,9 +30,9 @@
   * @author [email protected] (Jesse Wilson)
   * @since 2.0
   */
-public final class ProvisionException extends RuntimeException {
+public class ProvisionException extends RuntimeException {

-  private final ImmutableSet<Message> messages;
+  protected final ImmutableSet<Message> messages;

    /** Creates a ConfigurationException containing {...@code messages}. */
    public ProvisionException(Iterable<Message> messages) {

Added:  
tags/snapshot20090512/src/com/google/inject/commands/intercepting/InterceptingInjectorBuilder.java
==============================================================================
--- (empty file)
+++  
tags/snapshot20090512/src/com/google/inject/commands/intercepting/InterceptingInjectorBuilder.java
       
Wed May 13 13:44:42 2009
@@ -0,0 +1,221 @@
+/**
+ * Copyright (C) 2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.inject.commands.intercepting;
+
+import static com.google.inject.internal.Preconditions.checkArgument;
+import static com.google.inject.internal.Preconditions.checkNotNull;
+import com.google.inject.internal.Sets;
+import com.google.inject.AbstractModule;
+import com.google.inject.Binder;
+import com.google.inject.Binding;
+import com.google.inject.Guice;
+import com.google.inject.ImplementedBy;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+import com.google.inject.Module;
+import com.google.inject.ProvidedBy;
+import com.google.inject.Provider;
+import com.google.inject.TypeLiteral;
+import com.google.inject.binder.ScopedBindingBuilder;
+import com.google.inject.internal.UniqueAnnotations;
+import com.google.inject.name.Names;
+import com.google.inject.spi.DefaultBindingTargetVisitor;
+import com.google.inject.spi.Element;
+import com.google.inject.spi.Elements;
+import com.google.inject.spi.ModuleWriter;
+import com.google.inject.spi.UntargettedBinding;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @deprecated copy this class into your own project
+ *
+ * <p>Builds an {...@link Injector} that intercepts provision.
+ *
+ * <p>The injector contains an extra binding for {...@code Set<Key>} annotated
+ * with the name "Interceptable". This bound set contains all intercepted  
keys.
+ *
+ * <h3>Limitations of the current implementation</h3>
+ *
+ * <p>All intercepted bindings must have binding targets - for example, a  
type
+ * that is bound to itself cannot be intercepted:
+ * <pre class="code">bind(MyServiceClass.class);</pre>
+ *
+ * <p>All intercepted bindings must be bound explicitly. Interception  
cannot
+ * be applied to implicit bindings, or bindings that depend on
+ * {...@literal @}...@link ProvidedBy}, {...@literal @}...@link ImplementedBy}
+ * annotations.
+ *
+ * <p><strong>Implementation note:</strong> To intercept provision, an
+ * additional, internal binding is created for each intercepted key. This  
is
+ * used to bind the original (non-intercepted) provisioning strategy, and  
an
+ * intercepting binding is created for the original key. This shouldn't  
have
+ * any side-effects on the behaviour of the injector, but may confuse tools
+ * that depend on {...@link Injector#getBindings()} and similar methods.
+ *
+ * @author [email protected] (Jesse Wilson)
+ * @author [email protected] (Jerome Mourits)
+ */
+...@deprecated
+public final class InterceptingInjectorBuilder {
+
+  private static final Key<ProvisionInterceptor> INJECTION_INTERCEPTOR_KEY
+      = Key.get(ProvisionInterceptor.class);
+
+  private final Collection<Module> modules = new ArrayList<Module>();
+  private final Set<Key<?>> keysToIntercept = Sets.newHashSet();
+  private boolean tolerateUnmatchedInterceptions = false;
+
+  public InterceptingInjectorBuilder() {
+    // bind the keys to intercept
+    modules.add(new AbstractModule() {
+      protected void configure() {
+        bind(new TypeLiteral<Set<Key>>() {})
+            .annotatedWith(Names.named("Interceptable"))
+            .toInstance(Collections.<Key>unmodifiableSet(keysToIntercept));
+      }
+    });
+  }
+
+  public InterceptingInjectorBuilder install(Module... modules) {
+    this.modules.addAll(Arrays.asList(modules));
+    return this;
+  }
+
+  public InterceptingInjectorBuilder install(Collection<Module> modules) {
+    this.modules.addAll(modules);
+    return this;
+  }
+
+  public InterceptingInjectorBuilder intercept(Key<?>... keys) {
+    this.keysToIntercept.addAll(Arrays.asList(keys));
+    return this;
+  }
+
+  public InterceptingInjectorBuilder intercept(Collection<Key<?>> keys) {
+    checkArgument(!keys.contains(INJECTION_INTERCEPTOR_KEY),
+        "Cannot intercept the interceptor!");
+
+    keysToIntercept.addAll(keys);
+    return this;
+  }
+
+  public InterceptingInjectorBuilder intercept(Class<?>... classes) {
+    List<Key<?>> keysAsList = new ArrayList<Key<?>>(classes.length);
+    for (Class<?> clas : classes) {
+      keysAsList.add(Key.get(clas));
+    }
+
+    return intercept(keysAsList);
+  }
+
+  public InterceptingInjectorBuilder tolerateUnmatchedInterceptions() {
+    this.tolerateUnmatchedInterceptions = true;
+    return this;
+  }
+
+  public Injector build() {
+    // record commands from the modules
+    List<Element> elements = Elements.getElements(modules);
+
+    // rewrite the commands to insert interception
+    ModuleRewriter rewriter = new ModuleRewriter();
+    Module module = rewriter.create(elements);
+
+    // create and injector with the rewritten commands
+    Injector injector = Guice.createInjector(module);
+
+    // fail if any interceptions were missing
+    if (!tolerateUnmatchedInterceptions
+        && !rewriter.keysIntercepted.equals(keysToIntercept)) {
+      Set<Key<?>> keysNotIntercepted = Sets.newHashSet();
+      keysNotIntercepted.addAll(keysToIntercept);
+      keysNotIntercepted.removeAll(rewriter.keysIntercepted);
+      throw new IllegalArgumentException("An explicit binding is required  
for "
+          + "all intercepted keys, but was not found for " +  
keysNotIntercepted);
+    }
+
+    return injector;
+  }
+
+  /** Replays commands, inserting the InterceptingProvider where  
necessary. */
+  private class ModuleRewriter extends ModuleWriter {
+    private Set<Key<?>> keysIntercepted = Sets.newHashSet();
+
+    @Override public <T> void writeBind(Binder binder, Binding<T> binding)  
{
+      final Key<T> key = binding.getKey();
+
+      if (!keysToIntercept.contains(key)) {
+        super.writeBind(binder, binding);
+        return;
+      }
+
+      binding.acceptTargetVisitor(new DefaultBindingTargetVisitor<T,  
Void>() {
+        public Void visitUntargetted(UntargettedBinding<? extends T>  
untargettedBinding) {
+          throw new UnsupportedOperationException(
+              String.format("Cannot intercept bare binding of %s.", key));
+        }
+      });
+
+      Key<T> anonymousKey = Key.get(key.getTypeLiteral(),  
UniqueAnnotations.create());
+      binder.bind(key).toProvider(new InterceptingProvider<T>(key,  
anonymousKey));
+
+      ScopedBindingBuilder scopedBindingBuilder = bindKeyToTarget(binding,  
binder, anonymousKey);
+
+      // we scope the user's provider, not the interceptor. This is  
dangerous,
+      // but convenient. It means that although the user's provider will  
live
+      // in its proper scope, the intereptor gets invoked without a scope
+      applyScoping(binding, scopedBindingBuilder);
+
+      keysIntercepted.add(key);
+    }
+  }
+
+  /**
+   * Provide {...@code T}, with a hook for an {...@link ProvisionInterceptor}.
+   */
+  private static class InterceptingProvider<T> implements Provider<T> {
+    private final Key<T> key;
+    private final Key<T> anonymousKey;
+    private Provider<ProvisionInterceptor> injectionInterceptorProvider;
+    private Provider<? extends T> delegateProvider;
+
+    public InterceptingProvider(Key<T> key, Key<T> anonymousKey) {
+      this.key = key;
+      this.anonymousKey = anonymousKey;
+    }
+
+    @Inject void initialize(Injector injector,
+        Provider<ProvisionInterceptor> injectionInterceptorProvider) {
+      this.injectionInterceptorProvider
+          =  
checkNotNull(injectionInterceptorProvider, "injectionInterceptorProvider");
+      this.delegateProvider
+          =  
checkNotNull(injector.getProvider(anonymousKey), "delegateProvider");
+    }
+
+    public T get() {
+       
checkNotNull(injectionInterceptorProvider, "injectionInterceptorProvider");
+      checkNotNull(delegateProvider, "delegateProvider");
+      return injectionInterceptorProvider.get().intercept(key,  
delegateProvider);
+    }
+  }
+}

Added:  
tags/snapshot20090512/src/com/google/inject/commands/intercepting/ProvisionInterceptor.java
==============================================================================
--- (empty file)
+++  
tags/snapshot20090512/src/com/google/inject/commands/intercepting/ProvisionInterceptor.java
      
Wed May 13 13:44:42 2009
@@ -0,0 +1,33 @@
+/**
+ * Copyright (C) 2008 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.inject.commands.intercepting;
+
+import com.google.inject.Key;
+import com.google.inject.Provider;
+
+/**
+ * @deprecated copy this class into your own project
+ *
+ * <p>Intercepts object provision.
+ *
+ * @author [email protected] (Jesse Wilson)
+ * @author [email protected] (Jerome Mourits)
+ */
+...@deprecated
+public interface ProvisionInterceptor {
+  <T> T intercept(Key<T> key, Provider<? extends T> delegate);
+}

Modified: tags/snapshot20090512/src/com/google/inject/internal/Errors.java
==============================================================================
--- /trunk/src/com/google/inject/internal/Errors.java   (original)
+++ tags/snapshot20090512/src/com/google/inject/internal/Errors.java    Wed  
May 13 13:44:42 2009
@@ -18,6 +18,7 @@

  import com.google.inject.ConfigurationException;
  import com.google.inject.CreationException;
+import com.google.inject.Guice;
  import com.google.inject.Key;
  import com.google.inject.MembersInjector;
  import com.google.inject.Provider;
@@ -42,6 +43,8 @@
  import java.util.Comparator;
  import java.util.Formatter;
  import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.logging.Logger;

  /**
   * A collection of error messages. If this type is passed as a method  
parameter, the method is
@@ -60,9 +63,20 @@
   */
  public final class Errors implements Serializable {

+  private static final AtomicInteger warningsLogged = new AtomicInteger(0);
+
    // TODO(kevinb): gee, ya think we might want to remove this?
-  private static final boolean allowNullsBadBadBad
-      = "I'm a bad  
hack".equals(System.getProperty("guice.allow.nulls.bad.bad.bad"));
+  private static boolean allowNullsBadBadBad(Dependency<?> dependency) {
+    boolean allowNulls = "I'm a bad hack"
+        .equals(System.getProperty("guice.allow.nulls.bad.bad.bad"));
+
+    if (allowNulls && warningsLogged.getAndIncrement() < 10) {
+      Logger.getLogger(Guice.class.getName()).warning(
+          "Guice injected null into " + dependency + "; please mark it  
@Nullable");
+    }
+
+    return allowNulls;
+  }

    /**
     * The root errors object. Used to access the list of error messages.
@@ -278,7 +292,7 @@
        TypeLiteral<?> type, Throwable cause) {
      return errorInUserCode(cause,
          "Error notifying TypeListener %s (bound at %s) of %s.%n"
-        + " Reason: %s",
+            + " Reason: %s",
          listener.getListener(), convert(listener.getSource()), type,  
cause);
    }

@@ -505,7 +519,7 @@
        throws ErrorsException {
      if (value != null
          || dependency.isNullable()
-        || allowNullsBadBadBad) {
+        || allowNullsBadBadBad(dependency)) {
        return value;
      }


Modified:  
tags/snapshot20090512/src/com/google/inject/internal/Iterables.java
==============================================================================
--- /trunk/src/com/google/inject/internal/Iterables.java        (original)
+++ tags/snapshot20090512/src/com/google/inject/internal/Iterables.java Wed  
May 13 13:44:42 2009
@@ -20,16 +20,9 @@
  import java.util.Iterator;
  import java.util.NoSuchElementException;

-/**
- * This class contains static utility methods that operate on or return  
objects
- * of type {...@code Iterable}. Also see the parallel implementations in  
{...@link
- * Iterators}.
- *
- * @author Kevin Bourrillion
- * @author Scott Bonneau
- */
-public final class Iterables {
-  private Iterables() {}
+/** @deprecated please use the official version in {...@code  
com.google.common.collect}. */
+...@deprecated
+public class Iterables {

    /**
     * Returns a string representation of {...@code iterable}, with the format

Modified: tags/snapshot20090512/src/com/google/inject/internal/Lists.java
==============================================================================
--- /trunk/src/com/google/inject/internal/Lists.java    (original)
+++ tags/snapshot20090512/src/com/google/inject/internal/Lists.java     Wed May 
 
13 13:44:42 2009
@@ -20,17 +20,10 @@
  import java.util.Collection;
  import java.util.Collections;
  import java.util.Iterator;
-import java.util.List;

-/**
- * Static utility methods pertaining to {...@link List} instances. Also see  
this
- * class's counterparts {...@link Sets} and {...@link Maps}.
- *
- * @author Kevin Bourrillion
- * @author Mike Bostock
- */
-public final class Lists {
-  private Lists() {}
+/** @deprecated please use the official version in {...@code  
com.google.common.collect}. */
+...@deprecated
+public class Lists {

    // ArrayList


Modified: tags/snapshot20090512/src/com/google/inject/internal/Maps.java
==============================================================================
--- /trunk/src/com/google/inject/internal/Maps.java     (original)
+++ tags/snapshot20090512/src/com/google/inject/internal/Maps.java      Wed May 
 
13 13:44:42 2009
@@ -20,20 +20,12 @@
  import java.util.HashMap;
  import java.util.IdentityHashMap;
  import java.util.LinkedHashMap;
-import java.util.Map;
  import java.util.Map.Entry;
  import java.util.TreeMap;

-/**
- * Static utility methods pertaining to {...@link Map} instances. Also see  
this
- * class's counterparts {...@link Lists} and {...@link Sets}.
- *
- * @author Kevin Bourrillion
- * @author Mike Bostock
- * @author Isaac Shum
- */
-public final class Maps {
-  private Maps() {}
+/** @deprecated please use the official version in {...@code  
com.google.common.collect}. */
+...@deprecated
+public class Maps {

    /**
     * Creates a {...@code HashMap} instance.

Modified:  
tags/snapshot20090512/src/com/google/inject/internal/Preconditions.java
==============================================================================
--- /trunk/src/com/google/inject/internal/Preconditions.java    (original)
+++ tags/snapshot20090512/src/com/google/inject/internal/Preconditions.java     
 
Wed May 13 13:44:42 2009
@@ -17,48 +17,10 @@
  package com.google.inject.internal;

  import java.util.Collection;
-import java.util.NoSuchElementException;

-/**
- * Simple static methods to be called at the start of your own methods to  
verify
- * correct arguments and state. This allows constructs such as
- * <pre>
- *     if (count <= 0) {
- *       throw new IllegalArgumentException("must be positive: " + count);
- *     }</pre>
- *
- * to be replaced with the more compact
- * <pre>
- *     checkArgument(count > 0, "must be positive: %s", count);</pre>
- *
- * Note that the sense of the expression is inverted; with {...@code  
Preconditions}
- * you declare what you expect to be <i>true</i>, just as you do with an
- * <a  
href="http://java.sun.com/j2se/1.5.0/docs/guide/language/assert.html";>
- * {...@code assert}</a> or a JUnit {...@code assertTrue()} call.
- *
- * <p>Take care not to confuse precondition checking with other similar  
types
- * of checks! Precondition exceptions -- including those provided here,  
but also
- * {...@link IndexOutOfBoundsException}, {...@link NoSuchElementException},  
{...@link
- * UnsupportedOperationException} and others -- are used to signal that the
- * <i>calling method</i> has made an error. This tells the caller that it  
should
- * not have invoked the method when it did, with the arguments it did, or
- * perhaps <i>ever</i>. Postcondition or other invariant failures should  
not
- * throw these types of exceptions.
- *
- * <p><b>Note:</b> The methods of the {...@code Preconditions} class are  
highly
- * unusual in one way: they are <i>supposed to</i> throw exceptions, and  
promise
- * in their specifications to do so even when given perfectly valid input.  
That
- * is, {...@code null} is a valid parameter to the method {...@link
- * #checkNotNull(Object)} -- and technically this parameter could be even  
marked
- * as {...@link Nullable} -- yet the method will still throw an exception  
anyway,
- * because that's what its contract says to do.
- *
- * <p>This class may be used with the Google Web Toolkit (GWT).
- *
- * @author Kevin Bourrillion
- */
-public final class Preconditions {
-  private Preconditions() {}
+/** @deprecated please use the official version in {...@code  
com.google.common.collect}. */
+...@deprecated
+public class Preconditions {

    /**
     * Ensures the truth of an expression involving one or more parameters  
to the
@@ -290,12 +252,12 @@
      }
      return iterable;
    }
-
+
    private static boolean containsOrIsNull(Iterable<?> iterable) {
      if (iterable == null) {
        return true;
      }
-
+
      if (iterable instanceof Collection) {
        Collection<?> collection = (Collection<?>) iterable;
        try {

Modified: tags/snapshot20090512/src/com/google/inject/internal/Sets.java
==============================================================================
--- /trunk/src/com/google/inject/internal/Sets.java     (original)
+++ tags/snapshot20090512/src/com/google/inject/internal/Sets.java      Wed May 
 
13 13:44:42 2009
@@ -31,15 +31,9 @@
  import java.util.Set;
  import java.util.TreeMap;

-/**
- * Static utility methods pertaining to {...@link Set} instances. Also see  
this
- * class's counterparts {...@link Lists} and {...@link Maps}.
- *
- * @author Kevin Bourrillion
- * @author Jared Levy
- */
-public final class Sets {
-  private Sets() {}
+/** @deprecated please use the official version in {...@code  
com.google.common.collect}. */
+...@deprecated
+public class Sets {

    // HashSet


Added:  
tags/snapshot20090512/src/com/google/inject/internal/base/Preconditions.java
==============================================================================
--- (empty file)
+++  
tags/snapshot20090512/src/com/google/inject/internal/base/Preconditions.java    
 
Wed May 13 13:44:42 2009
@@ -0,0 +1,8 @@
+// Copyright 2009 Google Inc. All Rights Reserved.
+
+package com.google.inject.internal.base;
+
+/** @deprecated please use the official version in {...@code  
com.google.common.base}. */
+...@deprecated
+public class Preconditions extends  
com.google.inject.internal.Preconditions {
+}

Added:  
tags/snapshot20090512/src/com/google/inject/internal/collect/Iterables.java
==============================================================================
--- (empty file)
+++  
tags/snapshot20090512/src/com/google/inject/internal/collect/Iterables.java     
 
Wed May 13 13:44:42 2009
@@ -0,0 +1,8 @@
+// Copyright 2009 Google Inc. All Rights Reserved.
+
+package com.google.inject.internal.collect;
+
+/** @deprecated please use the official version in {...@code  
com.google.common.collect}. */
+...@deprecated
+public class Iterables extends com.google.inject.internal.Iterables {
+}

Added:  
tags/snapshot20090512/src/com/google/inject/internal/collect/Lists.java
==============================================================================
--- (empty file)
+++ tags/snapshot20090512/src/com/google/inject/internal/collect/Lists.java     
 
Wed May 13 13:44:42 2009
@@ -0,0 +1,8 @@
+// Copyright 2009 Google Inc. All Rights Reserved.
+
+package com.google.inject.internal.collect;
+
+/** @deprecated please use the official version in {...@code  
com.google.common.collect}. */
+...@deprecated
+public class Lists extends com.google.inject.internal.Lists {
+}

Added:  
tags/snapshot20090512/src/com/google/inject/internal/collect/Maps.java
==============================================================================
--- (empty file)
+++ tags/snapshot20090512/src/com/google/inject/internal/collect/Maps.java      
 
Wed May 13 13:44:42 2009
@@ -0,0 +1,8 @@
+// Copyright 2009 Google Inc. All Rights Reserved.
+
+package com.google.inject.internal.collect;
+
+/** @deprecated please use the official version in {...@code  
com.google.common.collect}. */
+...@deprecated
+public class Maps extends com.google.inject.internal.Maps {
+}

Added:  
tags/snapshot20090512/src/com/google/inject/internal/collect/Sets.java
==============================================================================
--- (empty file)
+++ tags/snapshot20090512/src/com/google/inject/internal/collect/Sets.java      
 
Wed May 13 13:44:42 2009
@@ -0,0 +1,8 @@
+// Copyright 2009 Google Inc. All Rights Reserved.
+
+package com.google.inject.internal.collect;
+
+/** @deprecated please use the official version in {...@code  
com.google.common.collect}. */
+...@deprecated
+public class Sets extends com.google.inject.internal.Sets {
+}

Modified:  
tags/snapshot20090512/src/com/google/inject/spi/DefaultBindingTargetVisitor.java
==============================================================================
--- /trunk/src/com/google/inject/spi/DefaultBindingTargetVisitor.java    
(original)
+++  
tags/snapshot20090512/src/com/google/inject/spi/DefaultBindingTargetVisitor.java
         
Wed May 13 13:44:42 2009
@@ -17,6 +17,10 @@
  package com.google.inject.spi;

  import com.google.inject.Binding;
+import com.google.inject.Provider;
+import com.google.inject.Key;
+import java.util.Set;
+import java.lang.reflect.Constructor;

  /**
   * No-op visitor for subclassing. All interface methods simply delegate to  
{...@link
@@ -38,40 +42,157 @@
    }

    public V visit(InstanceBinding<? extends T> instanceBinding) {
-    return visitOther(instanceBinding);
+    return visitInstance(instanceBinding);
    }

    public V visit(ProviderInstanceBinding<? extends T>  
providerInstanceBinding) {
-    return visitOther(providerInstanceBinding);
+    return visitProviderInstance(providerInstanceBinding);
    }

    public V visit(ProviderKeyBinding<? extends T> providerKeyBinding) {
-    return visitOther(providerKeyBinding);
+    return visitProviderKey(providerKeyBinding);
    }

    public V visit(LinkedKeyBinding<? extends T> linkedKeyBinding) {
-    return visitOther(linkedKeyBinding);
+    return visitLinkedKey(linkedKeyBinding);
    }

    public V visit(ExposedBinding<? extends T> exposedBinding) {
-    return visitOther(exposedBinding);
+    return visitExposed(exposedBinding);
    }

    public V visit(UntargettedBinding<? extends T> untargettedBinding) {
-    return visitOther(untargettedBinding);
+    return visitUntargetted(untargettedBinding);
    }

    public V visit(ConstructorBinding<? extends T> constructorBinding) {
-    return visitOther(constructorBinding);
+    return visitConstructor(constructorBinding);
    }

    public V visit(ConvertedConstantBinding<? extends T>  
convertedConstantBinding) {
-    return visitOther(convertedConstantBinding);
+    return visitConvertedConstant(convertedConstantBinding);
    }

-   // javac says it's an error to cast ProviderBinding<? extends T> to  
Binding<? extends T>
+  // javac says it's an error to cast ProviderBinding<? extends T> to  
Binding<? extends T>
    @SuppressWarnings("unchecked")
    public V visit(ProviderBinding<? extends T> providerBinding) {
      return visitOther((Binding) providerBinding);
+  }
+
+  // this API has gone through two major changes
+  //   originally each method had the form visitInstance(T,  
injectionPoints)
+  //                     and then the form visitInstance(InstanceBinding)
+  //                      and now the form visit(InstanceBinding)
+  //
+  // apologies for the churn.
+
+  /** @deprecated override {...@code visit} instead. */
+  @Deprecated protected V visitOther() {
+    return null;
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  @Deprecated public V visitInstance(T instance, Set<InjectionPoint>  
injectionPoints) {
+    return visitOther();
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  @Deprecated public V visitProvider(
+      Provider<? extends T> provider, Set<InjectionPoint> injectionPoints)  
{
+    return visitOther();
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  @Deprecated public V visitProviderKey(Key<? extends Provider<? extends  
T>> providerKey) {
+    return visitOther();
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  @Deprecated public V visitKey(Key<? extends T> key) {
+    return visitOther();
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  @Deprecated public V visitUntargetted() {
+    return visitOther();
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  @Deprecated public V visitConstructor(Constructor<? extends T>  
constructor,
+      Set<InjectionPoint> injectionPoints) {
+    return visitOther();
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  @Deprecated public V visitConvertedConstant(T value) {
+    return visitOther();
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  @Deprecated public V visitProviderBinding(Key<?> provided) {
+    return visitOther();
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  @Deprecated public V visitExposed(PrivateElements privateElements) {
+    return visitOther();
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  @Deprecated public V visitInstance(InstanceBinding<? extends T> binding)  
{
+    V result = visitInstance(binding.getInstance(),  
binding.getInjectionPoints());
+    return result != null ? result : visitOther(binding);
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  @Deprecated public V visitProviderInstance(ProviderInstanceBinding<?  
extends T> binding) {
+    V result = visitProvider(binding.getProviderInstance(),  
binding.getInjectionPoints());
+    return result != null ? result : visitOther(binding);
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  @Deprecated public V visitProviderKey(ProviderKeyBinding<? extends T>  
binding) {
+    V result = visitProviderKey(binding.getProviderKey());
+    return result != null ? result : visitOther(binding);
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  @Deprecated public V visitLinkedKey(LinkedKeyBinding<? extends T>  
binding) {
+    V result = visitKey(binding.getLinkedKey());
+    return result != null ? result : visitOther(binding);
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  @Deprecated public V visitExposed(ExposedBinding<? extends T> binding) {
+    V result = visitExposed(binding.getPrivateElements());
+    return result != null ? result : visitOther(binding);
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  @Deprecated public V visitUntargetted(UntargettedBinding<? extends T>  
binding) {
+    V result = visitUntargetted();
+    return result != null ? result : visitOther(binding);
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  @SuppressWarnings("unchecked")
+  @Deprecated public V visitConstructor(ConstructorBinding<? extends T>  
binding) {
+    V result = visitConstructor((Constructor)  
binding.getConstructor().getMember(),
+        binding.getInjectableMembers());
+    return result != null ? result : visitOther(binding);
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  @Deprecated public V visitConvertedConstant(ConvertedConstantBinding<?  
extends T> binding) {
+    V result = visitConvertedConstant(binding.getValue());
+    return result != null ? result : visitOther(binding);
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  // javac says it's an error to cast ProviderBinding<? extends T> to  
Binding<? extends T>
+  @SuppressWarnings("unchecked")
+  @Deprecated public V visitProviderBinding(ProviderBinding<? extends T>  
binding) {
+    V result = visitProviderBinding(binding.getProvidedKey());
+    return result != null ? result : visitOther((Binding) binding);
    }
  }

Modified:  
tags/snapshot20090512/src/com/google/inject/spi/DefaultElementVisitor.java
==============================================================================
--- /trunk/src/com/google/inject/spi/DefaultElementVisitor.java (original)
+++  
tags/snapshot20090512/src/com/google/inject/spi/DefaultElementVisitor.java      
 
Wed May 13 13:44:42 2009
@@ -38,41 +38,41 @@
    }

    public V visit(Message message) {
-    return visitOther(message);
+    return visitMessage(message);
    }

    public <T> V visit(Binding<T> binding) {
-    return visitOther(binding);
+    return visitBinding(binding);
    }

    /*if[AOP]*/
    public V visit(InterceptorBinding interceptorBinding) {
-    return visitOther(interceptorBinding);
+    return visitInterceptorBinding(interceptorBinding);
    }
    /*end[AOP]*/

    public V visit(ScopeBinding scopeBinding) {
-    return visitOther(scopeBinding);
+    return visitScopeBinding(scopeBinding);
    }

    public V visit(TypeConverterBinding typeConverterBinding) {
-    return visitOther(typeConverterBinding);
+    return visitTypeConverterBinding(typeConverterBinding);
    }

    public <T> V visit(ProviderLookup<T> providerLookup) {
-    return visitOther(providerLookup);
+    return visitProviderLookup(providerLookup);
    }

    public V visit(InjectionRequest injectionRequest) {
-    return visitOther(injectionRequest);
+    return visitInjectionRequest(injectionRequest);
    }

    public V visit(StaticInjectionRequest staticInjectionRequest) {
-    return visitOther(staticInjectionRequest);
+    return visitStaticInjectionRequest(staticInjectionRequest);
    }

    public V visit(PrivateElements privateElements) {
-    return visitOther(privateElements);
+    return visitPrivateElements(privateElements);
    }

    public <T> V visit(MembersInjectorLookup<T> lookup) {
@@ -81,5 +81,57 @@

    public V visit(TypeListenerBinding binding) {
      return visitOther(binding);
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  protected V visitElement(Element element) {
+    return visitOther(element);
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  public V visitMessage(Message message) {
+    return visitElement(message);
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  public <T> V visitBinding(Binding<T> binding) {
+    return visitElement(binding);
+  }
+
+  /*if[AOP]*/
+  /** @deprecated override {...@code visit} instead. */
+  public V visitInterceptorBinding(InterceptorBinding interceptorBinding) {
+    return visitElement(interceptorBinding);
+  }
+  /*end[AOP]*/
+
+  /** @deprecated override {...@code visit} instead. */
+  public V visitScopeBinding(ScopeBinding scopeBinding) {
+    return visitElement(scopeBinding);
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  public V visitTypeConverterBinding(TypeConverterBinding  
typeConverterBinding) {
+    return visitElement(typeConverterBinding);
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  public <T> V visitProviderLookup(ProviderLookup<T> providerLookup) {
+    return visitElement(providerLookup);
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  public V visitInjectionRequest(InjectionRequest injectionRequest) {
+    return visitElement(injectionRequest);
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  public V visitStaticInjectionRequest(StaticInjectionRequest  
staticInjectionRequest) {
+    return visitElement(staticInjectionRequest);
+  }
+
+  /** @deprecated override {...@code visit} instead. */
+  public V visitPrivateElements(PrivateElements privateElements) {
+    return visitElement(privateElements);
    }
  }

--~--~---------~--~----~------------~-------~--~----~
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