final class EncounterImpl<T> extends java.lang.Object implements TypeEncounter<T>
| Modifier and Type | Field and Description |
|---|---|
private java.util.List<MethodAspect> |
aspects |
private Errors |
errors |
private java.util.List<InjectionListener<? super T>> |
injectionListeners |
private Lookups |
lookups |
private java.util.List<MembersInjector<? super T>> |
membersInjectors |
private boolean |
valid |
| Constructor and Description |
|---|
EncounterImpl(Errors errors,
Lookups lookups) |
| Modifier and Type | Method and Description |
|---|---|
void |
addError(Message message)
Records an error message to be presented to the user at a later time.
|
void |
addError(java.lang.String message,
java.lang.Object... arguments)
Records an error message for type
I which will be presented to the user at a later
time. |
void |
addError(java.lang.Throwable t)
Records an exception for type
I, the full details of which will be logged, and the
message of which will be presented to the user at a later time. |
void |
bindInterceptor(Matcher<? super java.lang.reflect.Method> methodMatcher,
org.aopalliance.intercept.MethodInterceptor... interceptors)
Binds method interceptor[s] to methods matched in type
I and its supertypes. |
(package private) com.google.common.collect.ImmutableList<MethodAspect> |
getAspects() |
(package private) com.google.common.collect.ImmutableSet<InjectionListener<? super T>> |
getInjectionListeners() |
<T> MembersInjector<T> |
getMembersInjector(java.lang.Class<T> type)
Returns the members injector used to inject dependencies into methods and fields on instances
of the given type
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 type
T. |
(package private) com.google.common.collect.ImmutableSet<MembersInjector<? super T>> |
getMembersInjectors() |
<T> Provider<T> |
getProvider(java.lang.Class<T> type)
Returns the provider used to obtain instances for the given injection type.
|
<T> Provider<T> |
getProvider(Key<T> key)
Returns the provider used to obtain instances for the given injection key.
|
(package private) void |
invalidate() |
void |
register(InjectionListener<? super T> injectionListener)
Registers an injection listener for type
I. |
void |
register(MembersInjector<? super T> membersInjector)
Registers a members injector for type
I. |
private final Errors errors
private final Lookups lookups
private java.util.List<MembersInjector<? super T>> membersInjectors
private java.util.List<InjectionListener<? super T>> injectionListeners
private java.util.List<MethodAspect> aspects
private boolean valid
void invalidate()
com.google.common.collect.ImmutableList<MethodAspect> getAspects()
public void bindInterceptor(Matcher<? super java.lang.reflect.Method> methodMatcher, org.aopalliance.intercept.MethodInterceptor... interceptors)
TypeEncounterI and its supertypes. A
method is eligible for interception if:
bindInterceptor in interface TypeEncounter<T>methodMatcher - matches methods the interceptor should apply to. For
example: annotatedWith(Transactional.class).interceptors - to bindcom.google.common.collect.ImmutableSet<MembersInjector<? super T>> getMembersInjectors()
com.google.common.collect.ImmutableSet<InjectionListener<? super T>> getInjectionListeners()
public void register(MembersInjector<? super T> membersInjector)
TypeEncounterI. Guice will use the members injector after its
performed its own injections on an instance of I.register in interface TypeEncounter<T>public void register(InjectionListener<? super T> injectionListener)
TypeEncounterI. Guice will notify the listener after all
injections have been performed on an instance of I.register in interface TypeEncounter<T>public void addError(java.lang.String message,
java.lang.Object... arguments)
TypeEncounterI which 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. Uses String.format(String, Object[]) to insert the arguments
into the message.addError in interface TypeEncounter<T>public void addError(java.lang.Throwable t)
TypeEncounterI, 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.addError in interface TypeEncounter<T>public void addError(Message message)
TypeEncounteraddError in interface TypeEncounter<T>public <T> Provider<T> getProvider(Key<T> key)
TypeEncounterIllegalStateException if you try to use it beforehand.getProvider in interface TypeEncounter<T>public <T> Provider<T> getProvider(java.lang.Class<T> type)
TypeEncounterIllegalStateException if you try to use it beforehand.getProvider in interface TypeEncounter<T>public <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> typeLiteral)
TypeEncounterT. The returned members injector will not be valid until the main
injector has been created. The members injector will throw an IllegalStateException
if you try to use it beforehand.getMembersInjector in interface TypeEncounter<T>typeLiteral - type to get members injector forpublic <T> MembersInjector<T> getMembersInjector(java.lang.Class<T> type)
TypeEncounterT. The returned members injector will not be valid until the main
injector has been created. The members injector will throw an IllegalStateException
if you try to use it beforehand.getMembersInjector in interface TypeEncounter<T>type - type to get members injector for