Archive for the springframework Category

Spring Bean Substitution

Posted in java, springframework on June 24, 2006 by eddie

If we ever try to import a spring configuration from a packaged jar and need to customize some of the bean definitions, we would find ourselves having to do these things:

  1. extract the packaged configuration to somewhere we can actually edit;
  2. change the bean definition according to our needs;
  3. import the new configuration and exclude the original one.

Even though this works just fine, we will have to maintain the configuration copy and synchronize it with any updates made to the original one. This feels like forking our own branch from the spring configuration.

I think spring configuration can be a lot more flexible and powerful if we can substitute beans instead of having to redefine the whole bean dependency tree. Currently spring provides no such mechanism, so I tried a little hack utilizing the BeanFactoryPostProcessor and the BeanPostProcessor.

Continue reading