Author: limpbizkit
Date: Thu Feb 19 01:06:22 2009
New Revision: 851

Modified:
    trunk/build.xml
     
trunk/extensions/assistedinject/test/com/google/inject/assistedinject/FactoryProvider2Test.java
    trunk/lib/build/munge.jar
    trunk/src/com/google/inject/AbstractModule.java
    trunk/src/com/google/inject/AbstractProcessor.java
    trunk/src/com/google/inject/ClassBindingImpl.java
    trunk/src/com/google/inject/ConstructionProxy.java
    trunk/src/com/google/inject/DefaultConstructionProxyFactory.java
    trunk/src/com/google/inject/InheritingState.java
    trunk/src/com/google/inject/InjectorShell.java
    trunk/src/com/google/inject/PrivateModule.java
    trunk/src/com/google/inject/State.java
    trunk/src/com/google/inject/spi/ConstructorBinding.java
    trunk/src/com/google/inject/spi/DefaultElementVisitor.java
    trunk/src/com/google/inject/spi/ElementVisitor.java
    trunk/src/com/google/inject/spi/Elements.java
    trunk/src/com/google/inject/spi/ModuleWriter.java
    trunk/test/com/google/inject/AllTests.java
    trunk/test/com/google/inject/ParentInjectorTest.java
    trunk/test/com/google/inject/internal/LineNumbersTest.java
    trunk/test/com/google/inject/spi/ElementsTest.java

Log:
Removing all references to method interceptors from the non-AOPified Guice.  
This passes the full Guice test suite (other than the interceptor tests  
that are removed, and the tests that fail in the normal Guice build).

I still need to remove FastClass/FastMethod references. That should be  
substantially easier. (Although this was fairly straightforward)

I'm not sure about the variable names AOP and NO_AOP. Suggestions welcome.

Modified: trunk/build.xml
==============================================================================
--- trunk/build.xml     (original)
+++ trunk/build.xml     Thu Feb 19 01:06:22 2009
@@ -120,7 +120,18 @@
      <taskdef name="munge" classname="MungeTask"  
classpath="lib/build/munge.jar"/>
      <mkdir dir="build/no_aop"/>
      <munge todir="build/no_aop">
-      <fileset dir="." excludes="build/**/*"/>
+      <fileset dir=".">
+        <exclude name="build/**/*"/>
+        <exclude name="**/InterceptorBindingProcessor.java"/>
+        <exclude name="**/ProxyFactory.java"/>
+        <exclude name="**/InterceptorStackCallback.java"/>
+        <exclude name="**/InterceptorBinding.java"/>
+        <exclude name="**/MethodAspect.java"/>
+        <exclude name="**/MethodInterceptionTest.java"/>
+        <exclude name="**/BytecodeGenTest.java"/>
+        <exclude name="**/IntegrationTest.java"/>
+        <exclude name="**/MethodInterceptionTest.java"/>
+      </fileset>
        <arg value="-DNO_AOP" />
      </munge>
    </target>

Modified:  
trunk/extensions/assistedinject/test/com/google/inject/assistedinject/FactoryProvider2Test.java
==============================================================================
---  
trunk/extensions/assistedinject/test/com/google/inject/assistedinject/FactoryProvider2Test.java
  
(original)
+++  
trunk/extensions/assistedinject/test/com/google/inject/assistedinject/FactoryProvider2Test.java
  
Thu Feb 19 01:06:22 2009
@@ -610,6 +610,7 @@
      }
    }

+  /*if[AOP]*/
    public void testMethodInterceptorsOnAssistedTypes() {
      final AtomicInteger invocationCount = new AtomicInteger();
      final MethodInterceptor interceptor = new MethodInterceptor() {
@@ -635,6 +636,7 @@
      mustang.drive();
      assertEquals(1, invocationCount.get());
    }
+  /*end[AOP]*/

    /**
     * Our factories aren't reusable across injectors. Although this  
behaviour isn't something we

Modified: trunk/lib/build/munge.jar
==============================================================================
Binary files. No diff available.

Modified: trunk/src/com/google/inject/AbstractModule.java
==============================================================================
--- trunk/src/com/google/inject/AbstractModule.java     (original)
+++ trunk/src/com/google/inject/AbstractModule.java     Thu Feb 19 01:06:22 2009
@@ -155,6 +155,7 @@
      binder.requestStaticInjection(types);
    }

+  /*if[AOP]*/
    /**
     * @see Binder#bindInterceptor(com.google.inject.matcher.Matcher,
     *  com.google.inject.matcher.Matcher,
@@ -165,6 +166,7 @@
        MethodInterceptor... interceptors) {
      binder.bindInterceptor(classMatcher, methodMatcher, interceptors);
    }
+  /*end[AOP]*/

    /**
     * Adds a dependency from this module to {...@code key}. When the injector  
is

Modified: trunk/src/com/google/inject/AbstractProcessor.java
==============================================================================
--- trunk/src/com/google/inject/AbstractProcessor.java  (original)
+++ trunk/src/com/google/inject/AbstractProcessor.java  Thu Feb 19 01:06:22  
2009
@@ -76,9 +76,11 @@
      return false;
    }

+  /*if[AOP]*/
    public Boolean visitInterceptorBinding(InterceptorBinding  
interceptorBinding) {
      return false;
    }
+  /*end[AOP]*/

    public Boolean visitScopeBinding(ScopeBinding scopeBinding) {
      return false;

Modified: trunk/src/com/google/inject/ClassBindingImpl.java
==============================================================================
--- trunk/src/com/google/inject/ClassBindingImpl.java   (original)
+++ trunk/src/com/google/inject/ClassBindingImpl.java   Thu Feb 19 01:06:22  
2009
@@ -70,9 +70,11 @@
      return Dependency.forInjectionPoints(injectionPoints);
    }

+  /*if[AOP]*/
    public Map<Method, List<MethodInterceptor>> getMethodInterceptors() {
      return  
lateBoundConstructor.constructorInjector.constructionProxy.getMethodInterceptors();
    }
+  /*end[AOP]*/

    @Override public String toString() {
      return new ToStringBuilder(ConstructorBinding.class)

Modified: trunk/src/com/google/inject/ConstructionProxy.java
==============================================================================
--- trunk/src/com/google/inject/ConstructionProxy.java  (original)
+++ trunk/src/com/google/inject/ConstructionProxy.java  Thu Feb 19 01:06:22  
2009
@@ -48,8 +48,10 @@
     */
    Constructor<T> getConstructor();

+  /*if[AOP]*/
    /**
     * Returns the interceptors applied to each method, in order of  
invocation.
     */
    Map<Method, List<MethodInterceptor>> getMethodInterceptors();
+  /*end[AOP]*/
  }

Modified: trunk/src/com/google/inject/DefaultConstructionProxyFactory.java
==============================================================================
--- trunk/src/com/google/inject/DefaultConstructionProxyFactory.java     
(original)
+++ trunk/src/com/google/inject/DefaultConstructionProxyFactory.java    Thu  
Feb 19 01:06:22 2009
@@ -43,18 +43,17 @@
      @SuppressWarnings("unchecked") // the injection point is for a  
constructor of T
      final Constructor<T> constructor = (Constructor<T>)  
injectionPoint.getMember();

-    // We can't use FastConstructor if the constructor is non-public.
-    if (!Modifier.isPublic(constructor.getModifiers())) {
-      constructor.setAccessible(true);
+    /*if[AOP]*/
+    // Use FastConstructor if the constructor is public.
+    if (Modifier.isPublic(constructor.getModifiers())) {
        return new ConstructionProxy<T>() {
+        Class<T> classToConstruct = constructor.getDeclaringClass();
+        FastClass fastClass = newFastClass(classToConstruct,  
Visibility.forMember(constructor));
+        final FastConstructor fastConstructor =  
fastClass.getConstructor(constructor);
+
+        @SuppressWarnings("unchecked")
          public T newInstance(Object... arguments) throws  
InvocationTargetException {
-          try {
-            return constructor.newInstance(arguments);
-          } catch (InstantiationException e) {
-            throw new AssertionError(e); // shouldn't happen, we know this  
is a concrete type
-          } catch (IllegalAccessException e) {
-            throw new AssertionError(e); // a security manager is blocking  
us, we're hosed
-          }
+          return (T) fastConstructor.newInstance(arguments);
          }
          public InjectionPoint getInjectionPoint() {
            return injectionPoint;
@@ -67,15 +66,21 @@
          }
        };
      }
+    /*end[AOP]*/

-    return new ConstructionProxy<T>() {
-      Class<T> classToConstruct = constructor.getDeclaringClass();
-      FastClass fastClass = newFastClass(classToConstruct,  
Visibility.forMember(constructor));
-      final FastConstructor fastConstructor =  
fastClass.getConstructor(constructor);
+    if (!Modifier.isPublic(constructor.getModifiers())) {
+      constructor.setAccessible(true);
+    }

-      @SuppressWarnings("unchecked")
+    return new ConstructionProxy<T>() {
        public T newInstance(Object... arguments) throws  
InvocationTargetException {
-        return (T) fastConstructor.newInstance(arguments);
+        try {
+          return constructor.newInstance(arguments);
+        } catch (InstantiationException e) {
+          throw new AssertionError(e); // shouldn't happen, we know this  
is a concrete type
+        } catch (IllegalAccessException e) {
+          throw new AssertionError(e); // a security manager is blocking  
us, we're hosed
+        }
        }
        public InjectionPoint getInjectionPoint() {
          return injectionPoint;
@@ -83,9 +88,11 @@
        public Constructor<T> getConstructor() {
          return constructor;
        }
+      /*if[AOP]*/
        public Map<Method, List<MethodInterceptor>> getMethodInterceptors() {
          return ImmutableMap.of();
        }
+      /*end[AOP]*/
      };
    }
  }

Modified: trunk/src/com/google/inject/InheritingState.java
==============================================================================
--- trunk/src/com/google/inject/InheritingState.java    (original)
+++ trunk/src/com/google/inject/InheritingState.java    Thu Feb 19 01:06:22  
2009
@@ -40,7 +40,9 @@
        = Collections.unmodifiableMap(explicitBindingsMutable);
    private final Map<Class<? extends Annotation>, Scope> scopes =  
Maps.newHashMap();
    private final List<MatcherAndConverter> converters =  
Lists.newArrayList();
+  /*if[AOP]*/
    private final List<MethodAspect> methodAspects = Lists.newArrayList();
+  /*end[AOP]*/
    private final WeakKeySet blacklistedKeys = new WeakKeySet();
    private final Object lock;

@@ -100,6 +102,7 @@
      return matchingConverter;
    }

+  /*if[AOP]*/
    public void addMethodAspect(MethodAspect methodAspect) {
      methodAspects.add(methodAspect);
    }
@@ -110,6 +113,7 @@
      result.addAll(methodAspects);
      return result;
    }
+  /*end[AOP]*/

    public void blacklist(Key<?> key) {
      parent.blacklist(key);

Modified: trunk/src/com/google/inject/InjectorShell.java
==============================================================================
--- trunk/src/com/google/inject/InjectorShell.java      (original)
+++ trunk/src/com/google/inject/InjectorShell.java      Thu Feb 19 01:06:22 2009
@@ -136,10 +136,15 @@

        new MessageProcessor(errors).process(injector, elements);

+      /*if[AOP]*/
        InterceptorBindingProcessor interceptors = new  
InterceptorBindingProcessor(errors);
        interceptors.process(injector, elements);
        interceptors.setupProxyFactory(injector);
        stopwatch.resetAndLog("Interceptors creation");
+      /*end[AOP]*/
+      /*if[NO_AOP]
+      injector.constructionProxyFactory = new  
DefaultConstructionProxyFactory();
+      end[NO_AOP]*/

        new ScopeBindingProcessor(errors).process(injector, elements);
        stopwatch.resetAndLog("Scopes creation");

Modified: trunk/src/com/google/inject/PrivateModule.java
==============================================================================
--- trunk/src/com/google/inject/PrivateModule.java      (original)
+++ trunk/src/com/google/inject/PrivateModule.java      Thu Feb 19 01:06:22 2009
@@ -179,10 +179,12 @@
      binder.requestStaticInjection(types);
    }

+  /*if[AOP]*/
    protected final void bindInterceptor(Matcher<? super Class<?>>  
classMatcher,
        Matcher<? super Method> methodMatcher, MethodInterceptor...  
interceptors) {
      binder.bindInterceptor(classMatcher, methodMatcher, interceptors);
    }
+  /*end[AOP]*/

    protected final void requireBinding(Key<?> key) {
      binder.getProvider(key);

Modified: trunk/src/com/google/inject/State.java
==============================================================================
--- trunk/src/com/google/inject/State.java      (original)
+++ trunk/src/com/google/inject/State.java      Thu Feb 19 01:06:22 2009
@@ -71,6 +71,7 @@
        return ImmutableSet.of();
      }

+    /*if[AOP]*/
      public void addMethodAspect(MethodAspect methodAspect) {
        throw new UnsupportedOperationException();
      }
@@ -78,6 +79,7 @@
      public List<MethodAspect> getMethodAspects() {
        return ImmutableList.of();
      }
+    /*end[AOP]*/

      public void blacklist(Key<?> key) {
      }
@@ -115,9 +117,11 @@
    /** Returns all converters at this level only. */
    Iterable<MatcherAndConverter> getConvertersThisLevel();

+  /*if[AOP]*/
    void addMethodAspect(MethodAspect methodAspect);

    List<MethodAspect> getMethodAspects();
+  /*end[AOP]*/

    /**
     * Forbids the corresponding injector from creating a binding to {...@code  
key}. Child injectors

Modified: trunk/src/com/google/inject/spi/ConstructorBinding.java
==============================================================================
--- trunk/src/com/google/inject/spi/ConstructorBinding.java     (original)
+++ trunk/src/com/google/inject/spi/ConstructorBinding.java     Thu Feb 19  
01:06:22 2009
@@ -45,11 +45,13 @@
     */
    Set<InjectionPoint> getInjectionPoints();

+  /*if[AOP]*/
    /**
     * Returns the interceptors applied to each method, in the order that  
they will be applied.
     *
     * @return a possibly empty map
     */
    Map<Method, List<MethodInterceptor>> getMethodInterceptors();
+  /*end[AOP]*/

  }

Modified: trunk/src/com/google/inject/spi/DefaultElementVisitor.java
==============================================================================
--- trunk/src/com/google/inject/spi/DefaultElementVisitor.java  (original)
+++ trunk/src/com/google/inject/spi/DefaultElementVisitor.java  Thu Feb 19  
01:06:22 2009
@@ -45,9 +45,11 @@
      return visitElement(binding);
    }

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

    public V visitScopeBinding(ScopeBinding scopeBinding) {
      return visitElement(scopeBinding);

Modified: trunk/src/com/google/inject/spi/ElementVisitor.java
==============================================================================
--- trunk/src/com/google/inject/spi/ElementVisitor.java (original)
+++ trunk/src/com/google/inject/spi/ElementVisitor.java Thu Feb 19 01:06:22  
2009
@@ -34,10 +34,12 @@
     */
    <T> V visitBinding(Binding<T> binding);

+  /*if[AOP]*/
    /**
     * Visit a registration of interceptors for matching methods of matching  
classes.
     */
    V visitInterceptorBinding(InterceptorBinding interceptorBinding);
+  /*end[AOP]*/

    /**
     * Visit a registration of a scope annotation with the scope that  
implements it.

Modified: trunk/src/com/google/inject/spi/Elements.java
==============================================================================
--- trunk/src/com/google/inject/spi/Elements.java       (original)
+++ trunk/src/com/google/inject/spi/Elements.java       Thu Feb 19 01:06:22 2009
@@ -26,12 +26,12 @@
  import com.google.inject.Binding;
  import com.google.inject.Key;
  import com.google.inject.Module;
+import com.google.inject.PrivateBinder;
  import com.google.inject.PrivateModule;
  import com.google.inject.Provider;
  import com.google.inject.Scope;
  import com.google.inject.Stage;
  import com.google.inject.TypeLiteral;
-import com.google.inject.PrivateBinder;
  import com.google.inject.binder.AnnotatedBindingBuilder;
  import com.google.inject.binder.AnnotatedConstantBindingBuilder;
  import com.google.inject.binder.AnnotatedElementBuilder;
@@ -156,12 +156,14 @@
        this.privateElements = privateElements;
      }

+    /*if[AOP]*/
      public void bindInterceptor(
          Matcher<? super Class<?>> classMatcher,
          Matcher<? super Method> methodMatcher,
          MethodInterceptor... interceptors) {
        elements.add(new InterceptorBinding(getSource(), classMatcher,  
methodMatcher, interceptors));
      }
+    /*end[AOP]*/

      public void bindScope(Class<? extends Annotation> annotationType,  
Scope scope) {
        elements.add(new ScopeBinding(getSource(), annotationType, scope));

Modified: trunk/src/com/google/inject/spi/ModuleWriter.java
==============================================================================
--- trunk/src/com/google/inject/spi/ModuleWriter.java   (original)
+++ trunk/src/com/google/inject/spi/ModuleWriter.java   Thu Feb 19 01:06:22  
2009
@@ -23,9 +23,9 @@
  import com.google.inject.Binding;
  import com.google.inject.Key;
  import com.google.inject.Module;
+import com.google.inject.PrivateBinder;
  import com.google.inject.Provider;
  import com.google.inject.Scope;
-import com.google.inject.PrivateBinder;
  import com.google.inject.binder.ScopedBindingBuilder;
  import java.lang.annotation.Annotation;
  import java.util.List;
@@ -67,10 +67,12 @@
          return null;
        }

+      /*if[AOP]*/
        public Void visitInterceptorBinding(InterceptorBinding element) {
          writeBindInterceptor(binder, element);
          return null;
        }
+      /*end[AOP]*/

        public Void visitScopeBinding(ScopeBinding element) {
          writeBindScope(binder, element);
@@ -117,12 +119,14 @@
      binder.addError(element);
    }

+  /*if[AOP]*/
    protected void writeBindInterceptor(Binder binder, InterceptorBinding  
element) {
      List<MethodInterceptor> interceptors = element.getInterceptors();
      binder.withSource(element.getSource()).bindInterceptor(
          element.getClassMatcher(), element.getMethodMatcher(),
          interceptors.toArray(new MethodInterceptor[interceptors.size()]));
    }
+  /*end[AOP]*/

    protected void writeBindScope(Binder binder, ScopeBinding element) {
      binder.withSource(element.getSource()).bindScope(

Modified: trunk/test/com/google/inject/AllTests.java
==============================================================================
--- trunk/test/com/google/inject/AllTests.java  (original)
+++ trunk/test/com/google/inject/AllTests.java  Thu Feb 19 01:06:22 2009
@@ -17,10 +17,10 @@
  package com.google.inject;

  import com.google.inject.internal.FinalizableReferenceQueueTest;
+import com.google.inject.internal.Jsr166HashMapTest;
  import com.google.inject.internal.LineNumbersTest;
  import com.google.inject.internal.MapMakerTestSuite;
  import com.google.inject.internal.UniqueAnnotationsTest;
-import com.google.inject.internal.Jsr166HashMapTest;
  import com.google.inject.matcher.MatcherTest;
  import com.google.inject.name.NamesTest;
  import com.google.inject.spi.ElementsTest;
@@ -59,10 +59,8 @@
      suite.addTestSuite(ImplicitBindingTest.class);
      suite.addTestSuite(InjectionPointTest.class);
      suite.addTestSuite(InjectorTest.class);
-    suite.addTestSuite(IntegrationTest.class);
      suite.addTestSuite(KeyTest.class);
      suite.addTestSuite(LoggerInjectionTest.class);
-    suite.addTestSuite(MethodInterceptionTest.class);
      suite.addTestSuite(ModuleTest.class);
      suite.addTestSuite(ModulesTest.class);
      suite.addTestSuite(NullableInjectionPointTest.class);
@@ -97,7 +95,6 @@
      suite.addTestSuite(Jsr166HashMapTest.class);
      suite.addTestSuite(TypesTest.class);
      suite.addTestSuite(UniqueAnnotationsTest.class);
-    suite.addTestSuite(BytecodeGenTest.class);

      // matcher
      suite.addTestSuite(MatcherTest.class);
@@ -110,6 +107,12 @@

      // util
      suite.addTestSuite(ProvidersTest.class);
+
+    /*if[AOP]*/
+    suite.addTestSuite(IntegrationTest.class);
+    suite.addTestSuite(MethodInterceptionTest.class);
+    suite.addTestSuite(BytecodeGenTest.class);
+    /*end[AOP]*/

      return suite;
    }

Modified: trunk/test/com/google/inject/ParentInjectorTest.java
==============================================================================
--- trunk/test/com/google/inject/ParentInjectorTest.java        (original)
+++ trunk/test/com/google/inject/ParentInjectorTest.java        Thu Feb 19  
01:06:22 2009
@@ -110,6 +110,7 @@
      assertSame(child.getInstance(A.class), child.getInstance(A.class));
    }

+  /*if[AOP]*/
    public void testInterceptorsInherited() {
      Injector parent = Guice.createInjector(new AbstractModule() {
        protected void configure() {
@@ -126,6 +127,7 @@

      assertNull(child.getInstance(C.class).interceptedMethod());
    }
+  /*end[AOP]*/

    public void testTypeConvertersInherited() {
      Injector parent = Guice.createInjector(bindListConverterModule);

Modified: trunk/test/com/google/inject/internal/LineNumbersTest.java
==============================================================================
--- trunk/test/com/google/inject/internal/LineNumbersTest.java  (original)
+++ trunk/test/com/google/inject/internal/LineNumbersTest.java  Thu Feb 19  
01:06:22 2009
@@ -32,6 +32,7 @@
   */
  public class LineNumbersTest extends TestCase {

+  /*if[AOP]*/
    public void testCanHandleLineNumbersForGuiceGeneratedClasses() {
      try {
        Guice.createInjector(new AbstractModule() {
@@ -54,6 +55,7 @@
            "at " +  
LineNumbersTest.class.getName(), ".configure(LineNumbersTest.java:");
      }
    }
+  /*end[AOP]*/

    static class A {
      @Inject A(B b) {}

Modified: trunk/test/com/google/inject/spi/ElementsTest.java
==============================================================================
--- trunk/test/com/google/inject/spi/ElementsTest.java  (original)
+++ trunk/test/com/google/inject/spi/ElementsTest.java  Thu Feb 19 01:06:22  
2009
@@ -23,12 +23,12 @@
  import com.google.inject.BindingAnnotation;
  import com.google.inject.Key;
  import com.google.inject.Module;
+import com.google.inject.PrivateBinder;
  import com.google.inject.Provider;
  import com.google.inject.Scope;
  import com.google.inject.Scopes;
  import com.google.inject.Singleton;
  import com.google.inject.TypeLiteral;
-import com.google.inject.PrivateBinder;
  import com.google.inject.binder.AnnotatedBindingBuilder;
  import com.google.inject.binder.AnnotatedConstantBindingBuilder;
  import com.google.inject.binder.ConstantBindingBuilder;
@@ -539,6 +539,7 @@
      );
    }

+  /*if[AOP]*/
    public void testBindIntercepor() {
      final Matcher<Class> classMatcher = Matchers.subclassesOf(List.class);
      final Matcher<Object> methodMatcher = Matchers.any();
@@ -565,6 +566,7 @@
          }
      );
    }
+  /*end[AOP]*/

    public void testBindScope() {
      checkModule(

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