Package org.springframework.beans

Examples of org.springframework.beans.MutablePropertyValues


    assertEquals("name2", bw.getPropertyValue("list[0].nestedIndexedBean.list[0].name"));
    assertEquals("name3", bw.getPropertyValue("list[1].nestedIndexedBean.list[1].name"));
    assertEquals("name4", bw.getPropertyValue("map[key1].nestedIndexedBean.map[key1].name"));
    assertEquals("name5", bw.getPropertyValue("map['key2'].nestedIndexedBean.map[\"key2\"].name"));

    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("array[0].nestedIndexedBean.array[0].name", "name5");
    pvs.addPropertyValue("array[1].nestedIndexedBean.array[1].name", "name4");
    pvs.addPropertyValue("list[0].nestedIndexedBean.list[0].name", "name3");
    pvs.addPropertyValue("list[1].nestedIndexedBean.list[1].name", "name2");
    pvs.addPropertyValue("map[key1].nestedIndexedBean.map[\"key1\"].name", "name1");
    pvs.addPropertyValue("map['key2'].nestedIndexedBean.map[key2].name", "name0");
    bw.setPropertyValues(pvs);
    assertEquals("arrayname5", tb0.getNestedIndexedBean().getArray()[0].getName());
    assertEquals("arrayname4", tb1.getNestedIndexedBean().getArray()[1].getName());
    assertEquals("listname3", ((TestBean) tb2.getNestedIndexedBean().getList().get(0)).getName());
    assertEquals("listname2", ((TestBean) tb3.getNestedIndexedBean().getList().get(1)).getName());
View Full Code Here


      public void setAsText(String text) throws IllegalArgumentException {
        setValue("map" + text);
      }
    });

    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("array[0].nestedIndexedBean.array[0].name", "name5");
    pvs.addPropertyValue("array[1].nestedIndexedBean.array[1].name", "name4");
    pvs.addPropertyValue("list[0].nestedIndexedBean.list[0].name", "name3");
    pvs.addPropertyValue("list[1].nestedIndexedBean.list[1].name", "name2");
    pvs.addPropertyValue("map[key1].nestedIndexedBean.map[\"key1\"].name", "name1");
    pvs.addPropertyValue("map['key2'].nestedIndexedBean.map[key2].name", "name0");
    bw.setPropertyValues(pvs);
    assertEquals("arrayname5", tb0.getNestedIndexedBean().getArray()[0].getName());
    assertEquals("name4", tb1.getNestedIndexedBean().getArray()[1].getName());
    assertEquals("name3", ((TestBean) tb2.getNestedIndexedBean().getList().get(0)).getName());
    assertEquals("listname2", ((TestBean) tb3.getNestedIndexedBean().getList().get(1)).getName());
View Full Code Here

      public String getAsText() {
        return ((TestBean) getValue()).getName();
      }
    });

    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("array[0]", "a");
    pvs.addPropertyValue("array[1]", "b");
    pvs.addPropertyValue("list[0]", "c");
    pvs.addPropertyValue("list[1]", "d");
    pvs.addPropertyValue("map[key1]", "e");
    pvs.addPropertyValue("map['key2']", "f");
    bw.setPropertyValues(pvs);
    assertEquals("arraya", bean.getArray()[0].getName());
    assertEquals("arrayb", bean.getArray()[1].getName());
    assertEquals("listc", ((TestBean) bean.getList().get(0)).getName());
    assertEquals("listd", ((TestBean) bean.getList().get(1)).getName());
View Full Code Here

      public String getAsText() {
        return ((TestBean) getValue()).getName();
      }
    });

    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("array[0]", "a");
    pvs.addPropertyValue("array[1]", "b");
    pvs.addPropertyValue("list[0]", "c");
    pvs.addPropertyValue("list[1]", "d");
    pvs.addPropertyValue("map[key1]", "e");
    pvs.addPropertyValue("map['key2']", "f");
    bw.setPropertyValues(pvs);
    assertEquals("array0a", bean.getArray()[0].getName());
    assertEquals("array1b", bean.getArray()[1].getName());
    assertEquals("list0c", ((TestBean) bean.getList().get(0)).getName());
    assertEquals("list1d", ((TestBean) bean.getList().get(1)).getName());
View Full Code Here

    public BeanDefinition parse(Element element, ParserContext parserContext) {
      RootBeanDefinition definition = new RootBeanDefinition();
      definition.setBeanClass(TestBean.class);

      MutablePropertyValues mpvs = new MutablePropertyValues();
      mpvs.addPropertyValue("name", element.getAttribute("name"));
      mpvs.addPropertyValue("age", element.getAttribute("age"));
      definition.setPropertyValues(mpvs);

      parserContext.getRegistry().registerBeanDefinition(element.getAttribute("id"), definition);

      return null;
View Full Code Here

    public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
      Element element = (Element) node;
      BeanDefinition def = definition.getBeanDefinition();

      MutablePropertyValues mpvs = (def.getPropertyValues() == null) ? new MutablePropertyValues() : def.getPropertyValues();
      mpvs.addPropertyValue("name", element.getAttribute("name"));
      mpvs.addPropertyValue("age", element.getAttribute("age"));

      ((AbstractBeanDefinition) def).setPropertyValues(mpvs);
      return definition;
    }
View Full Code Here

  public void testPropertyOverrideConfigurer() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("tb1", TestBean.class);
    ac.registerSingleton("tb2", TestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "tb1.age=99\ntb2.name=test");
    ac.registerSingleton("configurer1", PropertyOverrideConfigurer.class, pvs);
    pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "tb2.age=99\ntb2.name=test2");
    pvs.addPropertyValue("order", "0");
    ac.registerSingleton("configurer2", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    TestBean tb1 = (TestBean) ac.getBean("tb1");
    TestBean tb2 = (TestBean) ac.getBean("tb2");
    assertEquals(99, tb1.getAge());
View Full Code Here

  }

  public void testPropertyOverrideConfigurerWithNestedProperty() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "tb.array[0].age=99\ntb.list[1].name=test");
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    IndexedTestBean tb = (IndexedTestBean) ac.getBean("tb");
    assertEquals(99, tb.getArray()[0].getAge());
    assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
View Full Code Here

  }

  public void testPropertyOverrideConfigurerWithNestedPropertyAndDotInBeanName() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("my.tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "my.tb_array[0].age=99\nmy.tb_list[1].name=test");
    pvs.addPropertyValue("beanNameSeparator", "_");
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    IndexedTestBean tb = (IndexedTestBean) ac.getBean("my.tb");
    assertEquals(99, tb.getArray()[0].getAge());
    assertEquals("test", ((TestBean) tb.getList().get(1)).getName());
View Full Code Here

  }

  public void testPropertyOverrideConfigurerWithNestedMapPropertyAndDotInMapKey() {
    StaticApplicationContext ac = new StaticApplicationContext();
    ac.registerSingleton("tb", IndexedTestBean.class);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.addPropertyValue("properties", "tb.map[key1]=99\ntb.map[key2.ext]=test");
    ac.registerSingleton("configurer", PropertyOverrideConfigurer.class, pvs);
    ac.refresh();
    IndexedTestBean tb = (IndexedTestBean) ac.getBean("tb");
    assertEquals("99", tb.getMap().get("key1"));
    assertEquals("test", tb.getMap().get("key2.ext"));
View Full Code Here

TOP

Related Classes of org.springframework.beans.MutablePropertyValues

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.