Package org.jruby.embed

Examples of org.jruby.embed.ScriptingContainer


    @Provides @Singleton RackServlet provideRackServlet(IRubyObject application) {
      return new RackServlet(new JRubyRackApplication(application));
    }

    @Provides IRubyObject provideApplication() {
      ScriptingContainer ruby = new ScriptingContainer();
      return ruby.parse("lambda { |env| [200, {}, ['Hello, World!']] }").run();
    }
View Full Code Here


  @Before public void setUp() throws Exception {
    // Silence logging.
    System.setProperty(DEFAULT_LOG_LEVEL_KEY, "WARN");

    // Build the Rack servlet.
    ScriptingContainer ruby = new ScriptingContainer();
    IRubyObject application = ruby.parse(CLASSPATH, "application.rb").run();
    RackServlet servlet = new RackServlet(new JRubyRackApplication(application));

    server = new ExampleServer(servlet, "/*");
    server.start();
    client = new DefaultHttpClient();
View Full Code Here

  }

  private IRubyObject createApplication() {
    // There's a lot you could do here; for now, we just read a rackup file from the classpath,
    // then build a Rack application based on it.
    ScriptingContainer container = new ScriptingContainer();
    container.put("builder_script", readResource("config.ru"));
    return container.parse("require 'rack'; Rack::Builder.new_from_string(builder_script)").run();
  }
View Full Code Here

  @Before public void setUp() throws Exception {
    // Silence logging.
    System.setProperty(DEFAULT_LOG_LEVEL_KEY, "WARN");

    // Build the Rack servlet.
    ScriptingContainer ruby = new ScriptingContainer();
    IRubyObject application = ruby.parse(CLASSPATH, "application.rb").run();
    RackServlet servlet = new RackServlet(new JRubyRackApplication(application));

    server = new ExampleServer(servlet, "/*");
    server.start();
    client = new DefaultHttpClient();
View Full Code Here

  @Before public void setUp() throws Exception {
    // Silence logging.
    System.setProperty(DEFAULT_LOG_LEVEL_KEY, "WARN");

    // Build the Rack servlet.
    ScriptingContainer ruby = new ScriptingContainer();
    IRubyObject application = ruby.parse("lambda { |env| [200, {}, ['Hello, World!']] }").run();
    RackServlet servlet = new RackServlet(new JRubyRackApplication(application));

    server = new ExampleServer(servlet, "/*");
    server.start();
    client = new DefaultHttpClient();
View Full Code Here

public class TestJRuby {

    private static String puts_x="puts x";
       
    @Test public void testPuts_persist() {
        ScriptingContainer container = new ScriptingContainer();
        container.put("x", 12345);
        container.runScriptlet(puts_x);
    }
View Full Code Here

    }
    @Test public void testEachArrayList() {
        List<Object> list = new ArrayList<Object>();
        list.add("one");
        list.add("two");
        ScriptingContainer container = new ScriptingContainer();
        container.put("list", list);
        String each = "list.each do |v|\n"
            + "  puts v\n"
            + "end";
        container.runScriptlet(each);
    }
View Full Code Here

    public ScriptEngine getScriptEngine() {
        LocalContextScope scope = SystemPropertyCatcher.getScope(LocalContextScope.SINGLETON);
        LocalVariableBehavior behavior = SystemPropertyCatcher.getBehavior(LocalVariableBehavior.GLOBAL);
        boolean lazy = SystemPropertyCatcher.isLazy(true);
        ScriptingContainer container = createScriptingContainer(scope, behavior, lazy);
            //new ScriptingContainer(scope, behavior, lazy);
        SystemPropertyCatcher.setClassLoader(container);
        SystemPropertyCatcher.setConfiguration(container);
        JRubyEngine engine = new JRubyEngine(container, this);
        return (ScriptEngine)engine;
View Full Code Here

     * @param lazy
     * @return The standard ScriptingContainer
     */
    public ScriptingContainer createScriptingContainer(LocalContextScope scope,
            LocalVariableBehavior behavior, boolean lazy) {
        return new ScriptingContainer(scope, behavior, lazy);
    }
View Full Code Here

  /**
   * Private constructor.
   */
  private Container() {
    scriptingContainer = new ScriptingContainer(LocalContextScope.THREADSAFE, LocalVariableBehavior.TRANSIENT);
    scriptingContainer.setCompileMode(CompileMode.JIT);
  }
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.