Changes between Version 1 and Version 2 of SCRIPTING_ACTIONS_API_R0
- Timestamp:
- 07/13/09 20:14:38 (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
SCRIPTING_ACTIONS_API_R0
v1 v2 6 6 7 7 == Overview == 8 The goal of this task is to expose t o the user the Sophie book's model and Sophie's logic in a user-friendly way.8 The goal of this task is to expose the Sophie book's model and Sophie's logic in a user-friendly way to the user. 9 9 10 10 Generally, there are two use-cases for scripting, which imply some differences in the requirements: … … 18 18 ^(List the necessary requirements that the task must fulfill.)^ 19 19 20 * Security 21 * Some scripts can crash the application. 22 * Some other scripts can allow crackers to execute malicious code. 23 * Solution: Not all Java classes have to be exposed to Sophie scripts. 24 20 25 == Task result == 21 26 * Source code 22 27 23 28 == Implementation idea == 24 ^(Provide some rough implementation idea(s).)^ 29 30 * To filter the access to some Java classes: 31 {{{ 32 context.setClassShutter(new ClassShutter() { 33 @Override 34 public boolean visibleToScripts(String fullClassName) { 35 return fullClassName.startsWith("org.mozilla.javascript"); 36 } 37 }); 38 }}} 39 40 * The following lines add a global variable {{{out}}} that is a JavaScript reflection of the {{{System.out}}} variable: 41 {{{ 42 Object wrappedOut = Context.javaToJS(System.out, scope); 43 ScriptableObject.putProperty(scope, "out", wrappedOut); 44 }}} 25 45 26 46 == Related ==