本文整理了Java中org.jruby.Ruby.getOrCreateModule
方法的一些代码示例,展示了Ruby.getOrCreateModule
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getOrCreateModule
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getOrCreateModule
[英]From Object, retrieve the named module. If it doesn't exist a new module is created.
[中]从对象中检索命名模块。如果不存在,则创建一个新模块。
代码示例来源:origin: org.jruby/jruby-complete
public static void load(Ruby runtime) {
define(runtime.getOrCreateModule("Timeout"));
}
代码示例来源:origin: org.jruby/jruby-core
public static void load(Ruby runtime) {
define(runtime.getOrCreateModule("Timeout"));
}
代码示例来源:origin: org.jruby.rack/jruby-rack
@Deprecated
public static RubyClass getClass(Ruby runtime, String name, RubyClass parent,
ObjectAllocator allocator, Class annoClass) {
RubyModule jruby = runtime.getOrCreateModule("JRuby");
RubyClass klass = jruby.getClass(name);
if (klass == null) {
klass = jruby.defineClassUnder(name, parent, allocator);
klass.defineAnnotatedMethods(annoClass);
}
return klass;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public void load(Ruby runtime, boolean wrap) {
RubyModule jrubyModule = runtime.getOrCreateModule("JRuby");
RubyModule config = jrubyModule.defineModuleUnder("CONFIG");
config.getSingletonClass().defineAnnotatedMethods(JRubyConfigLibrary.class);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public void load(Ruby runtime, boolean wrap) {
RubyModule jrubyModule = runtime.getOrCreateModule("JRuby");
RubyModule config = jrubyModule.defineModuleUnder("CONFIG");
config.getSingletonClass().defineAnnotatedMethods(JRubyConfigLibrary.class);
}
代码示例来源:origin: com.squareup.rack/rack-servlet
private static RubyClass getRackInputClass(Ruby runtime) {
RubyModule module = runtime.getOrCreateModule("RackServlet");
RubyClass klass = module.getClass("RackInput");
if (klass == null) {
klass = module.defineClassUnder("RackInput", runtime.getObject(), ALLOCATOR);
klass.defineAnnotatedMethods(JRubyRackInput.class);
}
return klass;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public void load(Ruby runtime, boolean wrap) throws IOException {
RubyModule mJRubyUtil = runtime.getOrCreateModule("JRuby").defineModuleUnder("Util");
mJRubyUtil.defineAnnotatedMethods(JRubyUtilLibrary.class);
// core class utils
runtime.getString().defineAnnotatedMethods(StringUtils.class);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public void load(Ruby runtime, boolean wrap) throws IOException {
RubyModule mJRubyUtil = runtime.getOrCreateModule("JRuby").defineModuleUnder("Util");
mJRubyUtil.defineAnnotatedMethods(JRubyUtilLibrary.class);
// core class utils
runtime.getString().defineAnnotatedMethods(StringUtils.class);
}
代码示例来源:origin: square/rack-servlet
private static RubyClass getRackInputClass(Ruby runtime) {
RubyModule module = runtime.getOrCreateModule("RackServlet");
RubyClass klass = module.getClass("RackInput");
if (klass == null) {
klass = module.defineClassUnder("RackInput", runtime.getObject(), ALLOCATOR);
klass.defineAnnotatedMethods(JRubyRackInput.class);
}
return klass;
}
代码示例来源:origin: org.jruby/jruby-complete
public void load(Ruby runtime, boolean wrap) throws IOException {
RubyModule JRuby = runtime.getOrCreateModule("JRuby");
RubyModule JRubyUtil = JRuby.defineModuleUnder("Util");
JRubyUtil.defineAnnotatedMethods(JRubyUtilLibrary.class);
JRubyUtil.setConstant("SEPARATOR", runtime.newString(org.jruby.util.cli.ArgumentProcessor.SEPARATOR));
JRubyUtil.setConstant("ON_WINDOWS", runtime.newBoolean(org.jruby.platform.Platform.IS_WINDOWS));
JRubyUtil.setConstant("ON_SOLARIS", runtime.newBoolean(org.jruby.platform.Platform.IS_SOLARIS));
}
代码示例来源:origin: org.jruby/jruby-core
public void load(Ruby runtime, boolean wrap) throws IOException {
RubyModule JRuby = runtime.getOrCreateModule("JRuby");
RubyModule JRubyUtil = JRuby.defineModuleUnder("Util");
JRubyUtil.defineAnnotatedMethods(JRubyUtilLibrary.class);
JRubyUtil.setConstant("SEPARATOR", runtime.newString(org.jruby.util.cli.ArgumentProcessor.SEPARATOR));
JRubyUtil.setConstant("ON_WINDOWS", runtime.newBoolean(org.jruby.platform.Platform.IS_WINDOWS));
JRubyUtil.setConstant("ON_SOLARIS", runtime.newBoolean(org.jruby.platform.Platform.IS_SOLARIS));
}
代码示例来源:origin: org.jruby.rack/jruby-rack
public static RubyClass getRackInputClass(final Ruby runtime) { // JRuby::Rack::Input
RubyModule jruby = runtime.getOrCreateModule("JRuby");
RubyModule rack = (RubyModule) jruby.getConstantAt("Rack");
if (rack == null) {
rack = runtime.defineModuleUnder("Rack", jruby);
}
RubyClass klass = rack.getClass("Input"); // JRuby::Rack getClass('Input')
if (klass == null) {
final RubyClass parent = runtime.getObject();
klass = rack.defineClassUnder("Input", parent, ALLOCATOR);
klass.defineAnnotatedMethods(RackInput.class);
}
if (jruby.getConstantAt("RackInput") == null) { // backwards compatibility
jruby.setConstant("RackInput", klass); // JRuby::RackInput #deprecated
}
return klass;
}
代码示例来源:origin: org.jruby/jruby-complete
public void load(Ruby runtime, boolean wrap) {
runtime.getLoadService().require("java");
// load Ruby parts of the 'jruby' library
runtime.getLoadService().loadFromClassLoader(runtime.getJRubyClassLoader(), "jruby/jruby.rb", false);
RubyModule JRuby = runtime.getOrCreateModule("JRuby");
JRuby.defineAnnotatedMethods(JRubyLibrary.class);
JRuby.defineAnnotatedMethods(JRubyUtilLibrary.class);
JRuby.defineClassUnder("ThreadLocal", runtime.getObject(), JRubyThreadLocal.ALLOCATOR)
.defineAnnotatedMethods(JRubyExecutionContextLocal.class);
JRuby.defineClassUnder("FiberLocal", runtime.getObject(), JRubyFiberLocal.ALLOCATOR)
.defineAnnotatedMethods(JRubyExecutionContextLocal.class);
RubyModule CONFIG = JRuby.defineModuleUnder("CONFIG");
CONFIG.getSingletonClass().defineAnnotatedMethods(JRubyConfig.class);
}
代码示例来源:origin: org.jruby/jruby-core
public void load(Ruby runtime, boolean wrap) {
runtime.getLoadService().require("java");
// load Ruby parts of the 'jruby' library
runtime.getLoadService().loadFromClassLoader(runtime.getJRubyClassLoader(), "jruby/jruby.rb", false);
RubyModule JRuby = runtime.getOrCreateModule("JRuby");
JRuby.defineAnnotatedMethods(JRubyLibrary.class);
JRuby.defineAnnotatedMethods(JRubyUtilLibrary.class);
JRuby.defineClassUnder("ThreadLocal", runtime.getObject(), JRubyThreadLocal.ALLOCATOR)
.defineAnnotatedMethods(JRubyExecutionContextLocal.class);
JRuby.defineClassUnder("FiberLocal", runtime.getObject(), JRubyFiberLocal.ALLOCATOR)
.defineAnnotatedMethods(JRubyExecutionContextLocal.class);
RubyModule CONFIG = JRuby.defineModuleUnder("CONFIG");
CONFIG.getSingletonClass().defineAnnotatedMethods(JRubyConfig.class);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public void load(Ruby runtime, boolean wrap) {
ThreadContext context = runtime.getCurrentContext();
runtime.getLoadService().require("java");
// load Ruby parts of the 'jruby' library
runtime.getLoadService().loadFromClassLoader(runtime.getJRubyClassLoader(), "jruby/jruby.rb", false);
// define JRuby module
RubyModule jrubyModule = runtime.getOrCreateModule("JRuby");
jrubyModule.defineAnnotatedMethods(JRubyLibrary.class);
jrubyModule.defineAnnotatedMethods(JRubyUtilLibrary.class);
RubyClass threadLocalClass = jrubyModule.defineClassUnder("ThreadLocal", runtime.getObject(), JRubyThreadLocal.ALLOCATOR);
threadLocalClass.defineAnnotatedMethods(JRubyExecutionContextLocal.class);
RubyClass fiberLocalClass = jrubyModule.defineClassUnder("FiberLocal", runtime.getObject(), JRubyFiberLocal.ALLOCATOR);
fiberLocalClass.defineAnnotatedMethods(JRubyExecutionContextLocal.class);
new JRubyConfigLibrary().load(runtime, wrap);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public void load(Ruby runtime, boolean wrap) {
ThreadContext context = runtime.getCurrentContext();
runtime.getLoadService().require("java");
// load Ruby parts of the 'jruby' library
runtime.getLoadService().loadFromClassLoader(runtime.getJRubyClassLoader(), "jruby/jruby.rb", false);
// define JRuby module
RubyModule jrubyModule = runtime.getOrCreateModule("JRuby");
jrubyModule.defineAnnotatedMethods(JRubyLibrary.class);
jrubyModule.defineAnnotatedMethods(JRubyUtilLibrary.class);
RubyClass threadLocalClass = jrubyModule.defineClassUnder("ThreadLocal", runtime.getObject(), JRubyThreadLocal.ALLOCATOR);
threadLocalClass.defineAnnotatedMethods(JRubyExecutionContextLocal.class);
RubyClass fiberLocalClass = jrubyModule.defineClassUnder("FiberLocal", runtime.getObject(), JRubyFiberLocal.ALLOCATOR);
fiberLocalClass.defineAnnotatedMethods(JRubyExecutionContextLocal.class);
new JRubyConfigLibrary().load(runtime, wrap);
}
代码示例来源:origin: org.jruby/yecht
public boolean basicLoad(final Ruby runtime) throws IOException {
ThreadContext ctx = runtime.getCurrentContext();
RubyModule rb_yaml = runtime.getOrCreateModule("YAML");
RubyModule rb_yecht = rb_yaml.defineModuleUnder("Yecht");
rb_yecht.defineConstant("VERSION", runtime.newString(YAML.YECHT_VERSION));
内容来源于网络,如有侵权,请联系作者删除!