Announcement Announcement Module
Collapse
No announcement yet.
Strange problems with command bean post processing Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Strange problems with command bean post processing

    I'm trying to configure some of my commands using a PropertyPlaceholderConfigurer, but the beans defined in my commands-context.xml never seem to get processed.

    I'm assuming it has to do with the fact that the beans are not loaded directly into the application context, but instead are loaded as a property on the lifeycle advisor.

    Is this behavior intentional? Because it seems counter-intuitive. I would have expected the bean definitions to receive all the normal processing that any other spring bean receives.

    Anyway, is there any way to accomplish what I'm trying to do?

    Thanks,
    Larry.

  • #2
    Originally posted by lstreepy
    I'm trying to configure some of my commands using a PropertyPlaceholderConfigurer, but the beans defined in my commands-context.xml never seem to get processed.

    I'm assuming it has to do with the fact that the beans are not loaded directly into the application context, but instead are loaded as a property on the lifeycle advisor
    Yep - this is correct. For some unknown reason commands are loaded using a BeanFactory rather than an ApplicationContext (which allows for automatic registration of post processes etc).

    There's probably 2 ways you could try to fix this. 1) replace the usage of a bean factory with an app context. Ideally this "command context" would be a child of the main application context used to configure application services. 2) add another method to DefaultApplicationLifecycleAdvisor#initNewWindowCo mmandBarFactory which registers all of the BeanFactoryPostProcessors found in the command bean factory. This would be similar to the registerBeanPostProcessors method but for BeanFactoryPostProcessors. You'd also need to dumplicate your PropertyPlaceholderConfigurer config in the command bean factory defintion.

    HTH

    Ollie

    Comment


    • #3
      Thanks Ollie, that's pretty much the conclusion that I had come to. What I was wondering is if anyone knew why the original implementation went to so much trouble to use a BeanFactory instead of an ApplicaitonContext.

      Anyway, I've got a version working with an ApplicationContext and it seems to work well. The only real visible change is that the commands context file would no longer be a Resource, it would be a string that is used as a normal ApplicationContext "location".

      Let me know if you see a reason NOT to pursue changing to an ApplicationContext.

      Thanks.
      Larry.

      Comment

      Working...
      X