Announcement Announcement Module
No announcement yet.
Problems with refreshing a context Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems with refreshing a context

    I am using Spring 2.0 on JDK6.

    What problems could be caused by refreshing a context
    in a bean that was created by the context? That is,
    bean X was created by a web application context C
    and bean X chooses to do the following:

      class X implements ApplicationContextAware {
          private ConfigurableApplicationContext ctx;
          public void setApplicationContext(final ApplicationContext ctx) {
              this.ctx = (ConfigurableApplicationContext) ctx;
          public void refresh() {
             if (ctx != null) {
               getLogger().log("Reloaded the application...");
    If the refresh method of X is invoked, what would be the state of the bean
    after ctx.refresh() is invoked? Let's assume that there are no
    requests being serviced.

    Is this is a correct way of refreshing the context?



  • #2
    If this bean X is a singleton managed by its BeanFactory it will be destroyed (its destroy() or custom method will be called) and it will be removed from the list of context managed beans. During refresh another bean X will be created.