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

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

本文整理了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

  1. Ruby getGlobalRuntime(AbstractLocalContextProvider provider) {
  2. if ( isGlobalRuntimeReady() ) {
  3. return Ruby.getGlobalRuntime();
  4. }
  5. return Ruby.newInstance(provider.config);
  6. }

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

  1. @Override
  2. public RubyInstanceConfig getRubyInstanceConfig() {
  3. if (Ruby.isGlobalRuntimeReady()) return Ruby.getGlobalRuntime().getInstanceConfig();
  4. else return config;
  5. }

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

  1. @Override
  2. public RubyInstanceConfig getRubyInstanceConfig() {
  3. if (Ruby.isGlobalRuntimeReady()) return Ruby.getGlobalRuntime().getInstanceConfig();
  4. else return config;
  5. }

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

  1. @Override
  2. public RubyInstanceConfig getRubyInstanceConfig() {
  3. if (Ruby.isGlobalRuntimeReady()) return Ruby.getGlobalRuntime().getInstanceConfig();
  4. else return config;
  5. }

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

  1. public Ruby getRuntime() {
  2. if (!Ruby.isGlobalRuntimeReady()) {
  3. return Ruby.newInstance(config);
  4. }
  5. return Ruby.getGlobalRuntime();
  6. }

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

  1. public Ruby getRuntime() {
  2. if (!Ruby.isGlobalRuntimeReady()) {
  3. return Ruby.newInstance(config);
  4. }
  5. return Ruby.getGlobalRuntime();
  6. }

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

  1. Ruby getGlobalRuntime(AbstractLocalContextProvider provider) {
  2. if ( isGlobalRuntimeReady() ) {
  3. return Ruby.getGlobalRuntime();
  4. }
  5. return Ruby.newInstance(provider.config);
  6. }

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

  1. public Ruby getRuntime() {
  2. if (!Ruby.isGlobalRuntimeReady()) {
  3. return Ruby.newInstance(config);
  4. }
  5. return Ruby.getGlobalRuntime();
  6. }

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

  1. public Ruby getRuntime() {
  2. if (!Ruby.isGlobalRuntimeReady()) {
  3. return Ruby.newInstance(config);
  4. }
  5. return Ruby.getGlobalRuntime();
  6. }

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

  1. @Override
  2. public RubyInstanceConfig getRubyInstanceConfig() {
  3. if (Ruby.isGlobalRuntimeReady()) return Ruby.getGlobalRuntime().getInstanceConfig();
  4. else return config;
  5. }

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

  1. public static Node buildAST(boolean isCommandLineScript, String arg) {
  2. Ruby ruby = Ruby.getGlobalRuntime();
  3. // inline script
  4. if (isCommandLineScript) return ruby.parse(ByteList.create(arg), "-e", null, 0, false);
  5. // from file
  6. FileInputStream fis = null;
  7. try {
  8. File file = new File(arg);
  9. fis = new FileInputStream(file);
  10. long size = file.length();
  11. byte[] bytes = new byte[(int)size];
  12. fis.read(bytes);
  13. System.out.println("-- processing " + arg + " --");
  14. return ruby.parse(new ByteList(bytes), arg, null, 0, false);
  15. } catch (IOException ioe) {
  16. throw new RuntimeException(ioe);
  17. } finally {
  18. try { if (fis != null) fis.close(); } catch(Exception ignored) { }
  19. }
  20. }

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

  1. public static Node buildAST(boolean isCommandLineScript, String arg) {
  2. Ruby ruby = Ruby.getGlobalRuntime();
  3. // inline script
  4. if (isCommandLineScript) return ruby.parse(ByteList.create(arg), "-e", null, 0, false);
  5. // from file
  6. FileInputStream fis = null;
  7. try {
  8. File file = new File(arg);
  9. fis = new FileInputStream(file);
  10. long size = file.length();
  11. byte[] bytes = new byte[(int)size];
  12. fis.read(bytes);
  13. System.out.println("-- processing " + arg + " --");
  14. return ruby.parse(new ByteList(bytes), arg, null, 0, false);
  15. } catch (IOException ioe) {
  16. throw new RuntimeException(ioe);
  17. } finally {
  18. try { if (fis != null) fis.close(); } catch(Exception ignored) { }
  19. }
  20. }

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

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

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

  1. public static Node buildAST(boolean isCommandLineScript, String arg) {
  2. Ruby ruby = Ruby.getGlobalRuntime();
  3. // set to IR mode, since we use different scopes, etc for IR
  4. ruby.getInstanceConfig().setCompileMode(CompileMode.OFFIR);
  5. // inline script
  6. if (isCommandLineScript) return ruby.parse(ByteList.create(arg), "-e", null, 0, false);
  7. // from file
  8. FileInputStream fis = null;
  9. try {
  10. File file = new File(arg);
  11. fis = new FileInputStream(file);
  12. long size = file.length();
  13. byte[] bytes = new byte[(int)size];
  14. fis.read(bytes);
  15. System.out.println("-- processing " + arg + " --");
  16. return ruby.parse(new ByteList(bytes), arg, null, 0, false);
  17. } catch (IOException ioe) {
  18. throw new RuntimeException(ioe);
  19. } finally {
  20. try { if (fis != null) fis.close(); } catch(Exception e) { }
  21. }
  22. }

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

  1. static RubyInstanceConfig getGlobalRuntimeConfigOrNew() {
  2. return Ruby.isGlobalRuntimeReady() ?
  3. Ruby.getGlobalRuntime().getInstanceConfig() :
  4. new RubyInstanceConfig();
  5. }

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

  1. static RubyInstanceConfig getGlobalRuntimeConfigOrNew() {
  2. return Ruby.isGlobalRuntimeReady() ?
  3. Ruby.getGlobalRuntime().getInstanceConfig() :
  4. new RubyInstanceConfig();
  5. }

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

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

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

  1. /**
  2. * Run the provided (required) block with the "global runtime" set to the current runtime,
  3. * for libraries that expect to operate against the global runtime.
  4. */
  5. @JRubyMethod(module = true)
  6. public static IRubyObject with_current_runtime_as_global(ThreadContext context, IRubyObject recv, Block block) {
  7. final Ruby current = context.runtime;
  8. final Ruby global = Ruby.getGlobalRuntime();
  9. try {
  10. if (current != global) {
  11. current.useAsGlobalRuntime();
  12. }
  13. return block.yield(context, runtime(context, recv)); // previously yield (without an argument)
  14. }
  15. finally {
  16. if (Ruby.getGlobalRuntime() != global) {
  17. global.useAsGlobalRuntime();
  18. }
  19. }
  20. }

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

  1. /**
  2. * Run the provided (required) block with the "global runtime" set to the current runtime,
  3. * for libraries that expect to operate against the global runtime.
  4. */
  5. @JRubyMethod(module = true)
  6. public static IRubyObject with_current_runtime_as_global(ThreadContext context, IRubyObject recv, Block block) {
  7. final Ruby current = context.runtime;
  8. final Ruby global = Ruby.getGlobalRuntime();
  9. try {
  10. if (current != global) {
  11. current.useAsGlobalRuntime();
  12. }
  13. return block.yield(context, runtime(context, recv)); // previously yield (without an argument)
  14. }
  15. finally {
  16. if (Ruby.getGlobalRuntime() != global) {
  17. global.useAsGlobalRuntime();
  18. }
  19. }
  20. }

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

  1. private void initLexer(String title) {
  2. LexerSource lexerSource = new ByteListLexerSource(title, 0, new ByteList(utf8Bytes), null);
  3. lexerSource.setEncoding(UTF8Encoding.INSTANCE);
  4. ParserSupport parserSupport = new ParserSupport();
  5. lexer = new RubyLexer(parserSupport, lexerSource, new NullWarnings(Ruby.getGlobalRuntime()));
  6. parserSupport.setLexer(lexer);
  7. parserSupport.setConfiguration(new ParserConfiguration(Ruby.getGlobalRuntime(), 0, false, true, false));
  8. parserSupport.setResult(new RubyParserResult());
  9. parserSupport.setWarnings(new NullWarnings(Ruby.getGlobalRuntime()));
  10. parserSupport.initTopLocalVariables();
  11. lexer.setState(LexingCommon.EXPR_BEG);
  12. }

相关文章

Ruby类方法