Package

Source Code of Config

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.support.ResourceBundleMessageSource;

/**
* This is the main context config class that imports older xml configurations. It creates
* the messageSource and a bean depending on an xml defined bean that uses the
* messageSource. This class does the same as the applicationcontext.xml file.
*/
@Configuration
@ImportResource("inherited.xml")
public class Config {

  @Bean
  public MessageSource messageSource() {
    return new ResourceBundleMessageSource();
  }

  @Bean
  public TheBeanThatUsesTheBeanWithMessageSource theOtherBean(
      @Qualifier("theBean1") TheBeanWithMessageSource theBeanWithMessageSource) {
    TheBeanThatUsesTheBeanWithMessageSource theOtherBean =
        new TheBeanThatUsesTheBeanWithMessageSource();
    theOtherBean.setBean(theBeanWithMessageSource);
    return theOtherBean;
  }

}
TOP

Related Classes of Config

TOP
Copyright © 2018 www.massapi.com. 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.