org.directwebremoting.guice.util
Class AbstractModule

java.lang.Object
  extended by com.google.inject.AbstractModule
      extended by org.directwebremoting.guice.util.AbstractModule
All Implemented Interfaces:
com.google.inject.Module
Direct Known Subclasses:
AbstractDwrModule

public abstract class AbstractModule
extends com.google.inject.AbstractModule

An extension of Guice's AbstractModule that provides support for member injection of objects created before injector creation, including AbstractModule itself and MethodInterceptor instances constructed at bind-time.

In addition, there are bindInterceptor variants that arrange for the interceptors to be constructor-injected, that can wrap each interceptor with extra common behavior, and that intercept all calls to methods declared by a given type. These variants all call registerForInjection, so there is no need to call it explicitly when using these methods (though it's harmless to do so).

The Class<?> and Key<?> arguments in the bindInterceptor variants really should be Class<? extends MethodInterceptor> and Key<? extends MethodInterceptor>, but this would cause compile-time warnings on every use.

Author:
Tim Peierls [tim at peierls dot net]

Method Summary
 void bindInterceptor(java.lang.Class<?> targetType, java.lang.Class<?>... methodInterceptorClasses)
          Variant of bindInterceptor intercepting non-nested calls to instances of a given type (or of a subclass of that type), allowing constructor-injection of interceptors described by class.
 void bindInterceptor(java.lang.Class<?> targetType, com.google.inject.Key<?>... methodInterceptorKeys)
          Variant of bindInterceptor intercepting non-nested calls to instances of a given type (or of a subclass of that type), allowing constructor-injection of interceptors described by Key.
 void bindInterceptor(com.google.inject.matcher.Matcher<? super java.lang.Class<?>> classMatcher, com.google.inject.matcher.Matcher<? super java.lang.reflect.Method> methodMatcher, java.lang.Class<?>... methodInterceptorClasses)
          Variant of bindInterceptor(Class, Class...) that allows constructor-injection of interceptors described by class.
 void bindInterceptor(com.google.inject.matcher.Matcher<? super java.lang.Class<?>> classMatcher, com.google.inject.matcher.Matcher<? super java.lang.reflect.Method> methodMatcher, com.google.inject.Key<?>... methodInterceptorKeys)
          Variant of bindInterceptor that allows constructor-injection of interceptors described by Key.
 void bindInterceptor(com.google.inject.matcher.Matcher<? super java.lang.Class<?>> classMatcher, com.google.inject.matcher.Matcher<? super java.lang.reflect.Method> methodMatcher, org.aopalliance.intercept.MethodInterceptor... methodInterceptors)
          Overridden version of bindInterceptor that, in addition to the standard behavior, arranges for field and method injection of each MethodInterceptor in interceptors.
 void bindInterceptor(com.google.inject.matcher.Matcher<? super java.lang.Class<?>> classMatcher, com.google.inject.matcher.Matcher<? super java.lang.reflect.Method> methodMatcher, MethodInterceptorWrapper methodInterceptorWrapper, java.lang.Class<?>... methodInterceptorClasses)
          Variant of bindInterceptor that allows constructor-injection of interceptors described by class, each wrapped by a method interceptor wrapper.
 void bindInterceptor(com.google.inject.matcher.Matcher<? super java.lang.Class<?>> classMatcher, com.google.inject.matcher.Matcher<? super java.lang.reflect.Method> methodMatcher, MethodInterceptorWrapper methodInterceptorWrapper, com.google.inject.Key<?>... methodInterceptorKeys)
          Variant of bindInterceptor that allows constructor-injection of interceptors described by Key, each wrapped by a method interceptor wrapper.
 
Methods inherited from class com.google.inject.AbstractModule
configure
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

bindInterceptor

public void bindInterceptor(com.google.inject.matcher.Matcher<? super java.lang.Class<?>> classMatcher,
                            com.google.inject.matcher.Matcher<? super java.lang.reflect.Method> methodMatcher,
                            org.aopalliance.intercept.MethodInterceptor... methodInterceptors)
Overridden version of bindInterceptor that, in addition to the standard behavior, arranges for field and method injection of each MethodInterceptor in interceptors.

Overrides:
bindInterceptor in class com.google.inject.AbstractModule
Parameters:
classMatcher - matches classes the interception should apply to. For example: only(Runnable.class).
methodMatcher - matches methods the interception should apply to. For example: annotatedWith(Transactional.class).
methodInterceptors - chain of MethodInterceptors used to intercept calls.

bindInterceptor

public void bindInterceptor(com.google.inject.matcher.Matcher<? super java.lang.Class<?>> classMatcher,
                            com.google.inject.matcher.Matcher<? super java.lang.reflect.Method> methodMatcher,
                            java.lang.Class<?>... methodInterceptorClasses)
Variant of bindInterceptor(Class, Class...) that allows constructor-injection of interceptors described by class.

Parameters:
classMatcher - matches classes the interception should apply to. For example: only(Runnable.class).
methodMatcher - matches methods the interception should apply to. For example: annotatedWith(Transactional.class).
methodInterceptorClasses - chain of MethodInterceptors used to intercept calls, specified by class.

bindInterceptor

public void bindInterceptor(com.google.inject.matcher.Matcher<? super java.lang.Class<?>> classMatcher,
                            com.google.inject.matcher.Matcher<? super java.lang.reflect.Method> methodMatcher,
                            com.google.inject.Key<?>... methodInterceptorKeys)
Variant of bindInterceptor that allows constructor-injection of interceptors described by Key.

Parameters:
classMatcher - matches classes the interception should apply to. For example: only(Runnable.class).
methodMatcher - matches methods the interception should apply to. For example: annotatedWith(Transactional.class).
methodInterceptorKeys - chain of MethodInterceptors used to intercept calls, specified by Key.

bindInterceptor

public void bindInterceptor(com.google.inject.matcher.Matcher<? super java.lang.Class<?>> classMatcher,
                            com.google.inject.matcher.Matcher<? super java.lang.reflect.Method> methodMatcher,
                            MethodInterceptorWrapper methodInterceptorWrapper,
                            java.lang.Class<?>... methodInterceptorClasses)
Variant of bindInterceptor that allows constructor-injection of interceptors described by class, each wrapped by a method interceptor wrapper.

Parameters:
classMatcher - matches classes the interception should apply to. For example: only(Runnable.class).
methodMatcher - matches methods the interception should apply to. For example: annotatedWith(Transactional.class).
methodInterceptorWrapper - a wrapper applied to each of the specified interceptors.
methodInterceptorClasses - chain of MethodInterceptors used to intercept calls, specified by class.

bindInterceptor

public void bindInterceptor(com.google.inject.matcher.Matcher<? super java.lang.Class<?>> classMatcher,
                            com.google.inject.matcher.Matcher<? super java.lang.reflect.Method> methodMatcher,
                            MethodInterceptorWrapper methodInterceptorWrapper,
                            com.google.inject.Key<?>... methodInterceptorKeys)
Variant of bindInterceptor that allows constructor-injection of interceptors described by Key, each wrapped by a method interceptor wrapper.

Parameters:
classMatcher - matches classes the interception should apply to. For example: only(Runnable.class).
methodMatcher - matches methods the interception should apply to. For example: annotatedWith(Transactional.class).
methodInterceptorWrapper - a wrapper applied to each of the specified interceptors.
methodInterceptorKeys - chain of MethodInterceptors used to intercept calls, specified by Key.

bindInterceptor

public final void bindInterceptor(java.lang.Class<?> targetType,
                                  java.lang.Class<?>... methodInterceptorClasses)
Variant of bindInterceptor intercepting non-nested calls to instances of a given type (or of a subclass of that type), allowing constructor-injection of interceptors described by class.

Parameters:
targetType - the type for which method calls are to be intercepted
methodInterceptorClasses - chain of MethodInterceptors used to intercept calls, specified by class.

bindInterceptor

public final void bindInterceptor(java.lang.Class<?> targetType,
                                  com.google.inject.Key<?>... methodInterceptorKeys)
Variant of bindInterceptor intercepting non-nested calls to instances of a given type (or of a subclass of that type), allowing constructor-injection of interceptors described by Key.

Parameters:
targetType - the type for which method calls are to be intercepted
methodInterceptorKeys - chain of MethodInterceptors used to intercept calls, specified by Key.

Copyright 2008