if (factory != null || factoryClassName != null)
{
KernelControllerContext context = visitor.getControllerContext();
ClassLoader cl = Configurator.getClassLoader(context.getBeanMetaData());
KernelConfigurator configurator = context.getKernel().getConfigurator();
ClassInfo classInfo;
if (factory != null)
{
Object target = factory.getValue(null, cl);
classInfo = configurator.getClassInfo(target.getClass());
}
else
{
classInfo = configurator.getClassInfo(factoryClassName, cl);
}
// should be parameter
if (previous instanceof ParameterMetaData == false)
throw new IllegalArgumentException("Previous node is not ParameterMetaData as expected: " + previous);
ParameterMetaData parameter = (ParameterMetaData) previous;
String[] parameterTypes = Configurator.getParameterTypes(false, parameters);
MethodInfo methodInfo = Configurator.findMethodInfo(classInfo, factoryMethod, parameterTypes, factoryClassName != null, true);
return applyCollectionOrMapCheck(methodInfo.getParameterTypes()[parameter.getIndex()]);
}
else
{
KernelControllerContext context = visitor.getControllerContext();
BeanInfo beanInfo = context.getBeanInfo();
// find matching parameter
if (previous instanceof ParameterMetaData)
{
ParameterMetaData parameter = (ParameterMetaData) previous;
String[] paramTypes = Configurator.getParameterTypes(false, parameters);
ConstructorInfo ci = Configurator.findConstructorInfo(beanInfo.getClassInfo(), paramTypes);
return applyCollectionOrMapCheck(ci.getParameterTypes()[parameter.getIndex()]);
}
else
{
// currently value constructor supports only values that are instances of class itself
// this will add another instance with the same class to context
ClassInfo type = beanInfo.getClassInfo();
log.debug("Constructing bean from injection value: results in multiple beans with same class type - " + type);
return type;
}
}
}