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

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

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

Ruby.getClassLoader介绍

暂无

代码示例

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

private void initRubyKernel() {
  // We cannot load any .rb and debug new parser features
  if (RubyInstanceConfig.DEBUG_PARSER) return;
  // load Ruby parts of core
  loadService.loadFromClassLoader(getClassLoader(), "jruby/kernel.rb", false);
}

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

private void initRubyPreludes() {
  // We cannot load any .rb and debug new parser features
  if (RubyInstanceConfig.DEBUG_PARSER) return;
  // load Ruby parts of core
  loadService.loadFromClassLoader(getClassLoader(), "jruby/preludes.rb", false);
}

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

private void initRubyKernel() {
  // We cannot load any .rb and debug new parser features
  if (RubyInstanceConfig.DEBUG_PARSER) return;
  // load Ruby parts of core
  loadService.loadFromClassLoader(getClassLoader(), "jruby/kernel.rb", false);
}

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

private void initRubyPreludes() {
  // We cannot load any .rb and debug new parser features
  if (RubyInstanceConfig.DEBUG_PARSER) return;
  // load Ruby parts of core
  loadService.loadFromClassLoader(getClassLoader(), "jruby/preludes.rb", false);
}

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

private void loadBundler() {
  loadService.loadFromClassLoader(getClassLoader(), "jruby/bundler/startup.rb", false);
}

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

private void loadBundler() {
  loadService.loadFromClassLoader(getClassLoader(), "jruby/bundler/startup.rb", false);
}

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

private void initRubyKernel() {
  // We cannot load any .rb and debug new parser features
  if (RubyInstanceConfig.DEBUG_PARSER) return;
  
  // load Ruby parts of core
  loadService.loadFromClassLoader(getClassLoader(), "jruby/kernel.rb", false);
  
  switch (config.getCompatVersion()) {
    case RUBY1_8:
      loadService.loadFromClassLoader(getClassLoader(), "jruby/kernel18.rb", false);
      break;
    case RUBY1_9:
      loadService.loadFromClassLoader(getClassLoader(), "jruby/kernel19.rb", false);
      break;
    case RUBY2_0:
      loadService.loadFromClassLoader(getClassLoader(), "jruby/kernel20.rb", false);
      break;
  }
}

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

private void initRubyKernel() {
  // We cannot load any .rb and debug new parser features
  if (RubyInstanceConfig.DEBUG_PARSER) return;
  
  // load Ruby parts of core
  loadService.loadFromClassLoader(getClassLoader(), "jruby/kernel.rb", false);
  
  switch (config.getCompatVersion()) {
    case RUBY1_8:
      loadService.loadFromClassLoader(getClassLoader(), "jruby/kernel18.rb", false);
      break;
    case RUBY1_9:
      loadService.loadFromClassLoader(getClassLoader(), "jruby/kernel19.rb", false);
      break;
    case RUBY2_0:
      loadService.loadFromClassLoader(getClassLoader(), "jruby/kernel20.rb", false);
      break;
  }
}

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

private static final Factory getInstance() {
    final String providerName = System.getProperty("ffi.factory");
    Factory factory = null;
    List<String> providerNames = new ArrayList<String>();
    List<Throwable> errors = new ArrayList<Throwable>();
    if (providerName != null) {
      providerNames.add(providerName);
    }
    final String prefix = Factory.class.getPackage().getName();
    providerNames.add(prefix + ".jffi.Factory");
    for (String className : providerNames) {
      try {
        factory = (Factory) Class.forName(className, true, Ruby.getClassLoader()).newInstance();
        break;
      } catch (Throwable ex) {
        errors.add(ex);
      }
    }
    if (factory == null) {
      StringBuilder sb = new StringBuilder();
      for (Throwable t : errors) {
        sb.append(t.getLocalizedMessage()).append('\n');
      }
      factory = new NoImplFactory(sb.toString());
    }
    return factory;
  }
}

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

private static final Factory getInstance() {
    final String providerName = System.getProperty("ffi.factory");
    Factory factory = null;
    List<String> providerNames = new ArrayList<String>();
    List<Throwable> errors = new ArrayList<Throwable>();
    if (providerName != null) {
      providerNames.add(providerName);
    }
    final String prefix = Factory.class.getPackage().getName();
    providerNames.add(prefix + ".jffi.Factory");
    for (String className : providerNames) {
      try {
        factory = (Factory) Class.forName(className, true, Ruby.getClassLoader()).newInstance();
        break;
      } catch (Throwable ex) {
        errors.add(ex);
      }
    }
    if (factory == null) {
      StringBuilder sb = new StringBuilder();
      for (Throwable t : errors) {
        sb.append(t.getLocalizedMessage()).append('\n');
      }
      factory = new NoImplFactory(sb.toString());
    }
    return factory;
  }
}

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

private void addLazyBuiltin(String name, String shortName, String className) {
  addBuiltinIfAllowed(name, new LateLoadingLibrary(shortName, className, getClassLoader()));
}

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

private void addLazyBuiltin(String name, String shortName, String className) {
  addBuiltinIfAllowed(name, new LateLoadingLibrary(shortName, className, getClassLoader()));
}

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

private void addLazyBuiltin(String name, String shortName, String className) {
  addBuiltinIfAllowed(name, new LateLoadingLibrary(shortName, className, getClassLoader()));
}

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

private void addLazyBuiltin(String name, String shortName, String className) {
  addBuiltinIfAllowed(name, new LateLoadingLibrary(shortName, className, getClassLoader()));
}

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

@Deprecated // no longer used
public static Stream fopen(Ruby runtime, String path, ModeFlags modes) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException, InvalidValueException, PipeException, BadDescriptorException {
  try {
    ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), path, modes, runtime.getClassLoader());
    Stream stream = fdopen(runtime, descriptor, modes);
    return stream;
  } catch (ResourceException resourceException) {
    throw resourceException.newRaiseException(runtime);
  }
}

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

@Deprecated // no longer used
public static Stream fopen(Ruby runtime, String path, ModeFlags modes) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException, InvalidValueException, PipeException, BadDescriptorException {
  try {
    ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), path, modes, runtime.getClassLoader());
    Stream stream = fdopen(runtime, descriptor, modes);
    return stream;
  } catch (ResourceException resourceException) {
    throw resourceException.newRaiseException(runtime);
  }
}

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

public static Stream fopen(Ruby runtime, String path, ModeFlags modes) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException, InvalidValueException, PipeException, BadDescriptorException {
  ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), path, modes, runtime.getClassLoader());
  Stream stream = fdopen(runtime, descriptor, modes);
  return stream;
}

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

public static Stream fopen(Ruby runtime, String path, ModeFlags modes) throws FileNotFoundException, DirectoryAsFileException, FileExistsException, IOException, InvalidValueException, PipeException, BadDescriptorException {
  ChannelDescriptor descriptor = ChannelDescriptor.open(runtime.getCurrentDirectory(), path, modes, runtime.getClassLoader());
  Stream stream = fdopen(runtime, descriptor, modes);
  return stream;
}

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

public static TypePopulator loadPopulatorFor(Class<?> type) {
  if (Options.DEBUG_FULLTRACE.load() || Options.REFLECTED_HANDLES.load()) {
    // we want non-generated invokers or need full traces, use default (slow) populator
    LOG.debug("trace mode, using default populator");
  } else {
    try {
      String qualifiedName = "org.jruby.gen." + type.getCanonicalName().replace('.', '$');
      String fullName = qualifiedName + AnnotationBinder.POPULATOR_SUFFIX;
      String fullPath = fullName.replace('.', '/') + ".class";
      if (LOG.isDebugEnabled()) LOG.debug("looking for populator " + fullName);
      if (Ruby.getClassLoader().getResource(fullPath) == null) {
        LOG.debug("could not find it, using default populator");
      } else {
        return (TypePopulator) Class.forName(fullName).newInstance();
      }
    } catch (Throwable ex) {
      if (LOG.isDebugEnabled()) LOG.debug("could not find populator, using default (" + ex + ')');
    }
  }
  return new TypePopulator.ReflectiveTypePopulator(type);
}

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

public static TypePopulator loadPopulatorFor(Class<?> type) {
  if (Options.DEBUG_FULLTRACE.load() || Options.REFLECTED_HANDLES.load()) {
    // we want non-generated invokers or need full traces, use default (slow) populator
    LOG.debug("trace mode, using default populator");
  } else {
    try {
      String qualifiedName = "org.jruby.gen." + type.getCanonicalName().replace('.', '$');
      String fullName = qualifiedName + AnnotationBinder.POPULATOR_SUFFIX;
      String fullPath = fullName.replace('.', '/') + ".class";
      if (LOG.isDebugEnabled()) LOG.debug("looking for populator " + fullName);
      if (Ruby.getClassLoader().getResource(fullPath) == null) {
        LOG.debug("could not find it, using default populator");
      } else {
        return (TypePopulator) Class.forName(fullName).newInstance();
      }
    } catch (Throwable ex) {
      if (LOG.isDebugEnabled()) LOG.debug("could not find populator, using default (" + ex + ')');
    }
  }
  return new TypePopulator.ReflectiveTypePopulator(type);
}

相关文章

微信公众号

最新文章

更多

Ruby类方法