I want to evaluate the OS (operating system) system property to load the environment corresponding configuration file. E.g. if OS evaluates to Windows, the properties-win.xml
will be loaded or if OS evaluates to Unix or Linux, the properties-unix.xml
will be loaded.
The below spel works fine
#{(systemProperties['os.name'].indexOf('nix') >= 0 or systemProperties['os.name'].indexOf('nux') >= 0 or systemProperties['os.name'].indexOf('aix') > 0 ) ? 'linux' :
((systemProperties['os.name'].indexOf('Win') >= 0) ? 'windows' : 'Unknow OS')}
But in place of evaluating the systemProperties['os.name']
each time, I want to have this in a variable and then wants to match the condition.
I saw the #this
variable usage (http://docs.spring.io/spring-framework/docs/3.0.6.RELEASE/spring-framework-reference/html/expressions.html sec 6.5.10.1) and tried to make the below spel
#{systemProperties['os.name'].?((#this.indexOf('nix') >= 0 or #this.indexOf('nux') >= 0 or #this.indexOf('aix') > 0 ) ? 'unix' :
(#this.indexOf('win') >= 0) ? 'windows' : 'Unknown')}
But somehow, it's giving parsing exception.
Does anyone can suggest anything?