org.jruby.Ruby.getGlobalRuntime()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(94)

本文整理了Java中org.jruby.Ruby.getGlobalRuntime方法的一些代码示例,展示了Ruby.getGlobalRuntime的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getGlobalRuntime方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getGlobalRuntime

Ruby.getGlobalRuntime介绍

[英]Get the global runtime.
[中]获取全局运行时。

代码示例

代码示例来源:origin: org.jruby/jruby-core

Ruby getGlobalRuntime(AbstractLocalContextProvider provider) {
  if ( isGlobalRuntimeReady() ) {
    return Ruby.getGlobalRuntime();
  }
  return Ruby.newInstance(provider.config);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@Override
public RubyInstanceConfig getRubyInstanceConfig() {
  if (Ruby.isGlobalRuntimeReady()) return Ruby.getGlobalRuntime().getInstanceConfig();
  else return config;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@Override
public RubyInstanceConfig getRubyInstanceConfig() {
  if (Ruby.isGlobalRuntimeReady()) return Ruby.getGlobalRuntime().getInstanceConfig();
  else return config;
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@Override
public RubyInstanceConfig getRubyInstanceConfig() {
  if (Ruby.isGlobalRuntimeReady()) return Ruby.getGlobalRuntime().getInstanceConfig();
  else return config;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public Ruby getRuntime() {
  if (!Ruby.isGlobalRuntimeReady()) {
    return Ruby.newInstance(config);
  }
  return Ruby.getGlobalRuntime();
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public Ruby getRuntime() {
  if (!Ruby.isGlobalRuntimeReady()) {
    return Ruby.newInstance(config);
  }
  return Ruby.getGlobalRuntime();
}

代码示例来源:origin: org.jruby/jruby-complete

Ruby getGlobalRuntime(AbstractLocalContextProvider provider) {
  if ( isGlobalRuntimeReady() ) {
    return Ruby.getGlobalRuntime();
  }
  return Ruby.newInstance(provider.config);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public Ruby getRuntime() {
  if (!Ruby.isGlobalRuntimeReady()) {
    return Ruby.newInstance(config);
  }
  return Ruby.getGlobalRuntime();
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public Ruby getRuntime() {
  if (!Ruby.isGlobalRuntimeReady()) {
    return Ruby.newInstance(config);
  }
  return Ruby.getGlobalRuntime();
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@Override
public RubyInstanceConfig getRubyInstanceConfig() {
  if (Ruby.isGlobalRuntimeReady()) return Ruby.getGlobalRuntime().getInstanceConfig();
  else return config;
}

代码示例来源:origin: org.jruby/jruby-complete

public static Node buildAST(boolean isCommandLineScript, String arg) {
  Ruby ruby = Ruby.getGlobalRuntime();
  // inline script
  if (isCommandLineScript) return ruby.parse(ByteList.create(arg), "-e", null, 0, false);
  // from file
  FileInputStream fis = null;
  try {
    File file = new File(arg);
    fis = new FileInputStream(file);
    long size = file.length();
    byte[] bytes = new byte[(int)size];
    fis.read(bytes);
    System.out.println("-- processing " + arg + " --");
    return ruby.parse(new ByteList(bytes), arg, null, 0, false);
  } catch (IOException ioe) {
    throw new RuntimeException(ioe);
  } finally {
    try { if (fis != null) fis.close(); } catch(Exception ignored) { }
  }
}

代码示例来源:origin: org.jruby/jruby-core

public static Node buildAST(boolean isCommandLineScript, String arg) {
  Ruby ruby = Ruby.getGlobalRuntime();
  // inline script
  if (isCommandLineScript) return ruby.parse(ByteList.create(arg), "-e", null, 0, false);
  // from file
  FileInputStream fis = null;
  try {
    File file = new File(arg);
    fis = new FileInputStream(file);
    long size = file.length();
    byte[] bytes = new byte[(int)size];
    fis.read(bytes);
    System.out.println("-- processing " + arg + " --");
    return ruby.parse(new ByteList(bytes), arg, null, 0, false);
  } catch (IOException ioe) {
    throw new RuntimeException(ioe);
  } finally {
    try { if (fis != null) fis.close(); } catch(Exception ignored) { }
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public ConcurrentLocalContextProvider(LocalVariableBehavior behavior, boolean lazy) {
  // To save startup time, Ruby runtime instantiation should be delayed as mush as possible
  // so, don't create runtime here.
  if (Ruby.isGlobalRuntimeReady()) config = Ruby.getGlobalRuntime().getInstanceConfig();
  else config = new RubyInstanceConfig();
  this.behavior = behavior;
  this.lazy = lazy;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public static Node buildAST(boolean isCommandLineScript, String arg) {
  Ruby ruby = Ruby.getGlobalRuntime();
  // set to IR mode, since we use different scopes, etc for IR
  ruby.getInstanceConfig().setCompileMode(CompileMode.OFFIR);
  // inline script
  if (isCommandLineScript) return ruby.parse(ByteList.create(arg), "-e", null, 0, false);
  // from file
  FileInputStream fis = null;
  try {
    File file = new File(arg);
    fis = new FileInputStream(file);
    long size = file.length();
    byte[] bytes = new byte[(int)size];
    fis.read(bytes);
    System.out.println("-- processing " + arg + " --");
    return ruby.parse(new ByteList(bytes), arg, null, 0, false);
  } catch (IOException ioe) {
    throw new RuntimeException(ioe);
  } finally {
    try { if (fis != null) fis.close(); } catch(Exception e) { }
  }
}

代码示例来源:origin: org.jruby/jruby-complete

static RubyInstanceConfig getGlobalRuntimeConfigOrNew() {
  return Ruby.isGlobalRuntimeReady() ?
      Ruby.getGlobalRuntime().getInstanceConfig() :
        new RubyInstanceConfig();
}

代码示例来源:origin: org.jruby/jruby-core

static RubyInstanceConfig getGlobalRuntimeConfigOrNew() {
  return Ruby.isGlobalRuntimeReady() ?
      Ruby.getGlobalRuntime().getInstanceConfig() :
        new RubyInstanceConfig();
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public ConcurrentLocalContextProvider(LocalVariableBehavior behavior, boolean lazy) {
  // To save startup time, Ruby runtime instantiation should be delayed as mush as possible
  // so, don't create runtime here.
  if (Ruby.isGlobalRuntimeReady()) config = Ruby.getGlobalRuntime().getInstanceConfig();
  else config = new RubyInstanceConfig();
  this.behavior = behavior;
  this.lazy = lazy;
}

代码示例来源:origin: org.jruby/jruby-core

/**
 * Run the provided (required) block with the "global runtime" set to the current runtime,
 * for libraries that expect to operate against the global runtime.
 */
@JRubyMethod(module = true)
public static IRubyObject with_current_runtime_as_global(ThreadContext context, IRubyObject recv, Block block) {
  final Ruby current = context.runtime;
  final Ruby global = Ruby.getGlobalRuntime();
  try {
    if (current != global) {
      current.useAsGlobalRuntime();
    }
    return block.yield(context, runtime(context, recv)); // previously yield (without an argument)
  }
  finally {
    if (Ruby.getGlobalRuntime() != global) {
      global.useAsGlobalRuntime();
    }
  }
}

代码示例来源:origin: org.jruby/jruby-complete

/**
 * Run the provided (required) block with the "global runtime" set to the current runtime,
 * for libraries that expect to operate against the global runtime.
 */
@JRubyMethod(module = true)
public static IRubyObject with_current_runtime_as_global(ThreadContext context, IRubyObject recv, Block block) {
  final Ruby current = context.runtime;
  final Ruby global = Ruby.getGlobalRuntime();
  try {
    if (current != global) {
      current.useAsGlobalRuntime();
    }
    return block.yield(context, runtime(context, recv)); // previously yield (without an argument)
  }
  finally {
    if (Ruby.getGlobalRuntime() != global) {
      global.useAsGlobalRuntime();
    }
  }
}

代码示例来源:origin: twineworks/ruby-for-pentaho-kettle

private void initLexer(String title) {
 LexerSource lexerSource = new ByteListLexerSource(title, 0, new ByteList(utf8Bytes), null);
 lexerSource.setEncoding(UTF8Encoding.INSTANCE);
 ParserSupport parserSupport = new ParserSupport();
 lexer = new RubyLexer(parserSupport, lexerSource, new NullWarnings(Ruby.getGlobalRuntime()));
 parserSupport.setLexer(lexer);
 parserSupport.setConfiguration(new ParserConfiguration(Ruby.getGlobalRuntime(), 0, false, true, false));
 parserSupport.setResult(new RubyParserResult());
 parserSupport.setWarnings(new NullWarnings(Ruby.getGlobalRuntime()));
 parserSupport.initTopLocalVariables();
 lexer.setState(LexingCommon.EXPR_BEG);
}

相关文章

微信公众号

最新文章

更多

Ruby类方法