/** * Set a {@link Map} of direct or indirect properties on the target object. * @param target the target object on which to set the properties. * @param properties a {@link Map} of String/Object pairs. * @throws PropertyException if an error happened while trying to set a property. */ public static void setProperties(Object target, Map<String, Object> properties) throws PropertyException { for (Map.Entry<String, Object> entry : properties.entrySet()) { String name = entry.getKey(); Object value = entry.getValue(); setProperty(target, name, value); } }
/** * Set a {@link Map} of direct or indirect properties on the target object. * @param target the target object on which to set the properties. * @param properties a {@link Map} of String/Object pairs. * @throws PropertyException if an error happened while trying to set a property. */ public static void setProperties(Object target, Map<String, Object> properties) throws PropertyException { for (Map.Entry<String, Object> entry : properties.entrySet()) { String name = entry.getKey(); Object value = entry.getValue(); setProperty(target, name, value); } }
/** * Set a {@link Map} of direct or indirect properties on the target object. * @param target the target object on which to set the properties. * @param properties a {@link Map} of String/Object pairs. * @throws PropertyException if an error happened while trying to set a property. */ public static void setProperties(Object target, Map properties) throws PropertyException { Iterator it = properties.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); setProperty(target, name, value); } }
/** * Set a {@link Map} of direct or indirect properties on the target object. * @param target the target object on which to set the properties. * @param properties a {@link Map} of String/Object pairs. * @throws PropertyException if an error happened while trying to set a property. */ public static void setProperties(Object target, Map properties) throws PropertyException { Iterator it = properties.entrySet().iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); setProperty(target, name, value); } }
private static Object createXAFactory(ResourceBean bean) throws Exception { String className = bean.getClassName(); if (className == null) throw new IllegalArgumentException("className cannot be null"); Class xaFactoryClass = ClassLoaderUtils.loadClass(className); Object xaFactory = xaFactoryClass.newInstance(); for (Map.Entry<Object, Object> entry : bean.getDriverProperties().entrySet()) { String name = (String) entry.getKey(); Object value = entry.getValue(); if (name.endsWith(PASSWORD_PROPERTY_NAME)) { value = decrypt((String) value); } if (log.isDebugEnabled()) log.debug("setting vendor property '" + name + "' to '" + value + "'"); PropertyUtils.setProperty(xaFactory, name, value); } return xaFactory; }
static Object createXAFactory(ResourceBean bean) throws Exception { String className = bean.getClassName(); if (className == null) throw new IllegalArgumentException("className cannot be null"); Class<?> xaFactoryClass = ClassLoaderUtils.loadClass(className); Object xaFactory = xaFactoryClass.newInstance(); for (Map.Entry<Object, Object> entry : bean.getDriverProperties().entrySet()) { String name = (String) entry.getKey(); Object value = entry.getValue(); if (name.endsWith(PASSWORD_PROPERTY_NAME)) { value = decrypt(value.toString()); } if (log.isDebugEnabled()) { log.debug("setting vendor property '" + name + "' to '" + value + "'"); } PropertyUtils.setProperty(xaFactory, name, value); } return xaFactory; }
public void testSettingKeyForPropertiesObject() throws Exception { Properties p = new Properties(); PropertyUtils.setProperty(p, "key", "value"); assertEquals("value", p.getProperty("key")); }
public void testSettingKeyForPropertiesObject() throws Exception { Properties p = new Properties(); PropertyUtils.setProperty(p, "key", "value"); assertEquals("value", p.getProperty("key")); }
public void testSetPropertiesDirectly() throws Exception { Destination destination = new Destination(); Properties p = new Properties(); p.setProperty("key", "value"); PropertyUtils.setProperty(destination, "props", p); assertEquals("value", destination.getProps().getProperty("key")); }
public void testSetClonedPropertiesDirectly() throws Exception { Destination destination = new Destination(); Properties p = new Properties(); p.setProperty("key", "value"); PropertyUtils.setProperty(destination, "clonedProps", p); assertEquals("value", destination.getClonedProps().getProperty("key")); }
public void testSetPropertiesDirectly() throws Exception { Destination destination = new Destination(); Properties p = new Properties(); p.setProperty("key", "value"); PropertyUtils.setProperty(destination, "props", p); assertEquals("value", destination.getProps().getProperty("key")); }
public void testSetClonedPropertiesDirectly() throws Exception { Destination destination = new Destination(); Properties p = new Properties(); p.setProperty("key", "value"); PropertyUtils.setProperty(destination, "clonedProps", p); assertEquals("value", destination.getClonedProps().getProperty("key")); }
public void testSetPropertiesObjectLongKey() throws Exception { PrivateDestination destination = new PrivateDestination(); PropertyUtils.setProperty(destination, "props.key", "value1"); PropertyUtils.setProperty(destination, "props.a.dotted.key", "value2"); assertEquals("value1", destination.getProps().get("key")); assertEquals("value2", destination.getProps().get("a.dotted.key")); }
public void testSetMultipleClonedProperties() throws Exception { Destination destination = new Destination(); PropertyUtils.setProperty(destination, "clonedProps.key1", "value1"); PropertyUtils.setProperty(destination, "clonedProps.key2", "value2"); assertEquals("value1", destination.getClonedProps().getProperty("key1")); assertEquals("value2", destination.getClonedProps().getProperty("key2")); }
public void testSetMultipleProperties() throws Exception { Destination destination = new Destination(); PropertyUtils.setProperty(destination, "props.key1", "value1"); PropertyUtils.setProperty(destination, "props.key2", "value2"); assertEquals("value1", destination.getProps().getProperty("key1")); assertEquals("value2", destination.getProps().getProperty("key2")); }
public void testSetMultipleClonedProperties() throws Exception { Destination destination = new Destination(); PropertyUtils.setProperty(destination, "clonedProps.key1", "value1"); PropertyUtils.setProperty(destination, "clonedProps.key2", "value2"); assertEquals("value1", destination.getClonedProps().getProperty("key1")); assertEquals("value2", destination.getClonedProps().getProperty("key2")); }
public void testSetPropertiesObjectLongKey() throws Exception { PrivateDestination destination = new PrivateDestination(); PropertyUtils.setProperty(destination, "props.key", "value1"); PropertyUtils.setProperty(destination, "props.a.dotted.key", "value2"); assertEquals("value1", destination.getProps().get("key")); assertEquals("value2", destination.getProps().get("a.dotted.key")); }
public void testSetMultipleProperties() throws Exception { Destination destination = new Destination(); PropertyUtils.setProperty(destination, "props.key1", "value1"); PropertyUtils.setProperty(destination, "props.key2", "value2"); assertEquals("value1", destination.getProps().getProperty("key1")); assertEquals("value2", destination.getProps().getProperty("key2")); }
public void testSetClonedProperties() throws Exception { Destination destination = new Destination(); PropertyUtils.setProperty(destination, "clonedProps.key", "value"); assertEquals("value", destination.getClonedProps().getProperty("key")); }
public void testSetClonedProperties() throws Exception { Destination destination = new Destination(); PropertyUtils.setProperty(destination, "clonedProps.key", "value"); assertEquals("value", destination.getClonedProps().getProperty("key")); }