Spring 3 – Environment/Profile based bean initialization and configuration
As we all know spring team is great and they always do wonder things. No different this time with spring 3.1 M1 release as well… In this post I am going to cover an interesting bean configuration/initialization strategy using which we can control bean initialization based on environment/profile. Spring team has introduce a concept of Environment and Profile using which we can annotate bean(s) (or mark them in XML) so that those beans will be initialized based on environment and active profile. Consider environment being a wrapper around our application context that know (or has information) about the environment in which application is running. Profile is something using which we can group various beans so that those beans will only be initialized if a particular profile is enabled in an environment. For example we have a simple application that uses some kind of third part service to validate the credit card numbers. Assume that the service charges us on per transaction basis an