Package org.springframework.beans.factory.support

Examples of org.springframework.beans.factory.support.ChildBeanDefinition


            }
            if(StringUtils.isBlank(parentName)) {
                bd = new RootBeanDefinition(clazz,cav,null);
            }
            else {
                bd = new ChildBeanDefinition(parentName,clazz,cav, null);
            }
            bd.setSingleton(singleton);
    }
    else {
            if(StringUtils.isBlank(parentName)) {
                bd = new RootBeanDefinition(clazz,singleton);
            }
            else {
                bd = new ChildBeanDefinition(parentName,clazz, null,null);
                bd.setSingleton(singleton);
            }

    }
    wrapper = new BeanWrapperImpl(bd);
View Full Code Here


      MutablePropertyValues pvs2 = new MutablePropertyValues();
      pvs2.addPropertyValue("name", "name${var}${var}${");
      pvs2.addPropertyValue("spouse", new RuntimeBeanReference("${ref}"));

      RootBeanDefinition parent = new RootBeanDefinition(TestBean.class, pvs1);
      ChildBeanDefinition bd = new ChildBeanDefinition("${parent}", pvs2);
      ac.getDefaultListableBeanFactory().registerBeanDefinition("parent1", parent);
      ac.getDefaultListableBeanFactory().registerBeanDefinition("tb1", bd);
    }
    else {
      MutablePropertyValues pvs = new MutablePropertyValues();
      pvs.addPropertyValue("age", "${age}");
      pvs.addPropertyValue("name", "name${var}${var}${");
      pvs.addPropertyValue("spouse", new RuntimeBeanReference("${ref}"));
      RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, pvs);
      ac.getDefaultListableBeanFactory().registerBeanDefinition("tb1", bd);
    }

    ConstructorArgumentValues cas = new ConstructorArgumentValues();
    cas.addIndexedArgumentValue(1, "${age}");
    cas.addGenericArgumentValue("${var}name${age}");

    MutablePropertyValues pvs = new MutablePropertyValues();
    List friends = new ManagedList();
    friends.add("na${age}me");
    friends.add(new RuntimeBeanReference("${ref}"));
    pvs.addPropertyValue("friends", friends);

    Set someSet = new ManagedSet();
    someSet.add("na${age}me");
    someSet.add(new RuntimeBeanReference("${ref}"));
    someSet.add(new TypedStringValue("${age}", Integer.class));
    pvs.addPropertyValue("someSet", someSet);

    Map someMap = new ManagedMap();
    someMap.put(new TypedStringValue("key${age}"), new TypedStringValue("${age}"));
    someMap.put(new TypedStringValue("key${age}ref"), new RuntimeBeanReference("${ref}"));
    someMap.put("key1", new RuntimeBeanReference("${ref}"));
    someMap.put("key2", "${age}name");
    MutablePropertyValues innerPvs = new MutablePropertyValues();
    innerPvs.addPropertyValue("touchy", "${os.name}");
    someMap.put("key3", new RootBeanDefinition(TestBean.class, innerPvs));
    MutablePropertyValues innerPvs2 = new MutablePropertyValues(innerPvs);
    someMap.put("${key4}", new BeanDefinitionHolder(new ChildBeanDefinition("tb1", innerPvs2), "child"));
    pvs.addPropertyValue("someMap", someMap);

    RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, cas, pvs);
    ac.getDefaultListableBeanFactory().registerBeanDefinition("tb2", bd);
View Full Code Here

    RootBeanDefinition parentDefinition = new RootBeanDefinition(TestBean.class);
    parentDefinition.setAbstract(true);
    parentDefinition.getPropertyValues().addPropertyValue("name", EXPECTED_NAME);
    parentDefinition.getPropertyValues().addPropertyValue("age", new Integer(EXPECTED_AGE));

    ChildBeanDefinition childDefinition = new ChildBeanDefinition("alias");

    DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
    factory.registerBeanDefinition("parent", parentDefinition);
    factory.registerBeanDefinition("child", childDefinition);
    factory.registerAlias("parent", "alias");
View Full Code Here

  public void testImplicitScopeInheritanceForChildBeanDefinitions() throws Exception {
    RootBeanDefinition parent = new RootBeanDefinition();
    parent.setScope("bonanza!");

    AbstractBeanDefinition child = new ChildBeanDefinition("parent");
    child.setBeanClass(TestBean.class);

    DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
    factory.registerBeanDefinition("parent", parent);
    factory.registerBeanDefinition("child", child);
View Full Code Here

    someMap.put("key2", "${age}name");
    MutablePropertyValues innerPvs = new MutablePropertyValues();
    innerPvs.addPropertyValue("touchy", "${os.name}");
    someMap.put("key3", new RootBeanDefinition(TestBean.class, innerPvs));
    MutablePropertyValues innerPvs2 = new MutablePropertyValues(innerPvs);
    someMap.put("${key4}", new BeanDefinitionHolder(new ChildBeanDefinition("tb1", innerPvs2), "child"));
    pvs.addPropertyValue("someMap", someMap);

    RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, cas, pvs);
    wac.getDefaultListableBeanFactory().registerBeanDefinition("tb2", bd);
View Full Code Here

    public void createComponents(Element element, ConfigurationInfo info,
            BeanDefinitionRegistry registry, BeanDefinitionReader reader,
            ResourceLoader resourceLoader) throws Exception {
        super.createComponents(element, info, registry, reader, resourceLoader);
        // add string template parser for sitemap variable substitution
        final ChildBeanDefinition beanDef = new ChildBeanDefinition("org.apache.cocoon.template.expression.AbstractStringTemplateParser");
        beanDef.setBeanClassName("org.apache.cocoon.components.treeprocessor.variables.LegacySitemapStringTemplateParser");
        beanDef.setSingleton(true);
        beanDef.setLazyInit(false);
        beanDef.getPropertyValues().addPropertyValue("serviceManager", new RuntimeBeanReference("org.apache.avalon.framework.service.ServiceManager"));
        this.register(beanDef, "org.apache.cocoon.el.parsing.StringTemplateParser/legacySitemap", null, registry);

        final RootBeanDefinition resolverDef = new RootBeanDefinition();
        resolverDef.setBeanClassName("org.apache.cocoon.components.treeprocessor.variables.StringTemplateParserVariableResolver");
        resolverDef.setLazyInit(false);
View Full Code Here

    RootBeanDefinition parentDefinition = new RootBeanDefinition(TestBean.class);
    parentDefinition.setAbstract(true);
    parentDefinition.getPropertyValues().add("name", EXPECTED_NAME);
    parentDefinition.getPropertyValues().add("age", new Integer(EXPECTED_AGE));

    ChildBeanDefinition childDefinition = new ChildBeanDefinition("alias");

    DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
    factory.registerBeanDefinition("parent", parentDefinition);
    factory.registerBeanDefinition("child", childDefinition);
    factory.registerAlias("parent", "alias");
View Full Code Here

  }

  @Test
  public void testGetTypeWorksAfterParentChildMerging() {
    RootBeanDefinition parentDefinition = new RootBeanDefinition(TestBean.class);
    ChildBeanDefinition childDefinition = new ChildBeanDefinition("parent", DerivedTestBean.class, null, null);

    DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
    factory.registerBeanDefinition("parent", parentDefinition);
    factory.registerBeanDefinition("child", childDefinition);
    factory.freezeConfiguration();
View Full Code Here

  @Test
  public void testScopeInheritanceForChildBeanDefinitions() throws Exception {
    RootBeanDefinition parent = new RootBeanDefinition();
    parent.setScope("bonanza!");

    AbstractBeanDefinition child = new ChildBeanDefinition("parent");
    child.setBeanClass(TestBean.class);

    DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
    factory.registerBeanDefinition("parent", parent);
    factory.registerBeanDefinition("child", child);
View Full Code Here

      pvs2.add("name", "name${var}${var}${");
      pvs2.add("spouse", new RuntimeBeanReference("${ref}"));
      pvs2.add("someMap", singletonMap);
      RootBeanDefinition parent = new RootBeanDefinition(TestBean.class);
      parent.setPropertyValues(pvs1);
      ChildBeanDefinition bd = new ChildBeanDefinition("${parent}", pvs2);
      factory.registerBeanDefinition("parent1", parent);
      factory.registerBeanDefinition("tb1", bd);
    }
    else {
      MutablePropertyValues pvs = new MutablePropertyValues();
      pvs.add("age", "${age}");
      pvs.add("name", "name${var}${var}${");
      pvs.add("spouse", new RuntimeBeanReference("${ref}"));
      pvs.add("someMap", singletonMap);
      RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
      bd.setPropertyValues(pvs);
      factory.registerBeanDefinition("tb1", bd);
    }

    ConstructorArgumentValues cas = new ConstructorArgumentValues();
    cas.addIndexedArgumentValue(1, "${age}");
    cas.addGenericArgumentValue("${var}name${age}");

    MutablePropertyValues pvs = new MutablePropertyValues();

    pvs.add("stringArray", new String[] {"${os.name}", "${age}"});

    List<Object> friends = new ManagedList<Object>();
    friends.add("na${age}me");
    friends.add(new RuntimeBeanReference("${ref}"));
    pvs.add("friends", friends);

    Set<Object> someSet = new ManagedSet<Object>();
    someSet.add("na${age}me");
    someSet.add(new RuntimeBeanReference("${ref}"));
    someSet.add(new TypedStringValue("${age}", Integer.class));
    pvs.add("someSet", someSet);

    Map<Object, Object> someMap = new ManagedMap<Object, Object>();
    someMap.put(new TypedStringValue("key${age}"), new TypedStringValue("${age}"));
    someMap.put(new TypedStringValue("key${age}ref"), new RuntimeBeanReference("${ref}"));
    someMap.put("key1", new RuntimeBeanReference("${ref}"));
    someMap.put("key2", "${age}name");
    MutablePropertyValues innerPvs = new MutablePropertyValues();
    innerPvs.add("touchy", "${os.name}");
    RootBeanDefinition innerBd = new RootBeanDefinition(TestBean.class);
    innerBd.setPropertyValues(innerPvs);
    someMap.put("key3", innerBd);
    MutablePropertyValues innerPvs2 = new MutablePropertyValues(innerPvs);
    someMap.put("${key4}", new BeanDefinitionHolder(new ChildBeanDefinition("tb1", innerPvs2), "child"));
    pvs.add("someMap", someMap);

    RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, cas, pvs);
    factory.registerBeanDefinition("tb2", bd);
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.support.ChildBeanDefinition

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.