Package org.jruby.embed

Examples of org.jruby.embed.ScriptingContainer


        assertEquals("3.4.4", new ScriptingContainer().runScriptlet("require 'sass';Sass.version[:number]"));
    }

    @Test
    public void correctCompassIsPackaged() {
        assertEquals("1.0.1", new ScriptingContainer().runScriptlet("require 'compass';Compass::VERSION"));
    }
View Full Code Here


    private boolean initialized;
    private File configLocation;

    public void compile() {
        initialize();
        new ScriptingContainer().runScriptlet(buildCompileScript());
    }
View Full Code Here

        new ScriptingContainer().runScriptlet(buildCompileScript());
    }

    private void initialize() {
        if (!initialized) {
            new ScriptingContainer().runScriptlet(buildInitializationScript());
            initialized = true;
        }
    }
View Full Code Here

    @Inject
    public JRubyScriptEngineService(Settings settings) {
        super(settings);

        this.container = new ScriptingContainer(LocalContextScope.THREADSAFE);
        this.container.setCompatVersion(CompatVersion.RUBY1_9);
    }
View Full Code Here

        master.getContainer().callMethod(master.getMain(), "ruby_plugin_loader=", this);
    }
   
    @Override
    public Plugin loadPlugin(File file) throws InvalidPluginException {
        ScriptingContainer container = master.getContainer();
        String path = file.getAbsolutePath();

        master.executeScriptAt(path);

        return (Plugin) container.callMethod(master.getMain(), "instantiate_plugin", path);
    }
View Full Code Here

    this.context = null;
    this.handler = null;
  }

  private void initializeScriptingContext() {
    context = new ScriptingContainer(LocalContextScope.SINGLETHREAD);
    context.setEnvironment(config.getEnvironment());
    context.runScriptlet(config.getKirkVersionStamper());

    this.bootstrapper = context.runScriptlet(
      PathType.ABSOLUTE, config.getBootstrapPath());
View Full Code Here

        return 0;
    }

    private List<Job> configureJobs(String jobSetupScript, String[] arguments) throws Exception {
        ScriptingContainer runtime = InstanceContainer.getRuntime();
        Configuration conf = getConf();
        conf.set(InstanceContainer.JOB_SETUP_SCRIPT_KEY, jobSetupScript);
        Object contextClass = runtime.runScriptlet("Rubydoop::Context");
        Object context = runtime.callMethod(contextClass, "new", conf, arguments);
        runtime.put("$rubydoop_context", context);

        try {
            runtime.callMethod(null, "require", jobSetupScript);
        } catch (InvokeFailedException e) {
            String message = String.format("Could not load job setup script (\"%s\"): \"%s\"", jobSetupScript, e.getMessage());
            throw new RubydoopRunnerException(message, e);
        }
       
        List<Job> jobs = (List<Job>) runtime.callMethod(context, "jobs");

        for (Job job : jobs) {
            job.setJarByClass(getClass());
        }
View Full Code Here

        this.instance = instance;
    }

    public static synchronized ScriptingContainer getRuntime() {
        if (globalRuntime == null) {
            globalRuntime = new ScriptingContainer(LocalVariableBehavior.PERSISTENT);
            globalRuntime.setCompatVersion(CompatVersion.RUBY1_9);
            globalRuntime.callMethod(null, "require", "setup_load_path");
            globalRuntime.callMethod(null, "require", "rubydoop");
        }
        return globalRuntime;
View Full Code Here

    public static InstanceContainer wrapInstance(Object instance) {
        return new InstanceContainer(getRuntime(), instance);
    }

    public static InstanceContainer createInstance(Configuration conf, String rubyClassProperty) {
        ScriptingContainer runtime = getRuntime();
        Object rubyClass = lookupClassInternal(runtime, conf, rubyClassProperty);
        return new InstanceContainer(runtime, runtime.callMethod(rubyClass, "new"));
    }
View Full Code Here

        Object rubyClass = lookupClassInternal(runtime, conf, rubyClassProperty);
        return new InstanceContainer(runtime, runtime.callMethod(rubyClass, "new"));
    }

    public static InstanceContainer lookupClass(Configuration conf, String rubyClassProperty) {
        ScriptingContainer runtime = getRuntime();
        Object rubyClass = lookupClassInternal(runtime, conf, rubyClassProperty);
        return new InstanceContainer(runtime, rubyClass);
    }
View Full Code Here

TOP

Related Classes of org.jruby.embed.ScriptingContainer

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.