Module six externalized configuration, in this module we will make the use of property files to be part of our configuration data for expressions that can be used with value or in XML. Well defined Spring provided beans as a means of achieving this, will you spring expression language or spell for more powerful expressions within our configurations. When we read a properties file, we need a beam to do that. And the being we could use is probably placeholder can figure out how it been definition for it here has a class, path, a resource class that can read the property smile and it becomes part of the application context, which means that our properties fire with active in count. As you see here it looks as if our dollar squiggly back expressions are pointing to those key value pairs and conversions will take place. That is somewhat true. But in fact the property placeholder configure is reading these key value pairs into the Spring Environment object an active and can are going to the Spring Environment object which is like a glorified map to get the values of those keys. Now that glasses deprecating, we actually use a property sources. Placeholder configure. You can see the definition of it here in a java configuration class. You should note the static. This means this being definition will execute before any non static being definitions. I want that to happen because I may have the other being definitions use items from the spring environment object that were populated from a property style. Where's the properties far, this class is associated with an app property source annotation which has the value of the property as farm. Now, if we're purist we want to get rid of the value annotations within our domain classes, we will put them in our java configuration classes here. We're using them as a method argument was a member variable which way you go depends on skirt, whether it's going to be used exclusively by one bean definition. We're not, spring expression language is significantly more powerful. Andy out let's just literal replacement here, you can actually execute code if you like. For example, here I'm executing the random method on math and I can use it in both XML and within our value annotations spell has the ability to locate spring managed beans. Its syntax is ID property, ID method. So hash employees service getting the beam of an ID of employees service, employee service start employees execute the method gets employees because there is no parenthesis, it's implying it's a property and therefore it's looking for a getter, employee service, all employees, no parenthesis before. But here we have the parenthesis. It means we're going to execute the method. All employees, it's not going to suffer get in front of it. So for example that value hash employee down, get with being with an ID of employee down that value, employee service dot get 1L given the blame been, whose ideas employee service execute get down, execute the method get one. Now we can use spell in expressions to filter collections, so we can do sub collections of collections within our application. We can use spel to filter a map for example into a collection such as a list of employees within the department. So here's my map, here's my employees of department. I'm going to look for a being whose ID's employed. DAO impulse execute the method. Get map there it is, get its values dark dot question mark means I'm going to filter all the items within values. Execute the method, get department because there is no parenthesis and for the department equals seven long. It's going to be part of this new list of employees. We can also filter to get one item with the current and the dollar sign to get either the first matching or the last matching out of a collection. No injected into a single item dependency such as just a single employee. And here we're actually combining both EL and spel. Get me all the values from the employee. [INAUDIBLE] Get map method, filter it using get department equals and then we see depth in dollar format that's EL. Getting the property depth in the spring environment object. And that would get me all the employees in that department whatever the value of the department is. But I did dot first name at the end. I just want to get the first name out of the first item within that map so we can really build our expressions quite extensively spell. Also has access to system properties such as the operating system name with the system properties. Predefined expression. Now in our test that we do in J unit we can define an application context, initial ideas set up values to use in our application context but at that I mean we can set some system properties. If I implement the application context initialize as I've done here will override the initialize method and here I've set a couple of system properties. When I come to my testing on J unit everything is the same as before, extend with context configuration classes. My application can fit class but I've added one or more initialize our classes, which means I can inject into my J unit system properties. In this case the key is my property because that's a custom property that I set in system properties. Now, here's a great example. Value equal system properties operating system name. Does it start with Windows if it does return hello Windows. Otherwise return Hello other basically doing an if else in an expression. Now we're extremely complicated. It is best to execute a method on a spring managed being to do such things because you have type safety in java. So we're going to do a lab now, we will use both EL and spel in this lab. We will use a properties file. Once you've done the lab, all of the instructions provided I will walk you through the lab afterwards and we can see how our spel expressions can get extremely powerful. I'll see you on the other side.