Package com.google.inject.internal
Class EncounterImpl<T>
java.lang.Object
com.google.inject.internal.EncounterImpl<T>
- All Implemented Interfaces:
TypeEncounter<T>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<MethodAspect> private final Errorsprivate List<InjectionListener<? super T>> private final Lookupsprivate List<MembersInjector<? super T>> private boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidRecords an error message to be presented to the user at a later time.voidRecords an error message for typeIwhich will be presented to the user at a later time.voidRecords an exception for typeI, the full details of which will be logged, and the message of which will be presented to the user at a later time.voidbindInterceptor(Matcher<? super Method> methodMatcher, org.aopalliance.intercept.MethodInterceptor... interceptors) Binds method interceptor[s] to methods matched in typeIand its supertypes.(package private) com.google.common.collect.ImmutableList<MethodAspect> (package private) com.google.common.collect.ImmutableSet<InjectionListener<? super T>> <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> typeLiteral) Returns the members injector used to inject dependencies into methods and fields on instances of the given typeT.<T> MembersInjector<T> getMembersInjector(Class<T> type) Returns the members injector used to inject dependencies into methods and fields on instances of the given typeT.(package private) com.google.common.collect.ImmutableSet<MembersInjector<? super T>> <T> Provider<T> getProvider(Key<T> key) Returns the provider used to obtain instances for the given injection key.<T> Provider<T> getProvider(Class<T> type) Returns the provider used to obtain instances for the given injection type.(package private) voidvoidregister(MembersInjector<? super T> membersInjector) Registers a members injector for typeI.voidregister(InjectionListener<? super T> injectionListener) Registers an injection listener for typeI.
-
Field Details
-
errors
-
lookups
-
membersInjectors
-
injectionListeners
-
aspects
-
valid
private boolean valid
-
-
Constructor Details
-
EncounterImpl
-
-
Method Details
-
invalidate
void invalidate() -
getAspects
com.google.common.collect.ImmutableList<MethodAspect> getAspects() -
bindInterceptor
public void bindInterceptor(Matcher<? super Method> methodMatcher, org.aopalliance.intercept.MethodInterceptor... interceptors) Description copied from interface:TypeEncounterBinds method interceptor[s] to methods matched in typeIand its supertypes. A method is eligible for interception if:- Guice created the instance the method is on
- Neither the enclosing type nor the method is final
- And the method is package-private or more accessible
- Specified by:
bindInterceptorin interfaceTypeEncounter<T>- Parameters:
methodMatcher- matches methods the interceptor should apply to. For example:annotatedWith(Transactional.class).interceptors- to bind
-
getMembersInjectors
com.google.common.collect.ImmutableSet<MembersInjector<? super T>> getMembersInjectors() -
getInjectionListeners
com.google.common.collect.ImmutableSet<InjectionListener<? super T>> getInjectionListeners() -
register
Description copied from interface:TypeEncounterRegisters a members injector for typeI. Guice will use the members injector after its performed its own injections on an instance ofI.- Specified by:
registerin interfaceTypeEncounter<T>
-
register
Description copied from interface:TypeEncounterRegisters an injection listener for typeI. Guice will notify the listener after all injections have been performed on an instance ofI.- Specified by:
registerin interfaceTypeEncounter<T>
-
addError
Description copied from interface:TypeEncounterRecords an error message for typeIwhich will be presented to the user at a later time. Unlike throwing an exception, this enable us to continue configuring the Injector and discover more errors. UsesString.format(String, Object[])to insert the arguments into the message.- Specified by:
addErrorin interfaceTypeEncounter<T>
-
addError
Description copied from interface:TypeEncounterRecords an exception for typeI, the full details of which will be logged, and the message of which will be presented to the user at a later time. If your type listener calls something that you worry may fail, you should catch the exception and pass it to this method.- Specified by:
addErrorin interfaceTypeEncounter<T>
-
addError
Description copied from interface:TypeEncounterRecords an error message to be presented to the user at a later time.- Specified by:
addErrorin interfaceTypeEncounter<T>
-
getProvider
Description copied from interface:TypeEncounterReturns the provider used to obtain instances for the given injection key. The returned provider will not be valid until the injector has been created. The provider will throw anIllegalStateExceptionif you try to use it beforehand.- Specified by:
getProviderin interfaceTypeEncounter<T>
-
getProvider
Description copied from interface:TypeEncounterReturns the provider used to obtain instances for the given injection type. The returned provider will not be valid until the injector has been created. The provider will throw anIllegalStateExceptionif you try to use it beforehand.- Specified by:
getProviderin interfaceTypeEncounter<T>
-
getMembersInjector
Description copied from interface:TypeEncounterReturns the members injector used to inject dependencies into methods and fields on instances of the given typeT. The returned members injector will not be valid until the main injector has been created. The members injector will throw anIllegalStateExceptionif you try to use it beforehand.- Specified by:
getMembersInjectorin interfaceTypeEncounter<T>- Parameters:
typeLiteral- type to get members injector for
-
getMembersInjector
Description copied from interface:TypeEncounterReturns the members injector used to inject dependencies into methods and fields on instances of the given typeT. The returned members injector will not be valid until the main injector has been created. The members injector will throw anIllegalStateExceptionif you try to use it beforehand.- Specified by:
getMembersInjectorin interfaceTypeEncounter<T>- Parameters:
type- type to get members injector for
-