public boolean isCollection() { BeanRuntimeInfo.Classification classification = creator.getBeanRuntimeInfo().getClassification(); return (classification == Classification.COLLECTION_COLLECTION || classification == Classification.ARRAY_COLLECTION); }
public Class<?> getBeanClass() { return creator.getBeanRuntimeInfo().getPopulateType(); }
private void decodeAndSetPropertyValue(String mapPropertyName, Object dataObject, ExecutionContext executionContext, Fragment source) { if(dataObject instanceof String) { setPropertyValue(mapPropertyName, decodeDataString((String) dataObject, executionContext), executionContext, source); } else { setPropertyValue(mapPropertyName, dataObject, executionContext, source); } }
private Object decodeDataString(String dataString, ExecutionContext executionContext) throws DataDecodeException { if((dataString == null || dataString.length() == 0) && defaultValue != null) { if(defaultValue.equals("null")) { return null; } dataString = defaultValue; } try { return getDecoder(executionContext).decode(dataString); } catch(DataDecodeException e) { throw new DataDecodeException("Failed to decode the value '" + dataString + "' for the bean id '" + beanIdName +"'.", e); } }
private DataDecoder resolveDecoderReflectively() throws DataDecodeException { Class<?> bindType = resolveBindTypeReflectively(); if(bindType != null) { DataDecoder resolvedDecoder = DataDecoder.Factory.create(bindType); if(resolvedDecoder != null) { return resolvedDecoder; } } return new StringDecoder(); }
/** * 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."); } }
/** * Create a Bean binding configuration. * * @param beanClass The bean runtime class. * @param beanId The bean ID. * @param createOnElement The element selector used to create the bean instance. * @param createOnElementNS The namespace for the element selector used to create the bean instance. */ public static Bean newBean(Class<?> beanClass, String beanId, String createOnElement, String createOnElementNS) { return new Bean(beanClass, beanId, createOnElement, createOnElementNS); }
/** * 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. * @return <code>this</code> Bean configuration instance. */ public Bean bindTo(String dataSelector) { return bindTo(dataSelector, (DataDecoder) null); }
/** * Set the binding value data type. * @param type The data type. * * @return <code>this</code> Value configuration instance. */ public Value setType(Class<?> type) { this.decoder = DataDecoder.Factory.create(type); return this; }
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 BeanRuntimeInfo getWiredBeanRuntimeInfo() { if(wiredBeanRuntimeInfo == null) { // Don't need to synchronize this. Worse thing that can happen is we initialize it // more than once... no biggie... wiredBeanRuntimeInfo = BeanRuntimeInfo.getBeanRuntimeInfo(wireBeanIdName, appContext); } return wiredBeanRuntimeInfo; }
/** * {@link FreeMarkerTemplate} data decoder impl. * * @author <a href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a> */ @DecodeType(FreeMarkerTemplate.class) public class FreeMarkerTemplateDecoder implements DataDecoder { public Object decode(String data) throws DataDecodeException { return new FreeMarkerTemplate(data); } }
/** * Create the bean setter method instance for this visitor. * * @param setterName The setter method name. * @return The bean setter method. */ private synchronized Method createPropertySetterMethod(Object bean, String setterName, Class<?> setterParamType) { if (propertySetterMethod == null) { propertySetterMethod = BeanUtils.createSetterMethod(setterName, bean, setterParamType); } return propertySetterMethod; }
public WiredBinding(BeanInstancePopulator populator) { super(populator); this.wiredBeanId = populator.getWireBeanId(); }
public Bean(BeanInstanceCreator creator) { this.creator = creator; this.beanId = creator.getBeanId(); }
@Override public String toString() { return getId(); }
public Binding(BeanInstancePopulator populator) { this.populator = populator; this.property = populator.getProperty(); }
/** * Create a Bean binding configuration. * * @param beanClass The bean runtime class. * @param beanId The bean ID. * @param createOnElement The element selector used to create the bean instance. * @param createOnElementNS The namespace for the element selector used to create the bean instance. * @param factory The factory that will create the runtime object */ public static <T> Bean newBean(Class<T> beanClass, String beanId, String createOnElement, String createOnElementNS, Factory<T> factory) { return new Bean(beanClass, beanId, createOnElement, createOnElementNS, factory); }
private BeanRuntimeInfo getWiredBeanRuntimeInfo() { if(wiredBeanRuntimeInfo == null) { // Don't need to synchronize this. Worse thing that can happen is we initialize it // more than once... wiredBeanRuntimeInfo = BeanRuntimeInfo.getBeanRuntimeInfo(wireBeanIdName, appContext); } return wiredBeanRuntimeInfo; }
/** * {@link MVELExpressionEvaluator} data decoder impl. * * @author <a href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a> */ @DecodeType(MVELExpressionEvaluator.class) public class MVELExpressionEvaluatorDecoder implements DataDecoder { public Object decode(String data) throws DataDecodeException { MVELExpressionEvaluator expressionEvaluator = new MVELExpressionEvaluator(); expressionEvaluator.setExpression(data); return expressionEvaluator; } }