Package javax.script

Examples of javax.script.ScriptEngineFactory


        in.close();
        Class cls = bundle.loadClass(className);
        if (!ScriptEngineFactory.class.isAssignableFrom(cls)) {
            throw new IllegalStateException("Invalid ScriptEngineFactory: " + cls.getName());
        }
        ScriptEngineFactory factory = (ScriptEngineFactory) cls.newInstance();
        List<String> names = factory.getNames();
        for (String test : names) {
          if (test.equals(name)) {
            ClassLoader old = Thread.currentThread().getContextClassLoader();
            ScriptEngine engine;
            try {
              // JRuby seems to require the correct TCCL to call getScriptEngine
              Thread.currentThread().setContextClassLoader(factory.getClass().getClassLoader());
              engine = factory.getScriptEngine();
            } finally {
              Thread.currentThread().setContextClassLoader(old);
            }
            LOGGER.trace("Resolved ScriptEngineFactory: {} for expected name: {}", engine, name);
            return engine;
          }
        }
        LOGGER.debug("ScriptEngineFactory: {} does not match expected name: {}", factory.getEngineName(), name);
        return null;
      } catch (Exception e) {
        LOGGER.warn("Cannot create ScriptEngineFactory: {}", e.getClass().getName(), e);
        return null;
      }
View Full Code Here


           && (factoryClassName!=null)
         ) {
        try {
          ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
          Class<?> factoryClass = Class.forName(factoryClassName, true, classLoader);
          ScriptEngineFactory scriptEngineFactory = (ScriptEngineFactory) factoryClass.newInstance();
          scriptEngineManager.registerEngineName(languageName, scriptEngineFactory);
        } catch (Exception e) {
          parse.addProblem("couldn't instantiate ScriptEngineFactory "+factoryClassName, e);
        }
      }
View Full Code Here

    public void setUp() throws Exception {
        if (!initialized) {
            Ripple.initialize();
        }

        ScriptEngineFactory factory = new RippleScriptEngineFactory();
        engine = factory.getScriptEngine();
    }
View Full Code Here

        Properties config = new Properties();
        Ripple.initialize(config);
    }

    public void testInfo() throws Exception {
        ScriptEngineFactory f = new RippleScriptEngineFactory();

        assertEquals("Ripple Script Engine", f.getEngineName());

        List<String> names = f.getNames();
        assertEquals(1, names.size());
        assertEquals("ripple", names.get(0));

        List<String> extensions = f.getExtensions();
        assertEquals(1, extensions.size());
        assertEquals("rpl", extensions.get(0));

        assertEquals(Ripple.getVersion(), f.getEngineVersion());

        assertEquals("Ripple", f.getLanguageName());

        assertEquals(Ripple.getVersion(), f.getLanguageVersion());

        List<String> mimeTypes = f.getMimeTypes();
        assertEquals(0, mimeTypes.size());
    }
View Full Code Here

        List<String> mimeTypes = f.getMimeTypes();
        assertEquals(0, mimeTypes.size());
    }

    public void testGetMethodCallSyntax() throws Exception {
        ScriptEngineFactory f = new RippleScriptEngineFactory();

        assertEquals("ex:bob foaf:name >> .",
                f.getMethodCallSyntax("ex:bob", "foaf:name"));

        assertEquals("1 2 add >> .",
                f.getMethodCallSyntax("1", "add", "2"));
    }
View Full Code Here

        assertEquals("1 2 add >> .",
                f.getMethodCallSyntax("1", "add", "2"));
    }

    public void testGetProgram() throws Exception {
        ScriptEngineFactory f = new RippleScriptEngineFactory();

        assertEquals("",
                f.getProgram());
        assertEquals("1 2 add >>.",
                f.getProgram("1 2 add >>"));
        assertEquals("ex:bob foaf:name >> ..\n1 2 add >> 5 mul >>.",
                f.getProgram("ex:bob foaf:name >> .", "1 2 add >> 5 mul >>"));
    }
View Full Code Here

    public void testGetOutputStatement() throws Exception {
        // TODO
    }

    public void testGetScriptEngine() throws Exception {
        ScriptEngineFactory f = new RippleScriptEngineFactory();
        ScriptEngine e = f.getScriptEngine();

        assertEquals(RippleScriptEngine.class, e.getClass());
        assertTrue(f == e.getFactory());
    }
View Full Code Here

        in.close();
        Class cls = bundle.loadClass(className);
        if (!ScriptEngineFactory.class.isAssignableFrom(cls)) {
            throw new IllegalStateException("Invalid ScriptEngineFactory: " + cls.getName());
        }
        ScriptEngineFactory factory = (ScriptEngineFactory) cls.newInstance();
        List<String> names = factory.getNames();
        for (String test : names) {
          if (test.equals(name)) {
            ClassLoader old = Thread.currentThread().getContextClassLoader();
            ScriptEngine engine;
            try {
              // JRuby seems to require the correct TCCL to call getScriptEngine
              Thread.currentThread().setContextClassLoader(factory.getClass().getClassLoader());
              engine = factory.getScriptEngine();
            } finally {
              Thread.currentThread().setContextClassLoader(old);
            }
            LOGGER.finest("Resolved ScriptEngineFactory: " + engine + " for expected name: " + name);
            return engine;
          }
        }
        LOGGER.fine("ScriptEngineFactory: " + factory.getEngineName() + " does not match expected name: " + name);
        return null;
      } catch (Exception e) {
        LOGGER.log(Level.WARNING, "Cannot create ScriptEngineFactory: " + e.getClass().getName(), e);
        return null;
      }
View Full Code Here

            @Override
            public Row next() {
                if (!it.hasNext())
                    return null;
                ScriptEngineFactory factory = it.next();
                return new ValuesRow(
                        rowType,
                        it.nextIndex(), // use nextIndex so that the IDs are 1-based
                        factory.getEngineName(),
                        factory.getEngineVersion(),
                        factory.getLanguageName(),
                        factory.getLanguageVersion(),
                        ++rowCounter /*hidden pk*/);
            }
View Full Code Here

                in.close();
                Class<?> cls = bundle.loadClass(className);
                if (!ScriptEngineFactory.class.isAssignableFrom(cls)) {
                    throw new IllegalStateException("Invalid ScriptEngineFactory: " + cls.getName());
                }
                ScriptEngineFactory factory = (ScriptEngineFactory) cls.newInstance();
                List<String> names = factory.getNames();
                for (String test : names) {
                    if (test.equals(name)) {
                        ClassLoader old = Thread.currentThread().getContextClassLoader();
                        ScriptEngine engine;
                        try {
                            // JRuby seems to require the correct TCCL to call getScriptEngine
                            Thread.currentThread().setContextClassLoader(factory.getClass().getClassLoader());
                            engine = factory.getScriptEngine();
                        } finally {
                            Thread.currentThread().setContextClassLoader(old);
                        }
                        LOG.trace("Resolved ScriptEngineFactory: {} for expected name: {}", engine, name);
                        return engine;
                    }
                }
                LOG.debug("ScriptEngineFactory: {} does not match expected name: {}", factory.getEngineName(), name);
                return null;
            } catch (Exception e) {
                LOG.warn("Cannot create ScriptEngineFactory: " + e.getClass().getName(), e);
                return null;
            }
View Full Code Here

TOP

Related Classes of javax.script.ScriptEngineFactory

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.