protected void applySingleProperty(Map objects, String name, String property, String value) { Object instance = objects.get(name); if (property.equals("class")) { throw new IllegalArgumentException("Property keys should not contain 'class' properties since these " + "should already be separated out by buildObjects()."); } else if (instance == null) { String msg = "Configuration error. Specified object [" + name + "] with property [" + property + "] without first defining that object's class. Please first " + "specify the class property first, e.g. myObject = fully_qualified_class_name " + "and then define additional properties."; throw new IllegalArgumentException(msg); } else { applyProperty(instance, property, value); } }
@Override protected Object doExecute() { applyProperty(lhs, rhs, objects); Object bean = objects.get(this.rootBeanName); setBean(bean); return null; }
protected void applyGlobalProperty(Map objects, String property, String value) { for (Object instance : objects.values()) { try { PropertyDescriptor pd = beanUtilsBean.getPropertyUtils().getPropertyDescriptor(instance, property); if (pd != null) { applyProperty(instance, property, value); } } catch (Exception e) { String msg = "Error retrieving property descriptor for instance " + "of type [" + instance.getClass().getName() + "] " + "while setting property [" + property + "]"; throw new ConfigurationException(msg, e); } } }
applyProperty(referencedValue, remaining, value);
protected void applyProperty(Object object, String propertyName, String stringValue) { Object value; if (NULL_VALUE_TOKEN.equals(stringValue)) { value = null; } else if (EMPTY_STRING_VALUE_TOKEN.equals(stringValue)) { value = StringUtils.EMPTY_STRING; } else if (isIndexedPropertyAssignment(propertyName)) { String checked = checkForNullOrEmptyLiteral(stringValue); value = resolveValue(checked); } else if (isTypedProperty(object, propertyName, Set.class)) { value = toSet(stringValue); } else if (isTypedProperty(object, propertyName, Map.class)) { value = toMap(stringValue); } else if (isTypedProperty(object, propertyName, List.class)) { value = toList(stringValue); } else if (isTypedProperty(object, propertyName, Collection.class)) { value = toCollection(stringValue); } else if (isTypedProperty(object, propertyName, byte[].class)) { value = toBytes(stringValue); } else if (isTypedProperty(object, propertyName, ByteSource.class)) { byte[] bytes = toBytes(stringValue); value = ByteSource.Util.bytes(bytes); } else { String checked = checkForNullOrEmptyLiteral(stringValue); value = resolveValue(checked); } applyProperty(object, propertyName, value); }
protected void applySingleProperty(Map objects, String name, String property, String value) { Object instance = objects.get(name); if (property.equals("class")) { throw new IllegalArgumentException("Property keys should not contain 'class' properties since these " + "should already be separated out by buildObjects()."); } else if (instance == null) { String msg = "Configuration error. Specified object [" + name + "] with property [" + property + "] without first defining that object's class. Please first " + "specify the class property first, e.g. myObject = fully_qualified_class_name " + "and then define additional properties."; throw new IllegalArgumentException(msg); } else { applyProperty(instance, property, value); } }
protected void applySingleProperty(Map objects, String name, String property, String value) { Object instance = objects.get(name); if (property.equals("class")) { throw new IllegalArgumentException("Property keys should not contain 'class' properties since these " + "should already be separated out by buildObjects()."); } else if (instance == null) { String msg = "Configuration error. Specified object [" + name + "] with property [" + property + "] without first defining that object's class. Please first " + "specify the class property first, e.g. myObject = fully_qualified_class_name " + "and then define additional properties."; throw new IllegalArgumentException(msg); } else { applyProperty(instance, property, value); } }
@Override protected Object doExecute() { applyProperty(lhs, rhs, objects); Object bean = objects.get(this.rootBeanName); setBean(bean); return null; }
protected void applyGlobalProperty(Map objects, String property, String value) { for (Object instance : objects.values()) { try { PropertyDescriptor pd = PropertyUtils.getPropertyDescriptor(instance, property); if (pd != null) { applyProperty(instance, property, value); } } catch (Exception e) { String msg = "Error retrieving property descriptor for instance " + "of type [" + instance.getClass().getName() + "] " + "while setting property [" + property + "]"; throw new ConfigurationException(msg, e); } } }
@SuppressWarnings({"unchecked"}) public Map<String, ?> buildObjects(Map<String, String> kvPairs) { if (kvPairs != null && !kvPairs.isEmpty()) { // Separate key value pairs into object declarations and property assignment // so that all objects can be created up front //https://issues.apache.org/jira/browse/SHIRO-85 - need to use LinkedHashMaps here: Map<String, String> instanceMap = new LinkedHashMap<String, String>(); Map<String, String> propertyMap = new LinkedHashMap<String, String>(); for (Map.Entry<String, String> entry : kvPairs.entrySet()) { if (entry.getKey().indexOf('.') < 0 || entry.getKey().endsWith(".class")) { instanceMap.put(entry.getKey(), entry.getValue()); } else { propertyMap.put(entry.getKey(), entry.getValue()); } } // Create all instances for (Map.Entry<String, String> entry : instanceMap.entrySet()) { createNewInstance((Map<String, Object>) objects, entry.getKey(), entry.getValue()); } // Set all properties for (Map.Entry<String, String> entry : propertyMap.entrySet()) { applyProperty(entry.getKey(), entry.getValue(), objects); } } return objects; }
protected void applyGlobalProperty(Map objects, String property, String value) { for (Object instance : objects.values()) { try { PropertyDescriptor pd = beanUtilsBean.getPropertyUtils().getPropertyDescriptor(instance, property); if (pd != null) { applyProperty(instance, property, value); } } catch (Exception e) { String msg = "Error retrieving property descriptor for instance " + "of type [" + instance.getClass().getName() + "] " + "while setting property [" + property + "]"; throw new ConfigurationException(msg, e); } } }
applyProperty(referencedValue, remaining, value);
protected void applyProperty(Object object, String propertyName, String stringValue) { Object value; if (NULL_VALUE_TOKEN.equals(stringValue)) { value = null; } else if (EMPTY_STRING_VALUE_TOKEN.equals(stringValue)) { value = StringUtils.EMPTY_STRING; } else if (isIndexedPropertyAssignment(propertyName)) { String checked = checkForNullOrEmptyLiteral(stringValue); value = resolveValue(checked); } else if (isTypedProperty(object, propertyName, Set.class)) { value = toSet(stringValue); } else if (isTypedProperty(object, propertyName, Map.class)) { value = toMap(stringValue); } else if (isTypedProperty(object, propertyName, List.class)) { value = toList(stringValue); } else if (isTypedProperty(object, propertyName, Collection.class)) { value = toCollection(stringValue); } else if (isTypedProperty(object, propertyName, byte[].class)) { value = toBytes(stringValue); } else if (isTypedProperty(object, propertyName, ByteSource.class)) { byte[] bytes = toBytes(stringValue); value = ByteSource.Util.bytes(bytes); } else { String checked = checkForNullOrEmptyLiteral(stringValue); value = resolveValue(checked); } applyProperty(object, propertyName, value); }