Package javax.script

Examples of javax.script.ScriptEngineManager


    public static final String PARAM_LANG = "lang";

    private final ScriptEngineManager engineManager;

    public ScriptEngineActivationStrategy() {
        engineManager = new ScriptEngineManager();
    }
View Full Code Here


    }

    private void createScriptEngineManager(Map<ScriptEngineManager, ClassLoader> managers, String factoryName,
                                           ClassLoader factoryLoader) {
        try {
            ScriptEngineManager manager = new ScriptEngineManager(factoryLoader);
            manager.setBindings(bindings);
            managers.put(manager, factoryLoader);
        } catch (Exception e) {
            // may fail if script implementation is not in environment
            logger.warning("Found ScriptEngineFactory candidate for " + factoryName
                    + ", but could not load ScripEngineManager! -> " + e);
View Full Code Here

    private HazelcastInstance hazelcastInstance;

    private final ILogger logger = Logger.getLogger(Activator.class);

    public void start(BundleContext context) throws Exception {
        final ScriptEngineManager scriptEngineManager = new OSGiScriptEngineManager(context);
        ScriptEngineManagerContext.setScriptEngineManager(scriptEngineManager);

        if (logger.isFinestEnabled()) {
            StringBuilder msg = new StringBuilder("Available script engines are:");
            for (ScriptEngineFactory scriptEngineFactory : scriptEngineManager.getEngineFactories()) {
                msg.append(scriptEngineFactory.getEngineName()).append('\n');
            }
            logger.finest(msg.toString());
        }
View Full Code Here

    public void beforeRun() throws Exception {
    }

    @Override
    public void run() throws Exception {
        ScriptEngineManager scriptEngineManager = ScriptEngineManagerContext.getScriptEngineManager();
        ScriptEngine engine = scriptEngineManager.getEngineByName(engineName);
        if (engine == null) {
            throw new IllegalArgumentException("Could not find ScriptEngine named '" + engineName + "'.");
        }
        engine.put("hazelcast", getNodeEngine().getHazelcastInstance());
        if (bindings != null) {
View Full Code Here

        ArrayList<String> scriptNamesAsList = new ArrayList<String>(Arrays.asList(scriptNames));      
        if ("IBM Corporation".equals(System.getProperty("java.vendor"))) {
            scriptNamesAsList.remove("ruby");
        }
       
        ScriptEngineManager manager = new ScriptEngineManager();
        for (String scriptName : scriptNamesAsList) {
            ScriptEngine engine = manager.getEngineByName(scriptName);
            assertNotNull("We should get the script engine for " + scriptName , engine);
        }
    }
View Full Code Here

    protected boolean matches(E exchange, Object scriptValue) {
        return ObjectConverter.toBool(scriptValue);
    }

    protected ScriptEngine createScriptEngine() {
        ScriptEngineManager manager = new ScriptEngineManager();
        try {
            engine = manager.getEngineByName(scriptEngineName);
        } catch (NoClassDefFoundError ex) {
            LOG.error("Can't load the scriptEngine for " + scriptEngineName + ", the exception is " + ex
                      + ", please check the scriptEngine needs jars.");
        }
        if (engine == null) {
View Full Code Here

    /**
     * Hack for now to work around a problem with the JRuby script engine
     */
    protected ScriptEngine getScriptEngineByExtension(String scriptExtn) {
        ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
        if ("rb".equals(scriptExtn)) {
            return new TuscanyJRubyScriptEngine();
        } else {
            if ("py".equals(scriptExtn)) {
                pythonCachedir();
            }
            return scriptEngineManager.getEngineByExtension(scriptExtn);
        }
    }
View Full Code Here

     */
    public static CompiledScript compileScriptFile(String filePath) throws ScriptException, IOException {
        Assert.notNull("filePath", filePath);
        CompiledScript script = parsedScripts.get(filePath);
        if (script == null) {
            ScriptEngineManager manager = new ScriptEngineManager();
            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;
View Full Code Here

    public static CompiledScript compileScriptString(String language, String script) throws ScriptException {
        Assert.notNull("language", language, "script", script);
        String cacheKey = language.concat("://").concat(script);
        CompiledScript compiledScript = parsedScripts.get(cacheKey);
        if (compiledScript == null) {
            ScriptEngineManager manager = new ScriptEngineManager();
            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;
View Full Code Here

        try {
            CompiledScript compiledScript = compileScriptString(language, script);
            if (compiledScript != null) {
                return executeScript(compiledScript, null, createScriptContext(context), null);
            }
            ScriptEngineManager manager = new ScriptEngineManager();
            ScriptEngine engine = manager.getEngineByName(language);
            if (engine == null) {
                throw new IllegalArgumentException("The script type is not supported for language: " + language);
            }
            if (Debug.verboseOn()) {
                Debug.logVerbose("Begin processing script [" + script + "] using engine " + engine.getClass().getName(), module);
View Full Code Here

TOP

Related Classes of javax.script.ScriptEngineManager

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.