Download - That old Spring magic has me in its SpEL
![Page 1: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/1.jpg)
That old Spring magic has me in its SpEL
Craig Walls
![Page 2: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/2.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
About me
![Page 3: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/3.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
About me
• Java, Spring, and OSGi fanatic
![Page 4: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/4.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
About me
• Java, Spring, and OSGi fanatic
• Principal consultant with Improving Enterprises
![Page 5: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/5.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
About me
• Java, Spring, and OSGi fanatic
• Principal consultant with Improving Enterprises
• Author
![Page 6: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/6.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
About me
• Java, Spring, and OSGi fanatic
• Principal consultant with Improving Enterprises
• Author
![Page 7: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/7.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Agenda
3
![Page 8: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/8.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Agenda
• Introducing SpEL
3
![Page 9: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/9.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Agenda
• Introducing SpEL
• Using SpEL
3
![Page 10: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/10.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Agenda
• Introducing SpEL
• Using SpEL
• SpEL Essentials
3
![Page 11: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/11.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Agenda
• Introducing SpEL
• Using SpEL
• SpEL Essentials
• A few SpEL incantations
3
![Page 12: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/12.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Agenda
• Introducing SpEL
• Using SpEL
• SpEL Essentials
• A few SpEL incantations
• Q & A
3
![Page 13: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/13.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Download the examples
Approximately the same code...
http://spring.habuma.com/examples/SpEL-examples.zip
4
![Page 14: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/14.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Introducing SpEL
![Page 15: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/15.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
What is SpEL
6
![Page 16: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/16.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
What is SpEL
• New in Spring 3.0
6
![Page 17: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/17.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
What is SpEL
• New in Spring 3.0– Originally conceived in Spring.NET
6
![Page 18: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/18.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
What is SpEL
• New in Spring 3.0– Originally conceived in Spring.NET
• The Spring Expression Language
6
![Page 19: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/19.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
What is SpEL
• New in Spring 3.0– Originally conceived in Spring.NET
• The Spring Expression Language
• Much like Unified EL, OGNL, JBoss EL, and others
6
![Page 20: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/20.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
What is SpEL
• New in Spring 3.0– Originally conceived in Spring.NET
• The Spring Expression Language
• Much like Unified EL, OGNL, JBoss EL, and others
• Will be used across entire Spring portfolio
6
![Page 21: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/21.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
What is SpEL
• New in Spring 3.0– Originally conceived in Spring.NET
• The Spring Expression Language
• Much like Unified EL, OGNL, JBoss EL, and others
• Will be used across entire Spring portfolio
• Succinctly express complex concepts
6
![Page 22: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/22.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
What is SpEL
• New in Spring 3.0– Originally conceived in Spring.NET
• The Spring Expression Language
• Much like Unified EL, OGNL, JBoss EL, and others
• Will be used across entire Spring portfolio
• Succinctly express complex concepts
• Can be used to wire bean properties
6
![Page 23: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/23.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
What is SpEL
• New in Spring 3.0– Originally conceived in Spring.NET
• The Spring Expression Language
• Much like Unified EL, OGNL, JBoss EL, and others
• Will be used across entire Spring portfolio
• Succinctly express complex concepts
• Can be used to wire bean properties
• Can be used outside of Spring
6
![Page 24: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/24.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Using SpEL
![Page 25: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/25.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Configuring beans with SpEL (XML)
![Page 26: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/26.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Configuring beans with SpEL (XML)
<bean id="appConfigurer" class="com.habuma.spel.tests.Witch"> <property name="name" value="#{systemProperties['WITCH_NAME']}" /></bean>
![Page 27: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/27.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Configuring beans with SpEL (@Value)
![Page 28: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/28.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Configuring beans with SpEL (@Value)
@Componentpublic class Wizard { @Value("#{systemEnvironment['WIZARD_NAME']}") private String name;
// ...}
![Page 29: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/29.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Programming with SpEL
![Page 30: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/30.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Programming with SpEL
ExpressionParser parser = new SpelAntlrExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext(rootObject);
Expression ex = parser.parseExpression("witches.^[isWicked()]");
Witch wickedWitch = (Witch) ex.getValue(context);
![Page 31: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/31.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Essential SpEL
![Page 32: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/32.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Literal expressions
![Page 33: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/33.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Literal expressions
#{'abracadabra'}
![Page 34: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/34.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Literal expressions
#{'abracadabra'}
#{42}
![Page 35: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/35.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Literal expressions
#{'abracadabra'}
#{42} #{3.1415926}
![Page 36: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/36.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Literal expressions
#{'abracadabra'}
#{42} #{3.1415926}
#{1e4}
![Page 37: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/37.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Literal expressions
#{'abracadabra'}
#{true}
#{42} #{3.1415926}
#{1e4}
![Page 38: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/38.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Literal expressions
#{'abracadabra'}
#{true} #{false}
#{42} #{3.1415926}
#{1e4}
![Page 39: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/39.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Literal expressions
#{'abracadabra'}
#{true} #{false}
#{42} #{3.1415926}
#{null}
#{1e4}
![Page 40: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/40.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Ready-to-use variables
![Page 41: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/41.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Ready-to-use variables
#{systemProperties['WIZARD_NAME']}
![Page 42: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/42.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Ready-to-use variables
#{systemProperties['WIZARD_NAME']}
#{systemProperties.WIZARD_NAME}
![Page 43: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/43.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Ready-to-use variables
#{systemProperties['WIZARD_NAME']}
#{systemProperties.WIZARD_NAME}
#{systemEnvironment['WIZARD_NAME']}
![Page 44: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/44.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Ready-to-use variables
#{systemProperties['WIZARD_NAME']}
#{systemProperties.WIZARD_NAME}
#{systemEnvironment['WIZARD_NAME']}
#{systemEnvironment.WIZARD_NAME}
![Page 45: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/45.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Ready-to-use variables
#{systemProperties['WIZARD_NAME']}
#{systemProperties.WIZARD_NAME}
#{systemEnvironment['WIZARD_NAME']}
#{systemEnvironment.WIZARD_NAME}
#{wizardBean.name}
![Page 46: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/46.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Ready-to-use variables
#{systemProperties['WIZARD_NAME']}
#{systemProperties.WIZARD_NAME}
#{systemEnvironment['WIZARD_NAME']}
#{systemEnvironment.WIZARD_NAME}
#{wizardBean.name}
Only available when using SpEL in Spring configuration
![Page 47: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/47.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Ready-to-use variables
![Page 48: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/48.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Ready-to-use variables
#{request.getParameter('wizardId')}
![Page 49: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/49.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Ready-to-use variables
#{request.getParameter('wizardId')}
#{session.getAttribute('wizard')}
![Page 50: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/50.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Ready-to-use variables
#{request.getParameter('wizardId')}
#{session.getAttribute('wizard')}
Can only be used to configure appropriately-scoped beans
![Page 51: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/51.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Constructors
![Page 52: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/52.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Constructors
#{new com.habuma.spel.tests.Wizard('Gandalf')}
![Page 53: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/53.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Constructors
#{new com.habuma.spel.tests.Wizard('Gandalf')}
#{new String('hokus pokus')}
![Page 54: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/54.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Accessing object members
![Page 55: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/55.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Accessing object members
#{elf.name}
![Page 56: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/56.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Accessing object members
#{elf.name}
#{elf.Name}
![Page 57: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/57.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Accessing object members
#{elf.name}
#{elf.Name}
#{elf.getName()}
![Page 58: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/58.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Accessing object members
#{elf.name}
#{elf.Name}
#{elf.getName()}
#{elf.name?.length()}
![Page 59: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/59.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Mixing expressions and text
![Page 60: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/60.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Mixing expressions and text
The wizard’s name is #{wizard.name}
Embeds the wizard’s name in some text
![Page 61: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/61.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Arithmetic operators
![Page 62: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/62.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Arithmetic operators
#{'Harry' + ' ' + 'Potter'}
![Page 63: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/63.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Arithmetic operators
#{'Harry' + ' ' + 'Potter'}
#{25 + 52}
![Page 64: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/64.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Arithmetic operators
#{'Harry' + ' ' + 'Potter'}
#{25 + 52} #{2.19 + 2.02}
![Page 65: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/65.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Arithmetic operators
#{'Harry' + ' ' + 'Potter'}
#{25 + 52} #{2.19 + 2.02}
#{77 - 25}
![Page 66: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/66.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Arithmetic operators
#{'Harry' + ' ' + 'Potter'}
#{25 + 52} #{2.19 + 2.02}
#{77 - 25} #{52 - -25}
![Page 67: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/67.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Arithmetic operators
#{'Harry' + ' ' + 'Potter'}
#{25 + 52} #{2.19 + 2.02}
#{77 - 25} #{52 - -25}
#{6 * 7}
![Page 68: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/68.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Arithmetic operators
#{'Harry' + ' ' + 'Potter'}
#{25 + 52} #{2.19 + 2.02}
#{77 - 25} #{52 - -25}
#{6 * 7} #{42 / 6}
![Page 69: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/69.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Arithmetic operators
#{'Harry' + ' ' + 'Potter'}
#{25 + 52} #{2.19 + 2.02}
#{77 - 25} #{52 - -25}
#{6 * 7} #{42 / 6}
#{44 % 7}
![Page 70: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/70.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Relational operators
![Page 71: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/71.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Relational operators
#{42 > 7}
![Page 72: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/72.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Relational operators
#{42 > 7} #{7 > 42}
![Page 73: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/73.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Relational operators
#{42 > 7} #{7 > 42}
#{10000 == 1e4}
![Page 74: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/74.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Relational operators
#{42 > 7} #{7 > 42}
#{10000 == 1e4}
#{‘Apple’ == ‘Apple’}
![Page 75: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/75.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Relational operators
#{42 > 7} #{7 > 42}
#{10000 == 1e4}
#{‘Apple’ == ‘Apple’}
#{‘Apple’ < ‘Orange’}
![Page 76: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/76.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Relational operators
#{42 > 7} #{7 > 42}
#{10000 == 1e4}
#{‘Apple’ == ‘Apple’}
#{‘Apple’ < ‘Orange’} #{‘Orange’ > ‘Apple’}
![Page 77: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/77.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Logical operators
![Page 78: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/78.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Logical operators
#{witch.isWicked() and witch.name == 'Elphaba'}
![Page 79: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/79.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Logical operators
#{witch.isWicked() and witch.name == 'Elphaba'}
#{witch.isWicked() or witch.name == 'Tattypoo'}
![Page 80: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/80.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Logical operators
#{witch.isWicked() and witch.name == 'Elphaba'}
#{witch.isWicked() or witch.name == 'Tattypoo'}
#{!witch.isWicked()}
![Page 81: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/81.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Ternary and Elvis operator
![Page 82: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/82.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Ternary and Elvis operator
#{wizard.isGood() ? 'Gandalf' : 'Saruman'}
![Page 83: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/83.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Ternary and Elvis operator
#{wizard.isGood() ? 'Gandalf' : 'Saruman'}
#{wizard.name ?: 'unknown'}
![Page 84: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/84.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
The type operator : T()
![Page 85: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/85.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
The type operator : T()
#{T(String)}
![Page 86: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/86.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
The type operator : T()
#{T(String)}
#{T(Math)}
![Page 87: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/87.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
The type operator : T()
#{T(String)}
#{T(Math)}
#{T(int)}
![Page 88: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/88.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
The type operator : T()
#{T(String)}
#{T(Math)}
#{T(int)}
#{T(java.util.Date)}
![Page 89: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/89.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Accessing class members
![Page 90: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/90.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Accessing class members
#{T(Math).floor(42.56)}
![Page 91: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/91.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Accessing class members
#{T(Math).floor(42.56)}
#{T(Math).PI}
![Page 92: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/92.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
instanceof
![Page 93: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/93.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
instanceof
#{‘Sabrina’ instanceof T(String)}
![Page 94: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/94.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
instanceof
#{‘Sabrina’ instanceof T(String)}
#{123 instanceof T(Integer)}
![Page 95: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/95.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
instanceof
#{‘Sabrina’ instanceof T(String)}
#{123 instanceof T(Integer)}
#{123L instanceof T(Long)}
![Page 96: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/96.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
instanceof
#{‘Sabrina’ instanceof T(String)}
#{123 instanceof T(Integer)}
#{123L instanceof T(Long)}
#{1.23 instanceof T(Double)}
![Page 97: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/97.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
instanceof
#{‘Sabrina’ instanceof T(String)}
#{123 instanceof T(Integer)}
#{123L instanceof T(Long)}
#{true instanceof T(Boolean)}
#{1.23 instanceof T(Double)}
![Page 98: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/98.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Regular expressions
![Page 99: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/99.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Regular expressions
#{phoneNumber matches '\\d{3}-\\d{3}-\\d{4}'}
![Page 100: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/100.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Regular expressions
#{phoneNumber matches '\\d{3}-\\d{3}-\\d{4}'}
#{websiteUrl matches 'http://www\\.[a-zA-Z0-9]*\\.(com|edu|net)'}
![Page 101: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/101.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Regular expressions
#{phoneNumber matches '\\d{3}-\\d{3}-\\d{4}'}
#{customerEmail matches '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}'}
#{websiteUrl matches 'http://www\\.[a-zA-Z0-9]*\\.(com|edu|net)'}
![Page 102: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/102.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Setting variables
![Page 103: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/103.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Setting variables
Assuming that the root object has a name property...
![Page 104: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/104.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Setting variables
name = 'Broomhilda'
Assuming that the root object has a name property...
![Page 105: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/105.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Accessing collection members
![Page 106: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/106.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Accessing collection members
#{wizards[0]}
Arrays
![Page 107: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/107.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Accessing collection members
#{wizards[0]}
#{magicWords['abracadabra']}
Arrays
Maps and Properties
![Page 108: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/108.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Collection selection
![Page 109: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/109.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Collection selection
#{witches.?[!isWicked()]}
Select all witches that aren’t wicked
![Page 110: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/110.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Collection selection
#{witches.?[!isWicked()]}
#{witches.^[isWicked()]}
Select all witches that aren’t wicked
Select the first wicked witch
![Page 111: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/111.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Collection selection
#{witches.?[!isWicked()]}
#{witches.^[isWicked()]}
#{witches.$[isWicked()]}
Select all witches that aren’t wicked
Select the first wicked witch
Select the last wicked witch
![Page 112: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/112.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Collection projection
![Page 113: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/113.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Collection projection
#{wizards.![name]}
Get the names of all wizards
![Page 114: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/114.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
The #this variable
![Page 115: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/115.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
The #this variable
#{wizards.![name].?[#this > 'G']}
Get the names of all wizards whose name is lexically ordered after ‘G’
![Page 116: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/116.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Adding a custom function
31
Only available with programmatic SpEL
![Page 117: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/117.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Adding a custom function
31
context = new StandardEvaluationContext();parser = new SpelAntlrExpressionParser();context.registerFunction("inEnglish", EnglishNumberInator.class.getDeclaredMethod( "translate", new Class[] {int.class}));
Only available with programmatic SpEL
![Page 118: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/118.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Adding a custom function
31
context = new StandardEvaluationContext();parser = new SpelAntlrExpressionParser();context.registerFunction("inEnglish", EnglishNumberInator.class.getDeclaredMethod( "translate", new Class[] {int.class}));
Expression ex = parser.parseExpression("#inEnglish(123)");String englishNumber = ex.getValue(context);
Only available with programmatic SpEL
![Page 119: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/119.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Demo
![Page 120: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/120.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
A few SpEL incantations
![Page 121: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/121.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Wiring in a system property (with a default)
![Page 122: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/122.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Wiring in a system property (with a default)
<bean class="Wizard"> <property name="name" value= "#{systemProperties['WIZARD_NAME'] ?: 'Gandalf'}" /></bean>
![Page 123: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/123.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Wiring bean references
![Page 124: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/124.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Wiring bean references
@Value("#{pricingService}")private PricingService pricingService;
![Page 125: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/125.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Wiring bean references
@Value("#{pricingService}")private PricingService pricingService;
<property name="pricingService" value="#{pricingService}" />
...or...
![Page 126: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/126.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Wiring bean references
@Value("#{pricingService}")private PricingService pricingService;
<property name="pricingService" value="#{pricingService}" />
Don’t do this!
...or...
![Page 127: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/127.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Wiring bean references
@Value("#{pricingService}")private PricingService pricingService;
<property name="pricingService" value="#{pricingService}" />
Don’t do this!However...
...or...
![Page 128: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/128.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Selective bean wiring
![Page 129: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/129.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Selective bean wiring
@Value("#{systemProperties['PRICING'] == 'aggressive'" + "? aggressivePricing : regularPricing}")private PricingService pricingService;
![Page 130: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/130.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Selective collection wiring
![Page 131: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/131.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Selective collection wiring
public interface TaxRule { boolean appliesToState(String state); double calculateTax(double base);}
![Page 132: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/132.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Selective collection wiring
public interface TaxRule { boolean appliesToState(String state); double calculateTax(double base);}
<util:list id="taxRules"> <ref id="revenueTax" /> <ref id="carpetTax" /> <ref id="existenceTax" /> <ref id="justBecauseTax" /></util:list>
![Page 133: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/133.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Selective collection wiring
<bean id="taxProcessor" class="TaxProcessor" scope="session"> <aop:scoped-proxy /> <property name="taxRules" value= "#{taxRules.?[appliesToState(session.getAttribute('user').state)]}" /></bean>
public interface TaxRule { boolean appliesToState(String state); double calculateTax(double base);}
<util:list id="taxRules"> <ref id="revenueTax" /> <ref id="carpetTax" /> <ref id="existenceTax" /> <ref id="justBecauseTax" /></util:list>
![Page 134: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/134.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Parting thoughts
38
![Page 135: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/135.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Parting thoughts
• SpEL expressions are great for doing Spring configuration magic
38
![Page 136: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/136.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Parting thoughts
• SpEL expressions are great for doing Spring configuration magic
• SpEL expressions are just Strings...no compile-time help to ensure type-safety, syntax, etc.
38
![Page 137: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/137.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Parting thoughts
• SpEL expressions are great for doing Spring configuration magic
• SpEL expressions are just Strings...no compile-time help to ensure type-safety, syntax, etc.
• Don’t abuse SpEL
38
![Page 138: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/138.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Parting thoughts
• SpEL expressions are great for doing Spring configuration magic
• SpEL expressions are just Strings...no compile-time help to ensure type-safety, syntax, etc.
• Don’t abuse SpEL
– Remember Goethe’s Sorcerer’s Apprentice
38
![Page 139: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/139.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Parting thoughts
• SpEL expressions are great for doing Spring configuration magic
• SpEL expressions are just Strings...no compile-time help to ensure type-safety, syntax, etc.
• Don’t abuse SpEL
– Remember Goethe’s Sorcerer’s Apprentice
– A little bit of magic in the wrong hands can be dangerous
38
![Page 140: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/140.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Parting thoughts
• SpEL expressions are great for doing Spring configuration magic
• SpEL expressions are just Strings...no compile-time help to ensure type-safety, syntax, etc.
• Don’t abuse SpEL
– Remember Goethe’s Sorcerer’s Apprentice
– A little bit of magic in the wrong hands can be dangerous
• Write tests!!!
38
![Page 141: That old Spring magic has me in its SpEL](https://reader034.vdocuments.us/reader034/viewer/2022042623/54b88e3d4a7959b7078b46b1/html5/thumbnails/141.jpg)
SpringOne 2GX 2009. All rights reserved. Do not distribute without permission.
Q&A
Thank you!Don’t forget to turn in your evaluations!!!