groovy.lang.GroovyShell.parseClass()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(146)

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

GroovyShell.parseClass介绍

[英]Parses the groovy code contained in codeSource and returns a java class.
[中]解析codeSource中包含的groovy代码并返回一个java类。

代码示例

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

/**
 * Parses the given script and returns it ready to be run.  When running in a secure environment
 * (-Djava.security.manager) codeSource.getCodeSource() determines what policy grants should be
 * given to the script.
 *
 * @param codeSource
 * @return ready to run script
 */
public Script parse(final GroovyCodeSource codeSource) throws CompilationFailedException {
  return InvokerHelper.createScript(parseClass(codeSource), context);
}

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

/**
 * Runs the given script source with command line arguments
 *
 * @param source    is the source content of the script
 * @param args      the command line arguments to pass in
 */
public Object run(GroovyCodeSource source, String[] args) throws CompilationFailedException {
  Class scriptClass = parseClass(source);
  return runScriptOrMainOrTestOrRunnable(scriptClass, args);
}

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

/**
 * Runs the given script with command line arguments
 *
 * @param in       the stream reading the script
 * @param fileName is the logical file name of the script (which is used to create the class name of the script)
 * @param args     the command line arguments to pass in
 */
public Object run(final Reader in, final String fileName, String[] args) throws CompilationFailedException {
  GroovyCodeSource gcs = AccessController.doPrivileged(new PrivilegedAction<GroovyCodeSource>() {
        public GroovyCodeSource run() {
          return new GroovyCodeSource(in, fileName, DEFAULT_CODE_BASE);
        }
  });
  Class scriptClass = parseClass(gcs);
  return runScriptOrMainOrTestOrRunnable(scriptClass, args);
}

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

/**
 * Parses the given script and returns it ready to be run.  When running in a secure environment
 * (-Djava.security.manager) codeSource.getCodeSource() determines what policy grants should be
 * given to the script.
 *
 * @param codeSource
 * @return ready to run script
 */
public Script parse(final GroovyCodeSource codeSource) throws CompilationFailedException {
  return InvokerHelper.createScript(parseClass(codeSource), context);
}

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

/**
 * Parses the given script and returns it ready to be run.  When running in a secure environment
 * (-Djava.security.manager) codeSource.getCodeSource() determines what policy grants should be
 * given to the script.
 *
 * @param codeSource
 * @return ready to run script
 */
public Script parse(final GroovyCodeSource codeSource) throws CompilationFailedException {
  return InvokerHelper.createScript(parseClass(codeSource), context);
}

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

/**
 * Parses the given script and returns it ready to be run.  When running in a secure environment
 * (-Djava.security.manager) codeSource.getCodeSource() determines what policy grants should be
 * given to the script.
 *
 * @param codeSource
 * @return ready to run script
 */
public Script parse(final GroovyCodeSource codeSource) throws CompilationFailedException {
  return InvokerHelper.createScript(parseClass(codeSource), context);
}

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

/**
 * Parses the given script and returns it ready to be run.  When running in a secure environment
 * (-Djava.security.manager) codeSource.getCodeSource() determines what policy grants should be
 * given to the script.
 *
 * @param codeSource
 * @return ready to run script
 */
public Script parse(final GroovyCodeSource codeSource) throws CompilationFailedException {
  return InvokerHelper.createScript(parseClass(codeSource), context);
}

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

/**
 * Runs the given script text with command line arguments
 *
 * @param scriptText is the text content of the script
 * @param fileName   is the logical file name of the script (which is used to create the class name of the script)
 * @param args       the command line arguments to pass in
 */
public Object run(final String scriptText, final String fileName, String[] args) throws CompilationFailedException {
  GroovyCodeSource gcs = AccessController.doPrivileged(new PrivilegedAction<GroovyCodeSource>() {
    public GroovyCodeSource run() {
      return new GroovyCodeSource(scriptText, fileName, DEFAULT_CODE_BASE);
    }
  });
  Class scriptClass = parseClass(gcs);
  return runScriptOrMainOrTestOrRunnable(scriptClass, args);
}

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

/**
 * Runs the given script with command line arguments
 *
 * @param in       the stream reading the script
 * @param fileName is the logical file name of the script (which is used to create the class name of the script)
 * @param args     the command line arguments to pass in
 */
public Object run(final InputStream in, final String fileName, String[] args) throws CompilationFailedException {
  GroovyCodeSource gcs = (GroovyCodeSource) AccessController.doPrivileged(new PrivilegedAction() {
    public Object run() {
      return new GroovyCodeSource(in, fileName, "/groovy/shell");
    }
  });
  Class scriptClass = parseClass(gcs);
  return runMainOrTestOrRunnable(scriptClass, args);
}

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

/**
 * Runs the given script with command line arguments
 *
 * @param in       the stream reading the script
 * @param fileName is the logical file name of the script (which is used to create the class name of the script)
 * @param args     the command line arguments to pass in
 */
public Object run(final InputStream in, final String fileName, String[] args) throws CompilationFailedException {
  GroovyCodeSource gcs = (GroovyCodeSource) AccessController.doPrivileged(new PrivilegedAction() {
    public Object run() {
      return new GroovyCodeSource(in, fileName, "/groovy/shell");
    }
  });
  Class scriptClass = parseClass(gcs);
  return runScriptOrMainOrTestOrRunnable(scriptClass, args);
}

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

/**
 * Runs the given script with command line arguments
 *
 * @param in       the stream reading the script
 * @param fileName is the logical file name of the script (which is used to create the class name of the script)
 * @param args     the command line arguments to pass in
 */
public Object run(final Reader in, final String fileName, String[] args) throws CompilationFailedException {
  GroovyCodeSource gcs = AccessController.doPrivileged(new PrivilegedAction<GroovyCodeSource>() {
        public GroovyCodeSource run() {
          return new GroovyCodeSource(in, fileName, DEFAULT_CODE_BASE);
        }
  });
  Class scriptClass = parseClass(gcs);
  return runScriptOrMainOrTestOrRunnable(scriptClass, args);
}

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

/**
 * Runs the given script with command line arguments
 *
 * @param in       the stream reading the script
 * @param fileName is the logical file name of the script (which is used to create the class name of the script)
 * @param args     the command line arguments to pass in
 */
public Object run(final InputStream in, final String fileName, String[] args) throws CompilationFailedException {
  GroovyCodeSource gcs = (GroovyCodeSource) AccessController.doPrivileged(new PrivilegedAction() {
    public Object run() {
      return new GroovyCodeSource(in, fileName, "/groovy/shell");
    }
  });
  Class scriptClass = parseClass(gcs);
  return runScriptOrMainOrTestOrRunnable(scriptClass, args);
}

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

/**
 * Runs the given script with command line arguments
 *
 * @param in       the stream reading the script
 * @param fileName is the logical file name of the script (which is used to create the class name of the script)
 * @param args     the command line arguments to pass in
 *
 * @deprecated Prefer using methods taking a Reader rather than an InputStream to avoid wrong encoding issues.
 */
public Object run(final InputStream in, final String fileName, String[] args) throws CompilationFailedException {
  GroovyCodeSource gcs = AccessController.doPrivileged(new PrivilegedAction<GroovyCodeSource>() {
    public GroovyCodeSource run() {
      try {
        String scriptText = config.getSourceEncoding() != null ?
            DefaultGroovyMethods.getText(in, config.getSourceEncoding()) :
            DefaultGroovyMethods.getText(in);
        return new GroovyCodeSource(scriptText, fileName, DEFAULT_CODE_BASE);
      } catch (IOException e) {
        throw new RuntimeException("Impossible to read the content of the input stream for file named: " + fileName, e);
      }
    }
  });
  Class scriptClass = parseClass(gcs);
  return runScriptOrMainOrTestOrRunnable(scriptClass, args);
}

相关文章