JPPF Issue Tracker
star_faded.png
Please log in to bookmark issues
feature_request_small.png
CLOSED  Feature request JPPF-216  -  Configuration enhancement: scripted property values
Posted Jan 29, 2014 - updated Mar 11, 2014
action_vote_minus_faded.png
0
Votes
action_vote_plus_faded.png
icon_info.png This issue has been closed with status "Closed" and resolution "RESOLVED".
Issue details
  • Type of issue
    Feature request
  • Status
     
    Closed
  • Assigned to
     lolo4j
  • Progress
       
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
  • Posted by
     lolo4j
  • Owned by
    Not owned by anyone
  • Estimated time
    Not estimated
  • Category
    Configuration
  • Resolution
    RESOLVED
  • Priority
    Normal
  • Targetted for
    icon_milestones.png JPPF 4.1
Issue description
We propose to add the following syntax to the JPPF configuration files, to express property values as the result of evaluating a JSR 223-compliant script language expression:
my.property = $script:language:source_type{script_source}$
Where:
  • language is the script language to use, such as provided by the javax.script APIs
  • source_type determines how to find the script, with possible values "inline", "file" or "url"
  • script_source is either the script expression of its location, depending on the value of source_type:
    • if source_type = inline, then script_source is the script itself, for example: my.prop = $script:javascript:inline{"hello" + "world"}$
    • if source_type = file, then script_source is a script file, looked up first in the file system, then in the classpath. For example: my.prop = $script:javascript:file{/home/me/myscript.js}$
    • if source_type = url, then script_source is a script loaded from a URL for example: my.prop = $script:javascript:url{file:///home/me/myscript.js}$
The scripts should be evaluated after all includes and variable substitutions have been resolved. This will allow the scripts to use a variable binding for the Properties (or TypedProperties object) being loaded.

Note the '$' at the end, to avoid confusion with any property substitution such as '${my.prop}' that would be part of the scripted value descriptor.

For instance, if the value of "other.prop" is 3:
my.prop = /my/path/folder_$script:javascript:inline{2 + thisProperties.getInt("other.prop")}$
then the value of my.prop should evaluate to the string "/my/path/folder_5". "thisProperties" is the variable binding which references the TypedProperties being loaded. Note that it could also be written equivalently as:
my.prop = /my/path/folder_$script:javascript:inline{2 + ${other.prop}}$
this will work because substitutions are resolved before the scripts are evaluated.

#3
Comment posted by
 lolo4j
Mar 11, 09:40
implemented in trunk revision 3077