Results 1 to 2 of 2

Thread: Help needed... bind beans in several xml files

  1. #1
    Join Date
    Jun 2005
    Posts
    6

    Default Help needed... bind beans in several xml files

    Hi all,

    I would like to know if this is possible to add new definitions of beans after we have initialized once the bean factory.

    To be more clear I have the following lines in my application:

    String[] configLocations = new String[] {
    "path/Database.xml",
    "path/DataAccessObjects.xml",
    "path/BusinessObjects.xml",
    "path/Services.xml",
    "path/Components.xml",
    "path/Delegate.xml"};

    beanFactory = new ClassPathXmlApplicationContext(configLocations, false);

    Those lines instantiate wired all my objects of the backend but actually I want also to wire the objects of my frontend. Therefore I would like to add other bean definitions to this factory after those lines (under) are executed.

    I do not find any methods which allow to add new definitions of beans without removing the beans that has already been loaded.
    Does anyone can tell if this is possible ? if yes how ?

    Thanks in advance,
    Tiggy

  2. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    Look at the methods on the AutowireCapableBeanFactory interface. With any of the Spring ApplicationContext implementations, you can cast it to ConfigurableApplicationContext, and get an AutowireCapableBeanFactory from that. You can then "autowire" existing instances, satisfying their dependencies from the factory.

    If you want to add a bean, you can look to the methods on DefaultListableBeanFactory.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

Similar Threads

  1. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  2. Reading xml beans files from jar files problem !!!
    By p_e_t_e_r in forum Container
    Replies: 10
    Last Post: Sep 26th, 2005, 12:38 AM
  3. (Tricky part) Spring beans and jar files
    By p_e_t_e_r in forum Container
    Replies: 1
    Last Post: Sep 17th, 2005, 08:19 PM
  4. Beans XML editor project started - input needed
    By Torsten Juergeleit in forum SpringSource Tool Suite
    Replies: 2
    Last Post: Jul 11th, 2005, 03:53 PM
  5. Replies: 2
    Last Post: Jan 14th, 2005, 11:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •