use of com.google.inject.spi.TypeListenerBinding in project guice by google.
the class MembersInjectorStore method createWithListeners.
/** Creates a new members injector and attaches both injection listeners and method aspects. */
private <T> MembersInjectorImpl<T> createWithListeners(TypeLiteral<T> type, Errors errors) throws ErrorsException {
int numErrorsBefore = errors.size();
Set<InjectionPoint> injectionPoints;
try {
injectionPoints = InjectionPoint.forInstanceMethodsAndFields(type);
} catch (ConfigurationException e) {
errors.merge(e.getErrorMessages());
injectionPoints = e.getPartialValue();
}
ImmutableList<SingleMemberInjector> injectors = getInjectors(injectionPoints, errors);
errors.throwIfNewErrors(numErrorsBefore);
EncounterImpl<T> encounter = new EncounterImpl<T>(errors, injector.lookups);
Set<TypeListener> alreadySeenListeners = Sets.newHashSet();
for (TypeListenerBinding binding : typeListenerBindings) {
TypeListener typeListener = binding.getListener();
if (!alreadySeenListeners.contains(typeListener) && binding.getTypeMatcher().matches(type)) {
alreadySeenListeners.add(typeListener);
try {
typeListener.hear(type, encounter);
} catch (RuntimeException e) {
errors.errorNotifyingTypeListener(binding, type, e);
}
}
}
encounter.invalidate();
errors.throwIfNewErrors(numErrorsBefore);
return new MembersInjectorImpl<T>(injector, type, encounter, injectors);
}
use of com.google.inject.spi.TypeListenerBinding in project roboguice by roboguice.
the class MembersInjectorStore method createWithListeners.
/**
* Creates a new members injector and attaches both injection listeners and method aspects.
*/
private <T> MembersInjectorImpl<T> createWithListeners(TypeLiteral<T> type, Errors errors) throws ErrorsException {
int numErrorsBefore = errors.size();
Set<InjectionPoint> injectionPoints;
try {
injectionPoints = InjectionPoint.forInstanceMethodsAndFields(type);
} catch (ConfigurationException e) {
errors.merge(e.getErrorMessages());
injectionPoints = e.getPartialValue();
}
ImmutableList<SingleMemberInjector> injectors = getInjectors(injectionPoints, errors);
errors.throwIfNewErrors(numErrorsBefore);
EncounterImpl<T> encounter = new EncounterImpl<T>(errors, injector.lookups);
Set<TypeListener> alreadySeenListeners = Sets.newHashSet();
for (TypeListenerBinding binding : typeListenerBindings) {
TypeListener typeListener = binding.getListener();
if (!alreadySeenListeners.contains(typeListener) && binding.getTypeMatcher().matches(type)) {
alreadySeenListeners.add(typeListener);
try {
typeListener.hear(type, encounter);
} catch (RuntimeException e) {
errors.errorNotifyingTypeListener(binding, type, e);
}
}
}
encounter.invalidate();
errors.throwIfNewErrors(numErrorsBefore);
return new MembersInjectorImpl<T>(injector, type, encounter, injectors);
}
Aggregations