Package javax.script

Examples of javax.script.ScriptEngineManager


  ScriptEngineManager factory = null;
 
  public ItemSimpleCsvMapping mappings[];
 
  public ItemSimpleCsvTransformation() {
    factory = new ScriptEngineManager();
  }
View Full Code Here


        show("java.version");
        show("java.vendor");
        show("java.vm.version");
        show("java.vm.vendor");
        show("java.vm.name");
        ScriptEngineManager sem = new ScriptEngineManager();
        assertNotNull(sem);
        Boolean isBSFClass = null;
        try {
            // Check for a method that's unlikely to be in any but the BSF implementation
            sem.getBindings().getClass().getDeclaredMethod("validateKey", new Class[]{Object.class});
            isBSFClass = Boolean.TRUE;
        } catch (SecurityException e) {
            // Leave as null - we don't know the answer
        } catch (NoSuchMethodException e) {
            isBSFClass = Boolean.FALSE;
        }
        if (isBSFClass == null) {
            System.out.println("ScriptEngineManager class - implementation unknown");
        } else if (isBSFClass.booleanValue()) {
            System.out.println("ScriptEngineManager class is from Apache BSF");
        } else {
            System.out.println("ScriptEngineManager class is not Apache BSF");
        }
        final int count = sem.getEngineFactories().size();
        assertTrue("Must find some factories",count>0);
        List l = sem.getEngineFactories();
        System.out.println("Factory count: "+count);
        for(int i=0; i < count; i++){
            System.out.println(l.get(i).getClass().getName());
        }
    }
View Full Code Here

        super("ScriptEngineManagerTest");
    }

    protected void setUp() throws Exception {
        super.setUp();
        mgr = new ScriptEngineManager();
    }
View Full Code Here

  /**
   * Constructor.
   */
  protected ScriptRunner() {
    manager = new ScriptEngineManager();
    jsEngine = manager.getEngineByName("JavaScript");
    context = jsEngine.getContext();
    context.setAttribute("vstar", VStarScriptingAPI.getInstance(), context
        .getScopes().get(0));
    scriptFileChooser = new JFileChooser();
View Full Code Here

                                          final GnucashWritableTransactionSplit myAccountSplit,
                                          final int scriptnum,
                                          final String language,
                                          final String scriptPath,
                                          final Reader reader) {
        ScriptEngineManager mgr = new ScriptEngineManager();

        ScriptEngine jsEngine = mgr.getEngineByName(language);

        jsEngine.put("text", text);
        jsEngine.put("value", value);
        jsEngine.put("transaction", myAccountSplit.getTransaction());
        jsEngine.put("myAccountSplit", myAccountSplit);
View Full Code Here

        assertEquals(ret, "func1", "A module could not be loaded using a relative path.");
       
    }
   
    private ScriptEngine getScriptEngine() {
        ScriptEngineManager manager = new ScriptEngineManager();
        return manager.getEngineByName("rhino-nonjdk");              
    }
View Full Code Here

    public ScriptEngine getEngineByLanguage(String language) {

        ScriptEngine engine;
        engine = engineByName.get(language);
        if (engine == null) {
            ScriptEngineManager manager = new ScriptEngineManager();
            engine = manager.getEngineByName(language);
            engineByName.put(language, engine);
        }
        return engine;

    }
View Full Code Here

        String engineName = conf.getSimpleValue("language",null);
        if (engineName==null)
            throw new InvalidPluginConfigurationException("No (valid) language given ");

        ScriptEngineManager seMgr = new ScriptEngineManager();
        engine = seMgr.getEngineByName(engineName);

        String scriptName = conf.getSimpleValue("scriptName", null);
        if (scriptName ==null)
            throw new InvalidPluginConfigurationException("No (valid) script name given");
View Full Code Here

        return LoggingUtils.getLogger(this);
    }

    private ScriptEngine get(final String shortName) {
        // try by name
        ScriptEngineManager sem = new ScriptEngineManager();
        javax.script.ScriptEngine engine = sem.getEngineByName(shortName);
        if (null == engine) {
            // try by extension
            engine = sem.getEngineByExtension(shortName);
        }
        return engine;
    }
View Full Code Here

        if (SHOW_PROVIDERS.equalsIgnoreCase(show)) {
            processProviders(false);        
            return;
        }
        ScriptEngineManager mgr;
        try {
            mgr = new ScriptEngineManager();
        } catch (Error e1) {
            System.out.println("Could not create ScriptEngineManager: "+e1);
            System.out.println("Checking which factories cannot be instantiated ...");
            processProviders(true);
            return;
        }
        final List engineFactories = mgr.getEngineFactories();
        if (engineFactories.isEmpty()){
            throw new RuntimeException("Could not find any engine factories");
        }

        final int engineCount = engineFactories.size();
        if (SHOW_FACTORIES.equalsIgnoreCase(show)) {
            System.err.println("Found "+engineCount+ " engine factories");
            for (Iterator iter = engineFactories.iterator(); iter.hasNext();){
                ScriptEngineFactory fac = (ScriptEngineFactory) iter.next();
                showFactory(fac, false);
            }
            return;
        }

        if (language == null && extension == null && inFileName != null) {
            int i = inFileName.lastIndexOf('.');
            if (i > 0) {
                extension = inFileName.substring(i+1);
            }
        }
        if (extension == null && language == null) {
            throw new IllegalArgumentException("unable to determine language");
        }

        try {
            ScriptEngine engine;
            if (language != null) {
                engine = mgr.getEngineByName(language);
                if (engine == null){
                    throw new IllegalArgumentException("unable to find engine using Language: "+language);
                }
            } else {
                engine = mgr.getEngineByExtension(extension);
                if (engine == null){
                    throw new IllegalArgumentException("unable to find engine using Extension: "+extension);
                }
            }
            if (SHOW_ENGINE.equalsIgnoreCase(show)){
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.