public boolean isCollection() { BeanRuntimeInfo.Classification classification = creator.getBeanRuntimeInfo().getClassification(); return (classification == Classification.COLLECTION_COLLECTION || classification == Classification.ARRAY_COLLECTION); }
public boolean isCollection() { BeanRuntimeInfo.Classification classification = creator.getBeanRuntimeInfo().getClassification(); return (classification == Classification.COLLECTION_COLLECTION || classification == Classification.ARRAY_COLLECTION); }
public boolean isCollection() { BeanRuntimeInfo.Classification classification = creator.getBeanRuntimeInfo().getClassification(); return (classification == Classification.COLLECTION_COLLECTION || classification == Classification.ARRAY_COLLECTION); }
/** * Assert that the beanClass associated with this configuration is an array or Collection. */ private void assertBeanClassIsCollection() { BeanRuntimeInfo beanRuntimeInfo = beanInstanceCreator.getBeanRuntimeInfo(); if (beanRuntimeInfo.getClassification() != BeanRuntimeInfo.Classification.COLLECTION_COLLECTION && beanRuntimeInfo.getClassification() != BeanRuntimeInfo.Classification.ARRAY_COLLECTION) { throw new IllegalArgumentException("Invalid call to a Collection/array Bean.bindTo method for a non Collection/Array target. Binding target type '" + beanRuntimeInfo.getPopulateType().getName() + "' (beanId '" + getBeanId() + "'). Use one of the Bean.bindTo methods that specify a 'bindingMember' argument."); } }
/** * Assert that the beanClass associated with this configuration is an array or Collection. */ private void assertBeanClassIsCollection() { BeanRuntimeInfo beanRuntimeInfo = beanInstanceCreator.getBeanRuntimeInfo(); if (beanRuntimeInfo.getClassification() != BeanRuntimeInfo.Classification.COLLECTION_COLLECTION && beanRuntimeInfo.getClassification() != BeanRuntimeInfo.Classification.ARRAY_COLLECTION) { throw new IllegalArgumentException("Invalid call to a Collection/array Bean.bindTo method for a non Collection/Array target. Binding target type '" + beanRuntimeInfo.getPopulateType().getName() + "' (beanId '" + getBeanId() + "'). Use one of the Bean.bindTo methods that specify a 'bindingMember' argument."); } }
/** * Assert that the beanClass associated with this configuration is an array or Collection. */ private void assertBeanClassIsCollection() { BeanRuntimeInfo beanRuntimeInfo = beanInstanceCreator.getBeanRuntimeInfo(); if (beanRuntimeInfo.getClassification() != BeanRuntimeInfo.Classification.COLLECTION_COLLECTION && beanRuntimeInfo.getClassification() != BeanRuntimeInfo.Classification.ARRAY_COLLECTION) { throw new IllegalArgumentException("Invalid call to a Collection/array Bean.bindTo method for a non Collection/Array target. Binding target type '" + beanRuntimeInfo.getPopulateType().getName() + "' (beanId '" + getBeanId() + "'). Use one of the Bean.bindTo methods that specify a 'bindingMember' argument."); } }
private Class<?> resolveBindTypeReflectively() throws DataDecodeException { String bindingMember = (setterMethod != null? setterMethod : property); if(bindingMember != null && beanRuntimeInfo.getClassification() == Classification.NON_COLLECTION) { Method bindingMethod = Bean.getBindingMethod(bindingMember, beanRuntimeInfo.getPopulateType()); if(bindingMethod != null) { return bindingMethod.getParameterTypes()[0]; } } return null; }
private Class<?> resolveBindTypeReflectively() throws DataDecodeException { String bindingMember = (setterMethod != null? setterMethod : property); if(bindingMember != null && beanRuntimeInfo.getClassification() == Classification.NON_COLLECTION) { Method bindingMethod = Bean.getBindingMethod(bindingMember, beanRuntimeInfo.getPopulateType()); if(bindingMethod != null) { return bindingMethod.getParameterTypes()[0]; } } return null; }
private Class<?> resolveBindTypeReflectively() throws DataDecodeException { String bindingMember = (setterMethod != null? setterMethod : property); if(bindingMember != null && beanRuntimeInfo.getClassification() == Classification.NON_COLLECTION) { Method bindingMethod = Bean.getBindingMethod(bindingMember, beanRuntimeInfo.getPopulateType()); if(bindingMethod != null) { return bindingMethod.getParameterTypes()[0]; } } return null; }
public void visitAfter(ExecutionContext executionContext, Fragment source) { Classification thisBeanType = beanRuntimeInfo.getClassification(); boolean isBeanTypeArray = (thisBeanType == Classification.ARRAY_COLLECTION); BeanContext beanContext = executionContext.getBeanContext(); beanContext.setBeanInContext(beanId, false); if(isBeanTypeArray) { Object bean = beanContext.getBean(beanId); if(logger.isDebugEnabled()) { logger.debug("Converting bean [" + beanIdName + "] to an array and rebinding to context."); } bean = convert(executionContext, bean, source); } }
public void visitAfter(ExecutionContext executionContext, Fragment source) { Classification thisBeanType = beanRuntimeInfo.getClassification(); boolean isBeanTypeArray = (thisBeanType == Classification.ARRAY_COLLECTION); BeanContext beanContext = executionContext.getBeanContext(); beanContext.setBeanInContext(beanId, false); if(isBeanTypeArray) { Object bean = beanContext.getBean(beanId); if(logger.isDebugEnabled()) { logger.debug("Converting bean [" + beanIdName + "] to an array and rebinding to context."); } bean = convert(executionContext, bean, source); } }
public void visitAfter(ExecutionContext executionContext, Fragment source) { Classification thisBeanType = beanRuntimeInfo.getClassification(); boolean isBeanTypeArray = (thisBeanType == Classification.ARRAY_COLLECTION); BeanContext beanContext = executionContext.getBeanContext(); beanContext.setBeanInContext(beanId, false); if(isBeanTypeArray) { Object bean = beanContext.getBean(beanId); if(logger.isDebugEnabled()) { logger.debug("Converting bean [" + beanIdName + "] to an array and rebinding to context."); } bean = convert(executionContext, bean, source); } }
@Override public boolean equals(Object obj) { if(obj == null) { return false; } if(obj == this) { return true; } if(!(obj instanceof BeanRuntimeInfo)) { return false; } BeanRuntimeInfo beanInfo = (BeanRuntimeInfo) obj; if(beanInfo.getArrayType() != getArrayType()) { return false; } if(beanInfo.getClassification() != getClassification()) { return false; } if(beanInfo.getPopulateType() != getPopulateType()) { return false; } return true; }
@Override public boolean equals(Object obj) { if(obj == null) { return false; } if(obj == this) { return true; } if(!(obj instanceof BeanRuntimeInfo)) { return false; } BeanRuntimeInfo beanInfo = (BeanRuntimeInfo) obj; if(beanInfo.getArrayType() != getArrayType()) { return false; } if(beanInfo.getClassification() != getClassification()) { return false; } if(beanInfo.getPopulateType() != getPopulateType()) { return false; } return true; }
@Override public boolean equals(Object obj) { if(obj == null) { return false; } if(obj == this) { return true; } if(!(obj instanceof BeanRuntimeInfo)) { return false; } BeanRuntimeInfo beanInfo = (BeanRuntimeInfo) obj; if(beanInfo.getArrayType() != getArrayType()) { return false; } if(beanInfo.getClassification() != getClassification()) { return false; } if(beanInfo.getPopulateType() != getPopulateType()) { return false; } return true; }
public void populateAndSetPropertyValue(Object bean, BeanContext beanContext, BeanId targetBeanId, final ExecutionContext executionContext, Fragment source) { BeanRuntimeInfo wiredBeanRI = getWiredBeanRuntimeInfo(); // When this observer is triggered then we look if we got something we can set immediately or that we got an array collection. // For an array collection, we need the array representation and not the list representation, so we register and observer that // listens for the change from the list to the array... if(wiredBeanRI != null && wiredBeanRI.getClassification() == Classification.ARRAY_COLLECTION ) { if(logger.isDebugEnabled()) { logger.debug("Registering bean CHANGE wiring observer for wiring bean '" + targetBeanId + "' onto target bean '" + beanId.getName() + "' after it has been converted from a List to an array."); } // Register an observer which looks for the change that the mutable list of the selected bean gets converted to an array. We // can then set this array beanContext.addObserver(listToArrayChangeObserver); } else { setPropertyValue(property, bean, executionContext, source); } }
public void populateAndSetPropertyValue(Object bean, BeanContext beanContext, BeanId targetBeanId, final ExecutionContext executionContext, Fragment source) { BeanRuntimeInfo wiredBeanRI = getWiredBeanRuntimeInfo(); // When this observer is triggered then we look if we got something we can set immediately or that we got an array collection. // For an array collection, we need the array representation and not the list representation, so we register and observer that // listens for the change from the list to the array... if(wiredBeanRI != null && wiredBeanRI.getClassification() == Classification.ARRAY_COLLECTION ) { if(logger.isDebugEnabled()) { logger.debug("Registering bean CHANGE wiring observer for wiring bean '" + targetBeanId + "' onto target bean '" + beanId.getName() + "' after it has been converted from a List to an array."); } // Register an observer which looks for the change that the mutable list of the selected bean gets converted to an array. We // can then set this array beanContext.addObserver(listToArrayChangeObserver); } else { setPropertyValue(property, bean, executionContext, source); } }
public void populateAndSetPropertyValue(Object bean, BeanContext beanContext, BeanId targetBeanId, final ExecutionContext executionContext, Fragment source) { BeanRuntimeInfo wiredBeanRI = getWiredBeanRuntimeInfo(); // When this observer is triggered then we look if we got something we can set immediately or that we got an array collection. // For an array collection, we need the array representation and not the list representation, so we register and observer that // listens for the change from the list to the array... if(wiredBeanRI != null && wiredBeanRI.getClassification() == Classification.ARRAY_COLLECTION ) { if(logger.isDebugEnabled()) { logger.debug("Registering bean CHANGE wiring observer for wiring bean '" + targetBeanId + "' onto target bean '" + beanId.getName() + "' after it has been converted from a List to an array."); } // Register an observer which looks for the change that the mutable list of the selected bean gets converted to an array. We // can then set this array beanContext.addObserver(listToArrayChangeObserver); } else { setPropertyValue(property, bean, executionContext, source); } }
Classification beanType = beanRuntimeInfo.getClassification(); boolean throwException = true; if (beanRuntimeInfo.isJAXBType() && getWiredBeanRuntimeInfo().getClassification() != BeanRuntimeInfo.Classification.NON_COLLECTION) {
public void onBeanLifecycleEvent(BeanContextLifecycleEvent event) { if(event.getBean() == watchedBean) { switch(event.getLifecycle()) { case ADD: if (wiredBeanRI != null && wiredBeanRI.getClassification() == Classification.ARRAY_COLLECTION) { // Register an observer which looks for the change that the mutable // list of the selected bean gets converted to an array. We // can then set this array arrayToListChangeObserver = new ArrayToListChangeObserver(); event.getExecutionContext().getBeanContext().addObserver(arrayToListChangeObserver); } else { populator.populateAndSetPropertyValue(event.getBean(), event.getExecutionContext()); } case REMOVE: try{ if(arrayToListChangeObserver != null) { event.getExecutionContext().getBeanContext().removeObserver(arrayToListChangeObserver); } } finally { event.getExecutionContext().getBeanContext().removeObserver(this); } } } }