Package javax.script

Examples of javax.script.Compilable


     // initialize the cache if needed
     if( compilers == null )
       compilers = new HashMap();

     // lookup in the cache
     Compilable compiler = (Compilable)compilers.get( language);
     if( compiler != null )
       return compiler;

     // No compiler created for this language. Lookup in ScriptManager
     compiler = (Compilable)scriptEngineManager.getEngineByName(language);
View Full Code Here


        when(socketFactory.createSocket(any(InetAddress.class),
            anyInt())).thenReturn(socket);

        ScriptEngine engine = new ScriptEngineManager().getEngineByName("python");
        Compilable compilable = (Compilable) engine;
        unpickleScript = compilable.compile(UNPICKLER_SCRIPT);
    }
View Full Code Here

            // pre-compile script if we have it as text
            if (reader != null) {
                ScriptEngine engine = this.scriptEngineFactory.getScriptEngine();
                if (engine instanceof Compilable) {
                    Compilable compilable = (Compilable) engine;
                    this.compiledScript = compilable.compile(scriptText);
                    LOG.debug("Using compiled script: {}", this.compiledScript);
                }
            }
        } catch (IOException e) {
            throw new ScriptEvaluationException("Cannot load " + scriptLanguage + " script from resource: " + scriptResource, e);
View Full Code Here

            ScriptEngine engine = manager.getEngineByExtension(getFileExtension(filePath));
            if (engine == null) {
                throw new IllegalArgumentException("The script type is not supported for location: " + filePath);
            }
            try {
                Compilable compilableEngine = (Compilable) engine;
                URL scriptUrl = FlexibleLocation.resolveLocation(filePath);
                BufferedReader reader = new BufferedReader(new InputStreamReader(scriptUrl.openStream()));
                script = compilableEngine.compile(reader);
                if (Debug.verboseOn()) {
                    Debug.logVerbose("Compiled script " + filePath + " using engine " + engine.getClass().getName(), module);
                }
            } catch (ClassCastException e) {
                if (Debug.verboseOn()) {
View Full Code Here

            ScriptEngine engine = manager.getEngineByName(language);
            if (engine == null) {
                throw new IllegalArgumentException("The script type is not supported for language: " + language);
            }
            try {
                Compilable compilableEngine = (Compilable) engine;
                compiledScript = compilableEngine.compile(script);
                if (Debug.verboseOn()) {
                    Debug.logVerbose("Compiled script [" + script + "] using engine " + engine.getClass().getName(), module);
                }
            } catch (ClassCastException e) {
                if (Debug.verboseOn()) {
View Full Code Here

        if (compiledScript == null) {
            checkScriptTextAvailable();
        }
        if (compiledScript == null) {
            if (engine instanceof Compilable) {
                Compilable compilable = (Compilable) engine;
                compileScript(compilable);
            }
        }
    }
View Full Code Here

        ScriptEngine se = mgr.getEngineByName("JUnit");
        assertNotNull(se);
        se.put("key", "value");
        assertEquals("value",se.eval("key"));
        if (se instanceof Compilable){
            Compilable co = (Compilable) se;
            CompiledScript cs = co.compile("key");
            assertNotNull(cs);
            assertEquals("value",cs.eval());
            assertEquals("value",cs.eval());
        } else {
            fail("Expected engine to implement Compilable");
View Full Code Here

    // </editor-fold>
    //-- Compile Methods --//
    // <editor-fold defaultstate="collapsed" desc=" Compile (compile) ">
    public CompiledScript compile(String script) throws ScriptException {
        if (_compilable) {
            Compilable compilable = (Compilable) _engine;
            return compilable.compile(script);
        } else {
            return null;
        }
    }
View Full Code Here

        }
    }

    public CompiledScript compile(Reader reader) throws ScriptException {
        if (_compilable) {
            Compilable compilable = (Compilable) _engine;
            return compilable.compile(reader);
        } else {
            return null;
        }
    }
View Full Code Here

    }
   
    public boolean check() {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("python");
        Compilable compilable = (Compilable) engine;

        try {
      compilable.compile(mScriptContent);
          checkStepsDescriptions();
          return true;
    } catch (ScriptException e) {
            JOptionPane.showMessageDialog(null, "Syntax error in file '" + mFileName + "':\n" + e.getMessage());
            return false;
View Full Code Here

TOP

Related Classes of javax.script.Compilable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.