if (field != null) {
// for multiplicities, we need to inject the target or targets using an object factory
// which first delegates to create the proxies and then returns them in the appropriate List or array
// type
if (field.getType().isArray()) {
injector = new FieldInjector(field, new ArrayMultiplicityObjectFactory(refClass, objectFactories));
} else {
injector = new FieldInjector(field, new ListMultiplicityObjectFactory(objectFactories));
}
} else {
if (method.getParameterTypes()[0].isArray()) {
injector = new MethodInjector(method, new ArrayMultiplicityObjectFactory(refClass, objectFactories));
} else {
injector = new MethodInjector(method, new ListMultiplicityObjectFactory(objectFactories));
}
}
return injector;
} else {
field = JavaIntrospectionHelper.findClosestMatchingField(refName, refClass, fields);
if (field == null) {
method = JavaIntrospectionHelper.findClosestMatchingMethod(refName, new Class[]{refClass}, methods);
if (method == null) {
throw new NoAccessorException(refName);
}
}
Injector injector;
if (field != null) {
injector = new FieldInjector(field, objectFactories.get(0));
} else {
injector = new MethodInjector(method, objectFactories.get(0));
}
return injector;
}