Use shared Groovy script engine

This commit is contained in:
Reinhard Pointner 2016-02-08 22:40:05 +00:00
parent 1ebece8d19
commit 25f6edd065
2 changed files with 7 additions and 8 deletions

View File

@ -10,11 +10,11 @@ import java.util.logging.Logger;
public class ExpressionFileFilter implements FileFilter {
private final ExpressionFilter filter;
private final boolean errorResult;
private final boolean error;
public ExpressionFileFilter(ExpressionFilter filter, boolean errorResult) {
public ExpressionFileFilter(ExpressionFilter filter, boolean error) {
this.filter = filter;
this.errorResult = errorResult;
this.error = error;
}
public ExpressionFilter getExpressionFilter() {
@ -27,7 +27,7 @@ public class ExpressionFileFilter implements FileFilter {
return filter.matches(new MediaBindingBean(readMetaInfo(f), f, null));
} catch (Exception e) {
Logger.getLogger(ExpressionFileFilter.class.getName()).log(Level.WARNING, e.toString());
return errorResult;
return error;
}
}

View File

@ -1,9 +1,10 @@
package net.filebot.format;
import static net.filebot.format.ExpressionFormat.*;
import java.security.AccessController;
import javax.script.Bindings;
import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.ScriptContext;
import javax.script.ScriptException;
@ -20,9 +21,7 @@ public class ExpressionFilter {
public ExpressionFilter(String expression) throws ScriptException {
this.expression = expression;
Compilable engine = (Compilable) ExpressionFormat.getGroovyScriptEngine();
this.compiledExpression = new SecureCompiledScript(engine.compile(expression)); // sandboxed script
this.compiledExpression = new SecureCompiledScript(compileScriptlet(expression));
}
public String getExpression() {