tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Spring > Core > Merge List

Merge List 

Spring Inversion of Control (IoC) also known as Dependency Injection (DI) is a process by which objects define their dependencies with collaborating objects. The following example shows list merging. Spring allows us to merge list elements defined in parent definition with child definition.

File Name  :  

File Name  :  
package com.bethecoder.tutorials.spring3.basic;

public class ComplexBean {

  private java.util.Properties simpleProps;
  private java.util.List simpleList;
  private java.util.Map simpleMap;
  private java.util.Set simpleSet;
  public java.util.Properties getSimpleProps() {
    return simpleProps;
  public void setSimpleProps(java.util.Properties simpleProps) {
    this.simpleProps = simpleProps;
  public java.util.List getSimpleList() {
    return simpleList;
  public void setSimpleList(java.util.List simpleList) {
    this.simpleList = simpleList;
  public java.util.Map getSimpleMap() {
    return simpleMap;
  public void setSimpleMap(java.util.Map simpleMap) {
    this.simpleMap = simpleMap;
  public java.util.Set getSimpleSet() {
    return simpleSet;
  public void setSimpleSet(java.util.Set simpleSet) {
    this.simpleSet = simpleSet;

File Name  :  
Author  :  Sudhakar KV
Email  :  [email protected]
package com.bethecoder.tutorials.spring3.tests.merge;

import org.springframework.beans.factory.xml.XmlBeanFactory;

import com.bethecoder.tutorials.spring3.basic.ComplexBean;

public class MergeList {

   @param args
  public static void main(String[] args) {
    XmlBeanFactory factory = new XmlBeanFactory(
                new ClassPathResource("merge_list.xml"));

    ComplexBean complexBean = (ComplexBeanfactory.getBean("complexBean");



It gives the following output,
[Value1, Value2, Value3, Value3, Value4, Value5]



Books Recommendation

Your Ad Here
bl  br