/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }