/** * Add a bean binding configuration to this Collection/array bean binding config. * <p/> * This method checks that this bean's beanClass is a Collection/array, generating an * {@link IllegalArgumentException} if the check fails. * * @param bean The Bean instance to be bound * @return <code>this</code> Bean configuration instance. * @throws IllegalArgumentException <u><code>this</code></u> Bean's beanClass (not the supplied bean!) is * not a Collection/array. You cannot call this method on Bean configurations whose beanClass is not a * Collection/array. For non Collection/array types, you must use one of the bindTo meths that specify a * 'bindingMember'. */ public Bean bindTo(Bean bean) throws IllegalArgumentException { assertNotProcessed(); AssertArgument.isNotNull(bean, "bean"); BeanInstancePopulator beanInstancePopulator = new BeanInstancePopulator(); // Configure the populator visitor... beanInstancePopulator.setBeanId(getBeanId()); beanInstancePopulator.setWireBeanId(bean.getBeanId()); bindings.add(new Binding(createOnElement, beanInstancePopulator, true)); wirings.add(bean); return this; }
AssertArgument.isNotNull(bean, "bean"); BeanInstancePopulator beanInstancePopulator = new BeanInstancePopulator();
BeanInstancePopulator beanInstancePopulator = new BeanInstancePopulator(); SmooksResourceConfiguration populatorConfig = new SmooksResourceConfiguration(dataSelector);
/** * Create a binding configuration to bind the data, selected from the message by the * dataSelector, to the target Collection/array Bean beanclass instance. * * @param dataSelector The data selector for the data value to be bound. * @param dataDecoder The {@link org.dhatim.javabean.DataDecoder} to be used for decoding * the data value. * @return <code>this</code> Bean configuration instance. */ public Bean bindTo(String dataSelector, DataDecoder dataDecoder) { assertNotProcessed(); AssertArgument.isNotNull(dataSelector, "dataSelector"); // dataDecoder can be null BeanInstancePopulator beanInstancePopulator = new BeanInstancePopulator(); SmooksResourceConfiguration populatorConfig = new SmooksResourceConfiguration(dataSelector); SelectorPropertyResolver.resolveSelectorTokens(populatorConfig); // Configure the populator visitor... beanInstancePopulator.setBeanId(getBeanId()); beanInstancePopulator.setValueAttributeName(populatorConfig.getStringParameter(BeanInstancePopulator.VALUE_ATTRIBUTE_NAME)); beanInstancePopulator.setValueAttributePrefix(populatorConfig.getStringParameter(BeanInstancePopulator.VALUE_ATTRIBUTE_PREFIX)); beanInstancePopulator.setDecoder(dataDecoder); bindings.add(new Binding(populatorConfig.getSelector(), beanInstancePopulator, true)); return this; }