本文整理了Java中org.jruby.RubyModule.defineAutoload
方法的一些代码示例,展示了RubyModule.defineAutoload
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RubyModule.defineAutoload
方法的具体详情如下:
包路径:org.jruby.RubyModule
类名称:RubyModule
方法名:defineAutoload
[英]Define an autoload. ConstantMap holds UNDEF for the name as an autoload marker.
[中]定义自动加载。ConstantMap将名称的UNDEF作为自动加载标记保存。
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(required = 2, module = true, visibility = PRIVATE)
public static IRubyObject autoload(ThreadContext context, final IRubyObject recv, IRubyObject symbol, IRubyObject file) {
final Ruby runtime = context.runtime;
final String nonInternedName = symbol.asJavaString();
if (!IdUtil.isValidConstantName(nonInternedName)) {
throw runtime.newNameError("autoload must be constant name", nonInternedName);
}
final RubyString fileString =
StringSupport.checkEmbeddedNulls(runtime, RubyFile.get_path(context, file));
if (fileString.isEmpty()) throw runtime.newArgumentError("empty file name");
final String baseName = nonInternedName.intern(); // interned, OK for "fast" methods
final RubyModule module = getModuleForAutoload(runtime, recv);
IRubyObject existingValue = module.fetchConstant(baseName);
if (existingValue != null && existingValue != RubyObject.UNDEF) return context.nil;
module.defineAutoload(baseName, new RubyModule.AutoloadMethod() {
public RubyString getFile() { return fileString; }
public void load(final Ruby runtime) {
final String file = getFile().asJavaString();
if (runtime.getLoadService().autoloadRequire(file)) {
// Do not finish autoloading by cyclic autoload
module.finishAutoload(baseName);
}
}
});
return context.nil;
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(required = 2, module = true, visibility = PRIVATE)
public static IRubyObject autoload(ThreadContext context, final IRubyObject recv, IRubyObject symbol, IRubyObject file) {
final Ruby runtime = context.runtime;
final String nonInternedName = symbol.asJavaString();
if (!IdUtil.isValidConstantName(nonInternedName)) {
throw runtime.newNameError("autoload must be constant name", nonInternedName);
}
final RubyString fileString =
StringSupport.checkEmbeddedNulls(runtime, RubyFile.get_path(context, file));
if (fileString.isEmpty()) throw runtime.newArgumentError("empty file name");
final String baseName = nonInternedName.intern(); // interned, OK for "fast" methods
final RubyModule module = getModuleForAutoload(runtime, recv);
IRubyObject existingValue = module.fetchConstant(baseName);
if (existingValue != null && existingValue != RubyObject.UNDEF) return context.nil;
module.defineAutoload(baseName, new RubyModule.AutoloadMethod() {
public RubyString getFile() { return fileString; }
public void load(final Ruby runtime) {
final String file = getFile().asJavaString();
if (runtime.getLoadService().autoloadRequire(file)) {
// Do not finish autoloading by cyclic autoload
module.finishAutoload(baseName);
}
}
});
return context.nil;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
if (existingValue != null && existingValue != RubyObject.UNDEF) return runtime.getNil();
module.defineAutoload(baseName, new IAutoloadMethod() {
@Override
public String file() {
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
if (existingValue != null && existingValue != RubyObject.UNDEF) return runtime.getNil();
module.defineAutoload(baseName, new IAutoloadMethod() {
@Override
public String file() {
内容来源于网络,如有侵权,请联系作者删除!