Tuesday, November 8, 2011

Spring Introduce Environment Profile

Spring 3.1 introduce notion of an Environment. This abstraction of profiles has been integrated throughout the container. As always, spring community trying to help developer by introducing this very useful concepts, I do think this will be very useful for application and will definitely reduce project timeline. Application now can easily switch between profiles. Like environment-specific bean definitions, like the need to register certain bean definitions in certain contexts, while not in others. You could say that you want to register a certain profile of bean definitions in situation A, and a different profile in situation B. it's important factor to understand that the Environment contains information about which profiles (if any) are currently active. When the Spring ApplicationContext above is loading our three bean definition files, it pays close attention to the attribute in each of them. If it is present and set to the name of a profile that is not currently active, the entire file is skipped — no bean definitions are parsed or registered. You would use same way to load ApplicationContext – spring container, which will activate your profile. 

Play Safe - I would still play safe and use this only when it’s necessary to do this, like you only changing some bean values. You can use this if sets of beans are similar between dev or production. 

No comments:

Post a Comment