public Object endElement(Object object, QName qName, ElementBinding elementBinding) { AbstractBeanMetaData beanMetaData = (AbstractBeanMetaData) object; ConstructorMetaData constructor = beanMetaData.getConstructor(); if (constructor != null) { List<ParameterMetaData> parameters = constructor.getParameters(); if (parameters != null && parameters.size() > 1) { orderParameters(parameters); } } return beanMetaData; }
/** * Check constructor factory class. * * @param constructor the constructor meta data */ protected void checkConstructorFactoryClass(ConstructorMetaData constructor) { if (constructor == null) return; if (constructor.getFactoryMethod() == null) return; if (constructor.getFactoryClass() != null) return; if (constructor.getValue() != null) return; if (constructor.getFactory() != null) return; if (constructor instanceof AbstractConstructorMetaData == false) return; AbstractConstructorMetaData acmd = AbstractConstructorMetaData.class.cast(constructor); acmd.setFactoryClass(getBean()); }
if (constructor == null) throw new IllegalArgumentException("BeanFactory should have a class attribute or a constructor element."); if (constructor.getFactoryMethod() == null) throw new IllegalArgumentException("BeanFactory should have a class attribute or the constructor element should have a factoryMethod attribute."); if (constructor.getFactory() == null && constructor.getFactoryClass() == null) throw new IllegalArgumentException("BeanFactory should have a class attribute or the constructor element should have a either a factoryClass attribute or a factory element.");
ValueMetaData vmd = metaData.getValue(); if (vmd != null) vmd = metaData.getFactory(); if (vmd != null) List<ParameterMetaData> parameters = metaData.getParameters(); MethodJoinpoint joinPoint = findMethod(trace, factoryInfo, cl, metaData.getFactoryMethod(), parameters, false, true); joinPoint.setTarget(factory); MethodInfo minfo = joinPoint.getMethodInfo(); String factoryClassName = metaData.getFactoryClass(); if (factoryClassName != null) List<ParameterMetaData> parameters = metaData.getParameters(); MethodJoinpoint joinPoint = findMethod(trace, factoryInfo, cl, metaData.getFactoryMethod(), parameters, true, true); MethodInfo minfo = joinPoint.getMethodInfo(); Object[] params = getParameters(trace, cl, pinfos, metaData.getParameters()); joinPoint.setArguments(params);
/** * Resolve a constructor * * @param trace whether trace is enabled * @param info the bean info * @param metaData the constructor metadata * @return the constructor info */ public static ConstructorInfo resolveConstructor(boolean trace, BeanInfo info, ConstructorMetaData metaData) { if (info == null) throw new IllegalArgumentException("Null bean info"); List<ParameterMetaData> params = Collections.emptyList(); if (metaData != null && metaData.getParameters() != null) params = metaData.getParameters(); String[] paramTypes = new String[params.size()]; if (params.isEmpty() == false) { int x = 0; for (Iterator<ParameterMetaData> i = params.iterator(); i.hasNext();) { ParameterMetaData pdata = i.next(); paramTypes[x++] = pdata.getType(); } } return findConstructorInfo(info.getClassInfo(), paramTypes); }
if (constructor.getFactoryMethod() == null) if (constructor.getValue() == null) throw new IllegalArgumentException("Bean should have a class attribute or the constructor element should have either a factoryMethod attribute or embedded value."); else if (constructor.getFactory() == null && constructor.getFactoryClass() == null) throw new IllegalArgumentException("Bean should have a class attribute or the constructor element should have one of a factoryClass attribute or a factory element, or embedded value.");