Changes between Version 1 and Version 2 of SCRIPTING_ACTIONS_API_R0


Ignore:
Timestamp:
07/13/09 20:14:38 (16 years ago)
Author:
mitex
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SCRIPTING_ACTIONS_API_R0

    v1 v2  
    66 
    77== Overview == 
    8 The goal of this task is to expose to the user the Sophie book's model and Sophie's logic in a user-friendly way. 
     8The goal of this task is to expose the Sophie book's model and Sophie's logic in a user-friendly way to the user. 
    99 
    1010Generally, there are two use-cases for scripting, which imply some differences in the requirements: 
     
    1818^(List the necessary requirements that the task must fulfill.)^ 
    1919 
     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 
    2025== Task result == 
    2126 * Source code 
    2227 
    2328== Implementation idea == 
    24 ^(Provide some rough implementation idea(s).)^ 
     29 
     30 * To filter the access to some Java classes: 
     31{{{ 
     32context.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{{{ 
     42Object wrappedOut = Context.javaToJS(System.out, scope); 
     43ScriptableObject.putProperty(scope, "out", wrappedOut); 
     44}}} 
    2545 
    2646== Related ==