Spring Advanced Wiring: Spring Profiles and the Spring Expression Language
Spring offers a wealth of configuration options that just work with simplicity and elegance. Still, there are those cases where standard bean configuration is just not enough. This talk discusses two slightly more advanced configuration options available in Spring.
First, in a short topic, we discuss Spring Profiles. First introduced in Spring 3.1 and improved in 3.2, Spring Profiles offer a simple way to optionally include beans in the Spring context. This topic covers:
- Specifying the profile that a bean belongs to
- Specifying the profile(s) in effect when the Spring context is loaded
The second medium length topic covers the Spring Expression Language (SpEL). First introduced in Spring 3.0, SpEL provides a powerful mechanism for truly dynamic bean configuration. However, it’s really a general purpose expression language that can be used to query and manipulate an object graph at runtime. This topic covered:
- How to configure your app to use SpEL
- Literal, boolean, class and regular expressions
- Accessing properties, arrays, lists, maps
- Referencing beans in SpEL
- User defined functions
- Other SpEL-binding capabilities
We also examine Spring 4.0’s @Conditional annotation for conditionally including a bean in the Spring context.
The presentation is intended for Spring developers who would like to stretch their Spring wings a bit beyond basic bean configuration.