Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: Dynamically loading more beans in an XmlWebApplicationContext

  1. #11

    Default

    Wow. Thanks Nick for such a quick reply.

    I've found the method calls you were talking about - DefaultListableBeanFactory.registerBeanDefinition( ) - and have got it to work. One thing I note is that if you do:

    Code:
    wac.refresh();
    instead of

    Code:
    wac.publishEvent(new ContextRefreshedEvent(wac));
    you lose the registered bean, so you can only really use this technique as a runtime thing or maybe perhaps as part of some sort of application bootstrapping.

    Anyway, thanks again.

  2. #12
    Join Date
    Jan 2007
    Posts
    8

    Default

    you lose the registered bean, so you can only really use this technique as a runtime thing or maybe perhaps as part of some sort of application bootstrapping.
    I'm not 100% I follow what you're saying. If you mean that you're losing the beans that were previously registered -- when you create a new bean factory, try setting the existing one as parent.
    This is what I'm doing, at runtime, I'm loading jars that contain applicationContext.xml files. I'm able to get the currently registered beans from the application context, set that beanfactory as the parent of my new one, and all new and old beans now are registered.

    I will try the wac.refresh() idea, thanks.

Posting Permissions

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