groovy.lang.Script.getMetaClass()方法的使用及代码示例

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

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

Script.getMetaClass介绍

暂无

代码示例

代码示例来源:origin: org.codehaus.groovy/groovy

public Object build(Script script) {
  // this used to be synchronized, but we also used to remove the
  // metaclass.  Since adding the metaclass is now a side effect, we
  // don't need to ensure the meta-class won't be observed and don't
  // need to hide the side effect.
  MetaClass scriptMetaClass = script.getMetaClass();
  script.setMetaClass(new FactoryInterceptorMetaClass(scriptMetaClass, this));
  script.setBinding(this);
  Object oldScriptName = getProxyBuilder().getVariables().get(SCRIPT_CLASS_NAME);
  try {
    getProxyBuilder().setVariable(SCRIPT_CLASS_NAME, script.getClass().getName());
    return script.run();
  } finally {
    if(oldScriptName != null) {
      getProxyBuilder().setVariable(SCRIPT_CLASS_NAME, oldScriptName);
    } else {
      getProxyBuilder().getVariables().remove(SCRIPT_CLASS_NAME);
    }
  }
}

代码示例来源:origin: apache/groovy

MetaClass oldMetaClass = scriptObject.getMetaClass();

代码示例来源:origin: apache/tinkerpop

final MetaClass oldMetaClass = scriptObject.getMetaClass();
scriptObject.setMetaClass(new DelegatingMetaClass(oldMetaClass) {
  @Override

代码示例来源:origin: org.codehaus.groovy/groovy-jsr223

MetaClass oldMetaClass = scriptObject.getMetaClass();

代码示例来源:origin: info.cukes/cucumber-groovy

private boolean isScript(Script script) {
  return DefaultGroovyMethods.asBoolean(script.getMetaClass().respondsTo(script, "main"));
}

代码示例来源:origin: info.cukes/cucumber-groovy

private void runIfScript(Binding context, Script script) {
  Class scriptClass = script.getMetaClass().getTheClass();
  if (isScript(script) && !scripts.contains(scriptClass)) {
    script.setBinding(context);
    script.run();
    scripts.add(scriptClass);
  }
}

代码示例来源:origin: org.codehaus.groovy/groovy-jdk14

public Object build(Script script) {
  // this used to be synchronized, but we also used to remove the
  // metaclass.  Since adding the metaclass is now a side effect, we
  // don't need to ensure the meta-class won't be observed and don't
  // need to hide the side effect.
  MetaClass scriptMetaClass = script.getMetaClass();
  script.setMetaClass(new FactoryInterceptorMetaClass(scriptMetaClass, this));
  script.setBinding(this);
  return script.run();
}

代码示例来源:origin: org.kohsuke.droovy/groovy

public Object build(Script script) {
  // this used to be synchronized, but we also used to remove the
  // metaclass.  Since adding the metaclass is now a side effect, we
  // don't need to ensure the meta-class won't be observed and don't
  // need to hide the side effect.
  MetaClass scriptMetaClass = script.getMetaClass();
  script.setMetaClass(new FactoryInterceptorMetaClass(scriptMetaClass, this));
  script.setBinding(this);
  return script.run();
}

代码示例来源:origin: org.codehaus.groovy/groovy-all-minimal

public Object build(Script script) {
  synchronized (script) {
    MetaClass scriptMetaClass = script.getMetaClass();
    try {
      script.setMetaClass(new FactoryInterceptorMetaClass(scriptMetaClass, this));
      script.setBinding(this);
      return script.run();
    } finally {
      script.setMetaClass(scriptMetaClass);
    }
  }
}

代码示例来源:origin: org.apache.tinkerpop/gremlin-groovy

final MetaClass oldMetaClass = scriptObject.getMetaClass();
scriptObject.setMetaClass(new DelegatingMetaClass(oldMetaClass) {
  @Override

代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

public Object build(Script script) {
  // this used to be synchronized, but we also used to remove the
  // metaclass.  Since adding the metaclass is now a side effect, we
  // don't need to ensure the meta-class won't be observed and don't
  // need to hide the side effect.
  MetaClass scriptMetaClass = script.getMetaClass();
  script.setMetaClass(new FactoryInterceptorMetaClass(scriptMetaClass, this));
  script.setBinding(this);
  Object oldScriptName = getProxyBuilder().getVariables().get(SCRIPT_CLASS_NAME);
  try {
    getProxyBuilder().setVariable(SCRIPT_CLASS_NAME, script.getClass().getName());
    return script.run();
  } finally {
    if(oldScriptName != null) {
      getProxyBuilder().setVariable(SCRIPT_CLASS_NAME, oldScriptName);
    } else {
      getProxyBuilder().getVariables().remove(SCRIPT_CLASS_NAME);
    }
  }
}

代码示例来源:origin: com.tinkerpop/gremlin-groovy

});
final MetaClass oldMetaClass = scriptObject.getMetaClass();
scriptObject.setMetaClass(new DelegatingMetaClass(oldMetaClass) {
  @Override

代码示例来源:origin: org.scijava/scripting-groovy

final MetaClass oldMetaClass = scriptObject.getMetaClass();

代码示例来源:origin: org.kohsuke.droovy/groovy

MetaClass oldMetaClass = scriptObject.getMetaClass();

代码示例来源:origin: org.codehaus.groovy/groovy-jdk14

MetaClass oldMetaClass = scriptObject.getMetaClass();

代码示例来源:origin: com.thinkaurelius.groovy-shaded-asm/groovy-shaded-asm

MetaClass oldMetaClass = scriptObject.getMetaClass();

代码示例来源:origin: zycgit/hasor

globalClosures.put(name, new MethodClosure(scriptObject, name));
MetaClass oldMetaClass = scriptObject.getMetaClass();

相关文章