org.jruby.RubyModule.getMethodsForWrite()方法的使用及代码示例

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

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

RubyModule.getMethodsForWrite介绍

暂无

代码示例

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

@Override
public Map<String, DynamicMethod> getMethodsForWrite() {
  return origin.getMethodsForWrite();
}

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

@Override
public Map<String, DynamicMethod> getMethodsForWrite() {
  return delegate.getMethodsForWrite();
}

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

@Override
public Map<String, DynamicMethod> getMethodsForWrite() {
  return delegate.getMethodsForWrite();
}

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

@Override
public Map<String, DynamicMethod> getMethodsForWrite() {
  return origin.getMethodsForWrite();
}

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

/**
 * This method is not intended for use by normal users; it is a fast-path
 * method that skips synchronization and hierarchy invalidation to speed
 * boot-time method definition.
 *
 * @param name The name to which to bind the method
 * @param method The method to bind
 */
public void addMethodAtBootTimeOnly(String name, DynamicMethod method) {
  getMethodsForWrite().put(name, method);
  getRuntime().addProfiledMethod(name, method);
}

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

private void putMethod(String name, DynamicMethod method) {
  getMethodsForWrite().put(name, method);
  getRuntime().addProfiledMethod(name, method);
}

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

/**
 * This method is not intended for use by normal users; it is a fast-path
 * method that skips synchronization and hierarchy invalidation to speed
 * boot-time method definition.
 *
 * @param name The name to which to bind the method
 * @param method The method to bind
 */
public void addMethodAtBootTimeOnly(String name, DynamicMethod method) {
  getMethodsForWrite().put(name, method);
  getRuntime().addProfiledMethod(name, method);
}

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

private void putMethod(String name, DynamicMethod method) {
  getMethodsForWrite().put(name, method);
  getRuntime().addProfiledMethod(name, method);
}

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

@JRubyMethod(name = "mix", visibility = PRIVATE, compat = RUBY2_0)
public IRubyObject mix(ThreadContext context, IRubyObject mod) {
  Ruby runtime = context.runtime;
  if (!mod.isModule()) {
    throw runtime.newTypeError(mod, runtime.getModule());
  }
  for (Map.Entry<String, DynamicMethod> entry : ((RubyModule)mod).methods.entrySet()) {
    if (methods.containsKey(entry.getKey())) {
      throw runtime.newArgumentError("method would conflict - " + entry.getKey());
    }
  }
  for (Map.Entry<String, DynamicMethod> entry : ((RubyModule)mod).methods.entrySet()) {
    getMethodsForWrite().put(entry.getKey(), entry.getValue().dup());
  }
  return mod;
}

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

@JRubyMethod(name = "mix", visibility = PRIVATE, compat = RUBY2_0)
public IRubyObject mix(ThreadContext context, IRubyObject mod) {
  Ruby runtime = context.runtime;
  if (!mod.isModule()) {
    throw runtime.newTypeError(mod, runtime.getModule());
  }
  for (Map.Entry<String, DynamicMethod> entry : ((RubyModule)mod).methods.entrySet()) {
    if (methods.containsKey(entry.getKey())) {
      throw runtime.newArgumentError("method would conflict - " + entry.getKey());
    }
  }
  for (Map.Entry<String, DynamicMethod> entry : ((RubyModule)mod).methods.entrySet()) {
    getMethodsForWrite().put(entry.getKey(), entry.getValue().dup());
  }
  return mod;
}

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

@JRubyMethod(name = "mix", visibility = PRIVATE)
public IRubyObject mix(ThreadContext context, IRubyObject mod) {
  Ruby runtime = context.runtime;
  if (!mod.isModule()) {
    throw runtime.newTypeError(mod, runtime.getModule());
  }
  for (Map.Entry<String, DynamicMethod> entry : ((RubyModule)mod).methods.entrySet()) {
    if (methodLocation.getMethods().containsKey(entry.getKey())) {
      throw runtime.newArgumentError("method would conflict - " + entry.getKey());
    }
  }
  for (Map.Entry<String, DynamicMethod> entry : ((RubyModule)mod).methods.entrySet()) {
    methodLocation.getMethodsForWrite().put(entry.getKey(), entry.getValue().dup());
  }
  return mod;
}

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

@JRubyMethod(name = "mix", visibility = PRIVATE)
public IRubyObject mix(ThreadContext context, IRubyObject mod) {
  Ruby runtime = context.runtime;
  if (!mod.isModule()) {
    throw runtime.newTypeError(mod, runtime.getModule());
  }
  for (Map.Entry<String, DynamicMethod> entry : ((RubyModule)mod).methods.entrySet()) {
    if (methodLocation.getMethods().containsKey(entry.getKey())) {
      throw runtime.newArgumentError("method would conflict - " + entry.getKey());
    }
  }
  for (Map.Entry<String, DynamicMethod> entry : ((RubyModule)mod).methods.entrySet()) {
    methodLocation.getMethodsForWrite().put(entry.getKey(), entry.getValue().dup());
  }
  return mod;
}

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

public void addMethodInternal(String name, DynamicMethod method) {
  synchronized(getMethodsForWrite()) {
    addMethodAtBootTimeOnly(name, method);
    invalidateCoreClasses();
    invalidateCacheDescendants();
  }
}

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

public void addMethodInternal(String name, DynamicMethod method) {
  synchronized(getMethodsForWrite()) {
    addMethodAtBootTimeOnly(name, method);
    invalidateCoreClasses();
    invalidateCacheDescendants();
  }
}

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

public final void addMethodInternal(String name, DynamicMethod method) {
  synchronized (methodLocation.getMethodsForWrite()) {
    putMethod(getRuntime(), name, method);
    invalidateCoreClasses();
    invalidateCacheDescendants();
  }
}

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

/**
 * @note Internal API - only public as its used by generated code!
 * @param runtime
 * @param id identifier string (8859_1).  Matching entry in symbol table.
 * @param method
 * @return method
 */ // NOTE: used by AnnotationBinder
public DynamicMethod putMethod(Ruby runtime, String id, DynamicMethod method) {
  if (hasPrepends()) {
    method = method.dup();
    method.setImplementationClass(methodLocation);
  }
  methodLocation.getMethodsForWrite().put(id, method);
  runtime.addProfiledMethod(id, method);
  return method;
}

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

/**
 * @note Internal API - only public as its used by generated code!
 * @param runtime
 * @param id identifier string (8859_1).  Matching entry in symbol table.
 * @param method
 * @return method
 */ // NOTE: used by AnnotationBinder
public DynamicMethod putMethod(Ruby runtime, String id, DynamicMethod method) {
  if (hasPrepends()) {
    method = method.dup();
    method.setImplementationClass(methodLocation);
  }
  methodLocation.getMethodsForWrite().put(id, method);
  runtime.addProfiledMethod(id, method);
  return method;
}

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

public final void addMethodInternal(String name, DynamicMethod method) {
  synchronized (methodLocation.getMethodsForWrite()) {
    putMethod(getRuntime(), name, method);
    invalidateCoreClasses();
    invalidateCacheDescendants();
  }
}

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

public void removeMethod(ThreadContext context, String name) {
  Ruby runtime = context.runtime;
  testFrozen("class/module");
  // We can safely reference methods here instead of doing getMethods() since if we
  // are adding we are not using a IncludedModuleWrapper.
  synchronized(getMethodsForWrite()) {
    DynamicMethod method = (DynamicMethod) getMethodsForWrite().remove(name);
    if (method == null) {
      throw runtime.newNameError("method '" + name + "' not defined in " + getName(), name);
    }
    invalidateCoreClasses();
    invalidateCacheDescendants();
  }
  
  if (isSingleton()) {
    IRubyObject singleton = ((MetaClass)this).getAttached(); 
    singleton.callMethod(context, "singleton_method_removed", runtime.newSymbol(name));
  } else {
    callMethod(context, "method_removed", runtime.newSymbol(name));
  }
}

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

public void removeMethod(ThreadContext context, String id) {
  testFrozen("class/module");
  switch (id) {
    case "object_id"  : warnMethodRemoval(context, id); break;
    case "__send__"   : warnMethodRemoval(context, id); break;
    case "initialize" : warnMethodRemoval(context, id); break;
  }
  RubySymbol name = context.runtime.newSymbol(id);
  // We can safely reference methods here instead of doing getMethods() since if we
  // are adding we are not using a IncludedModule.
  Map<String, DynamicMethod> methodsForWrite = methodLocation.getMethodsForWrite();
  synchronized (methodsForWrite) {
    DynamicMethod method = methodsForWrite.remove(id);
    if (method == null) {
      throw context.runtime.newNameError(str(context.runtime, "method '", name, "' not defined in ", rubyName()), id);
    }
    invalidateCoreClasses();
    invalidateCacheDescendants();
  }
  if (isSingleton()) {
    ((MetaClass) this).getAttached().callMethod(context, "singleton_method_removed", name);
  } else {
    callMethod(context, "method_removed", name);
  }
}

相关文章

微信公众号

最新文章

更多

RubyModule类方法