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

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

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

Ruby.getOrCreateModule介绍

[英]From Object, retrieve the named module. If it doesn't exist a new module is created.
[中]从对象中检索命名模块。如果不存在,则创建一个新模块。

代码示例

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

  1. public static void load(Ruby runtime) {
  2. define(runtime.getOrCreateModule("Timeout"));
  3. }

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

  1. public static void load(Ruby runtime) {
  2. define(runtime.getOrCreateModule("Timeout"));
  3. }

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

  1. @Deprecated
  2. public static RubyClass getClass(Ruby runtime, String name, RubyClass parent,
  3. ObjectAllocator allocator, Class annoClass) {
  4. RubyModule jruby = runtime.getOrCreateModule("JRuby");
  5. RubyClass klass = jruby.getClass(name);
  6. if (klass == null) {
  7. klass = jruby.defineClassUnder(name, parent, allocator);
  8. klass.defineAnnotatedMethods(annoClass);
  9. }
  10. return klass;
  11. }

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

  1. public void load(Ruby runtime, boolean wrap) {
  2. RubyModule jrubyModule = runtime.getOrCreateModule("JRuby");
  3. RubyModule config = jrubyModule.defineModuleUnder("CONFIG");
  4. config.getSingletonClass().defineAnnotatedMethods(JRubyConfigLibrary.class);
  5. }

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

  1. public void load(Ruby runtime, boolean wrap) {
  2. RubyModule jrubyModule = runtime.getOrCreateModule("JRuby");
  3. RubyModule config = jrubyModule.defineModuleUnder("CONFIG");
  4. config.getSingletonClass().defineAnnotatedMethods(JRubyConfigLibrary.class);
  5. }

代码示例来源:origin: com.squareup.rack/rack-servlet

  1. private static RubyClass getRackInputClass(Ruby runtime) {
  2. RubyModule module = runtime.getOrCreateModule("RackServlet");
  3. RubyClass klass = module.getClass("RackInput");
  4. if (klass == null) {
  5. klass = module.defineClassUnder("RackInput", runtime.getObject(), ALLOCATOR);
  6. klass.defineAnnotatedMethods(JRubyRackInput.class);
  7. }
  8. return klass;
  9. }

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

  1. public void load(Ruby runtime, boolean wrap) throws IOException {
  2. RubyModule mJRubyUtil = runtime.getOrCreateModule("JRuby").defineModuleUnder("Util");
  3. mJRubyUtil.defineAnnotatedMethods(JRubyUtilLibrary.class);
  4. // core class utils
  5. runtime.getString().defineAnnotatedMethods(StringUtils.class);
  6. }

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

  1. public void load(Ruby runtime, boolean wrap) throws IOException {
  2. RubyModule mJRubyUtil = runtime.getOrCreateModule("JRuby").defineModuleUnder("Util");
  3. mJRubyUtil.defineAnnotatedMethods(JRubyUtilLibrary.class);
  4. // core class utils
  5. runtime.getString().defineAnnotatedMethods(StringUtils.class);
  6. }

代码示例来源:origin: square/rack-servlet

  1. private static RubyClass getRackInputClass(Ruby runtime) {
  2. RubyModule module = runtime.getOrCreateModule("RackServlet");
  3. RubyClass klass = module.getClass("RackInput");
  4. if (klass == null) {
  5. klass = module.defineClassUnder("RackInput", runtime.getObject(), ALLOCATOR);
  6. klass.defineAnnotatedMethods(JRubyRackInput.class);
  7. }
  8. return klass;
  9. }

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

  1. public void load(Ruby runtime, boolean wrap) throws IOException {
  2. RubyModule JRuby = runtime.getOrCreateModule("JRuby");
  3. RubyModule JRubyUtil = JRuby.defineModuleUnder("Util");
  4. JRubyUtil.defineAnnotatedMethods(JRubyUtilLibrary.class);
  5. JRubyUtil.setConstant("SEPARATOR", runtime.newString(org.jruby.util.cli.ArgumentProcessor.SEPARATOR));
  6. JRubyUtil.setConstant("ON_WINDOWS", runtime.newBoolean(org.jruby.platform.Platform.IS_WINDOWS));
  7. JRubyUtil.setConstant("ON_SOLARIS", runtime.newBoolean(org.jruby.platform.Platform.IS_SOLARIS));
  8. }

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

  1. public void load(Ruby runtime, boolean wrap) throws IOException {
  2. RubyModule JRuby = runtime.getOrCreateModule("JRuby");
  3. RubyModule JRubyUtil = JRuby.defineModuleUnder("Util");
  4. JRubyUtil.defineAnnotatedMethods(JRubyUtilLibrary.class);
  5. JRubyUtil.setConstant("SEPARATOR", runtime.newString(org.jruby.util.cli.ArgumentProcessor.SEPARATOR));
  6. JRubyUtil.setConstant("ON_WINDOWS", runtime.newBoolean(org.jruby.platform.Platform.IS_WINDOWS));
  7. JRubyUtil.setConstant("ON_SOLARIS", runtime.newBoolean(org.jruby.platform.Platform.IS_SOLARIS));
  8. }

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

  1. public static RubyClass getRackInputClass(final Ruby runtime) { // JRuby::Rack::Input
  2. RubyModule jruby = runtime.getOrCreateModule("JRuby");
  3. RubyModule rack = (RubyModule) jruby.getConstantAt("Rack");
  4. if (rack == null) {
  5. rack = runtime.defineModuleUnder("Rack", jruby);
  6. }
  7. RubyClass klass = rack.getClass("Input"); // JRuby::Rack getClass('Input')
  8. if (klass == null) {
  9. final RubyClass parent = runtime.getObject();
  10. klass = rack.defineClassUnder("Input", parent, ALLOCATOR);
  11. klass.defineAnnotatedMethods(RackInput.class);
  12. }
  13. if (jruby.getConstantAt("RackInput") == null) { // backwards compatibility
  14. jruby.setConstant("RackInput", klass); // JRuby::RackInput #deprecated
  15. }
  16. return klass;
  17. }

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

  1. public void load(Ruby runtime, boolean wrap) {
  2. runtime.getLoadService().require("java");
  3. // load Ruby parts of the 'jruby' library
  4. runtime.getLoadService().loadFromClassLoader(runtime.getJRubyClassLoader(), "jruby/jruby.rb", false);
  5. RubyModule JRuby = runtime.getOrCreateModule("JRuby");
  6. JRuby.defineAnnotatedMethods(JRubyLibrary.class);
  7. JRuby.defineAnnotatedMethods(JRubyUtilLibrary.class);
  8. JRuby.defineClassUnder("ThreadLocal", runtime.getObject(), JRubyThreadLocal.ALLOCATOR)
  9. .defineAnnotatedMethods(JRubyExecutionContextLocal.class);
  10. JRuby.defineClassUnder("FiberLocal", runtime.getObject(), JRubyFiberLocal.ALLOCATOR)
  11. .defineAnnotatedMethods(JRubyExecutionContextLocal.class);
  12. RubyModule CONFIG = JRuby.defineModuleUnder("CONFIG");
  13. CONFIG.getSingletonClass().defineAnnotatedMethods(JRubyConfig.class);
  14. }

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

  1. public void load(Ruby runtime, boolean wrap) {
  2. runtime.getLoadService().require("java");
  3. // load Ruby parts of the 'jruby' library
  4. runtime.getLoadService().loadFromClassLoader(runtime.getJRubyClassLoader(), "jruby/jruby.rb", false);
  5. RubyModule JRuby = runtime.getOrCreateModule("JRuby");
  6. JRuby.defineAnnotatedMethods(JRubyLibrary.class);
  7. JRuby.defineAnnotatedMethods(JRubyUtilLibrary.class);
  8. JRuby.defineClassUnder("ThreadLocal", runtime.getObject(), JRubyThreadLocal.ALLOCATOR)
  9. .defineAnnotatedMethods(JRubyExecutionContextLocal.class);
  10. JRuby.defineClassUnder("FiberLocal", runtime.getObject(), JRubyFiberLocal.ALLOCATOR)
  11. .defineAnnotatedMethods(JRubyExecutionContextLocal.class);
  12. RubyModule CONFIG = JRuby.defineModuleUnder("CONFIG");
  13. CONFIG.getSingletonClass().defineAnnotatedMethods(JRubyConfig.class);
  14. }

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

  1. public void load(Ruby runtime, boolean wrap) {
  2. ThreadContext context = runtime.getCurrentContext();
  3. runtime.getLoadService().require("java");
  4. // load Ruby parts of the 'jruby' library
  5. runtime.getLoadService().loadFromClassLoader(runtime.getJRubyClassLoader(), "jruby/jruby.rb", false);
  6. // define JRuby module
  7. RubyModule jrubyModule = runtime.getOrCreateModule("JRuby");
  8. jrubyModule.defineAnnotatedMethods(JRubyLibrary.class);
  9. jrubyModule.defineAnnotatedMethods(JRubyUtilLibrary.class);
  10. RubyClass threadLocalClass = jrubyModule.defineClassUnder("ThreadLocal", runtime.getObject(), JRubyThreadLocal.ALLOCATOR);
  11. threadLocalClass.defineAnnotatedMethods(JRubyExecutionContextLocal.class);
  12. RubyClass fiberLocalClass = jrubyModule.defineClassUnder("FiberLocal", runtime.getObject(), JRubyFiberLocal.ALLOCATOR);
  13. fiberLocalClass.defineAnnotatedMethods(JRubyExecutionContextLocal.class);
  14. new JRubyConfigLibrary().load(runtime, wrap);
  15. }

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

  1. public void load(Ruby runtime, boolean wrap) {
  2. ThreadContext context = runtime.getCurrentContext();
  3. runtime.getLoadService().require("java");
  4. // load Ruby parts of the 'jruby' library
  5. runtime.getLoadService().loadFromClassLoader(runtime.getJRubyClassLoader(), "jruby/jruby.rb", false);
  6. // define JRuby module
  7. RubyModule jrubyModule = runtime.getOrCreateModule("JRuby");
  8. jrubyModule.defineAnnotatedMethods(JRubyLibrary.class);
  9. jrubyModule.defineAnnotatedMethods(JRubyUtilLibrary.class);
  10. RubyClass threadLocalClass = jrubyModule.defineClassUnder("ThreadLocal", runtime.getObject(), JRubyThreadLocal.ALLOCATOR);
  11. threadLocalClass.defineAnnotatedMethods(JRubyExecutionContextLocal.class);
  12. RubyClass fiberLocalClass = jrubyModule.defineClassUnder("FiberLocal", runtime.getObject(), JRubyFiberLocal.ALLOCATOR);
  13. fiberLocalClass.defineAnnotatedMethods(JRubyExecutionContextLocal.class);
  14. new JRubyConfigLibrary().load(runtime, wrap);
  15. }

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

  1. public boolean basicLoad(final Ruby runtime) throws IOException {
  2. ThreadContext ctx = runtime.getCurrentContext();
  3. RubyModule rb_yaml = runtime.getOrCreateModule("YAML");
  4. RubyModule rb_yecht = rb_yaml.defineModuleUnder("Yecht");
  5. rb_yecht.defineConstant("VERSION", runtime.newString(YAML.YECHT_VERSION));

相关文章

Ruby类方法