}
try {
method.setAccessible(true);
method.invoke(injectee, values);
} catch (IllegalAccessException e) {
throw new ProvisionException(
"Failed to inject method " + method
+ ". Reason: " + e, e);
} catch (InvocationTargetException ie) {
Throwable e = ie.getTargetException();
throw new ProvisionException(
"Failed to inject method " + method
+ ". Reason: " + e, e);
}
}
});
}
}
protected <I> void bindAnnotationInjectorToField(
final TypeEncounter<I> encounter,
final TypeLiteral<?> type, final Field field) {
// TODO lets exclude fields with @Inject?
final A annotation = field.getAnnotation(annotationType);
if (annotation != null) {
if (providerProvider == null) {
providerProvider = memberProviderProvider
.get(encounter);
}
encounter.register(new InjectionListener<I>() {
public void afterInjection(I injectee) {
AnnotationMemberProvider provider = providerProvider
.get();
Object value = provider.provide(annotation, type,
field);
checkInjectedValueType(value, field.getType(),
encounter);
try {
field.setAccessible(true);
field.set(injectee, value);
} catch (IllegalAccessException e) {
throw new ProvisionException(
"Failed to inject field " + field
+ ". Reason: " + e, e);
}
}
});