@Override public void start() { try { assert context != null; scriptEvaluator = new ScriptEvaluator(getDecoratedExpression(), EXPRESSION_TYPE, getParameterNames(), getParameterTypes(), THROWN_EXCEPTIONS); super.start(); } catch (Exception e) { addError( "Could not start evaluator with expression [" + expression + "]", e); } }
public boolean evaluate(E event) throws EvaluationException { if (!isStarted()) { throw new IllegalStateException("Evaluator [" + name + "] was called in stopped state"); } try { Boolean result = (Boolean) scriptEvaluator.evaluate(getParameterValues(event)); return result.booleanValue(); } catch (Exception ex) { errorCount++; if (errorCount >= ERROR_THRESHOLD) { stop(); } throw new EvaluationException("Evaluator [" + name + "] caused an exception", ex); } }
private Object compile(final Resource content, final boolean query) { Object ctx = objectCache.get(content); if (ctx == null) { ScriptEvaluator evaluator = new ScriptEvaluator(); evaluator.setThrownExceptions(THROWN_EXCEPTIONS); evaluator.setParentClassLoader(getClass().getClassLoader()); Class<?> type = query ? JaninoQuery.class : JaninoScript.class; evaluator.setExtendedType(type); evaluator.setStaticMethod(false); evaluator.setMethodName("execute"); evaluator.setClassName(type.getName() + "_Generated"); if (DEBUG) { evaluator.setDebuggingInformation(true, true, true); try { r = content.open(); evaluator.cook(content.toString(), r); } catch (Exception e) { throw guessErrorStatement(new JaninoProviderException("Compilation failed", e), content); IOUtils.closeSilently(r); Class<?> cl = evaluator.getMethod().getDeclaringClass(); try { ctx = cl.newInstance();
protected ScriptEvaluator getEvaluator( Class returnType, String[] parameterNames, Class[] parameterTypes ) { try { return new ScriptEvaluator( block, returnType, parameterNames, parameterTypes ); } catch( CompileException exception ) { throw new OperationException( "could not compile script: " + block, exception ); } }
/** * Performs the actual expression evaluation. * * @param context * @param input of type TupleEntry * @return Comparable */ protected Object evaluate( Context context, TupleEntry input ) { try { if( context.parameterTypes.length == 0 ) return context.scriptEvaluator.evaluate( null ); Tuple parameterTuple = TupleViews.reset( context.intermediate, input.getTuple() ); Object[] arguments = Tuples.asArray( parameterTuple, context.parameterCoercions, context.parameterTypes, context.parameterArray ); return context.scriptEvaluator.evaluate( arguments ); } catch( InvocationTargetException exception ) { throw new OperationException( "could not evaluate expression: " + block, exception.getTargetException() ); } }
protected ScriptEvaluator getEvaluator( Class returnType, String[] parameterNames, Class[] parameterTypes ) { try { return new ScriptEvaluator( block, returnType, parameterNames, parameterTypes ); } catch( CompileException exception ) { throw new OperationException( "could not compile script: " + block, exception ); } }
/** * Performs the actual expression evaluation. * * @param context * @param input of type TupleEntry * @return Comparable */ protected Object evaluate( Context context, TupleEntry input ) { try { if( context.parameterTypes.length == 0 ) return context.scriptEvaluator.evaluate( null ); Tuple parameterTuple = TupleViews.reset( context.intermediate, input.getTuple() ); Object[] arguments = Tuples.asArray( parameterTuple, context.parameterCoercions, context.parameterTypes, context.parameterArray ); return context.scriptEvaluator.evaluate( arguments ); } catch( InvocationTargetException exception ) { throw new OperationException( "could not evaluate expression: " + block, exception.getTargetException() ); } }
private static IScriptEvaluator buildEvaluator(final String expression, final Class<?> type, final String[] parameterNames, final Class<?>[] parameterTypes) { try { return new ScriptEvaluator(expression, type, parameterNames, parameterTypes); } catch (final Exception ex) { throw WrappedException.wrap(ex, "An error occurred during expression's preprocessing in \n {0} \n", expression); } } }
public boolean evaluate(E event) throws EvaluationException { if (!isStarted()) { throw new IllegalStateException("Evaluator [" + name + "] was called in stopped state"); } try { Boolean result = (Boolean) scriptEvaluator.evaluate(getParameterValues(event)); return result.booleanValue(); } catch (Exception ex) { errorCount++; if (errorCount >= ERROR_THRESHOLD) { stop(); } throw new EvaluationException("Evaluator [" + name + "] caused an exception", ex); } }
@Override public void start() { try { assert context != null; scriptEvaluator = new ScriptEvaluator(getDecoratedExpression(), EXPRESSION_TYPE, getParameterNames(), getParameterTypes(), THROWN_EXCEPTIONS); super.start(); } catch (Exception e) { addError( "Could not start evaluator with expression [" + expression + "]", e); } }
public boolean evaluate(E event) throws EvaluationException { if (!isStarted()) { throw new IllegalStateException("Evaluator [" + name + "] was called in stopped state"); } try { Boolean result = (Boolean) scriptEvaluator.evaluate(getParameterValues(event)); return result.booleanValue(); } catch (Exception ex) { errorCount++; if (errorCount >= ERROR_THRESHOLD) { stop(); } throw new EvaluationException("Evaluator [" + name + "] caused an exception", ex); } }
@Override public void start() { try { assert context != null; scriptEvaluator = new ScriptEvaluator(getDecoratedExpression(), EXPRESSION_TYPE, getParameterNames(), getParameterTypes(), THROWN_EXCEPTIONS); super.start(); } catch (Exception e) { addError( "Could not start evaluator with expression [" + expression + "]", e); } }
public boolean evaluate(E event) throws EvaluationException { if (!isStarted()) { throw new IllegalStateException("Evaluator [" + name + "] was called in stopped state"); } try { Boolean result = (Boolean) scriptEvaluator.evaluate(getParameterValues(event)); return result.booleanValue(); } catch (Exception ex) { errorCount++; if (errorCount >= ERROR_THRESHOLD) { stop(); } throw new EvaluationException("Evaluator [" + name + "] caused an exception", ex); } }
@Override public void start() { try { assert context != null; scriptEvaluator = new ScriptEvaluator(getDecoratedExpression(), EXPRESSION_TYPE, getParameterNames(), getParameterTypes(), THROWN_EXCEPTIONS); super.start(); } catch (Exception e) { addError("Could not start evaluator with expression [" + expression + "]", e); } }
public boolean evaluate(E event) throws EvaluationException { if (!isStarted()) { throw new IllegalStateException("Evaluator [" + name + "] was called in stopped state"); } try { Boolean result = (Boolean) scriptEvaluator.evaluate(getParameterValues(event)); return result.booleanValue(); } catch (Exception ex) { errorCount++; if (errorCount >= ERROR_THRESHOLD) { stop(); } throw new EvaluationException("Evaluator [" + name + "] caused an exception", ex); } }
@Override public void start() { try { assert context != null; scriptEvaluator = new ScriptEvaluator(getDecoratedExpression(), EXPRESSION_TYPE, getParameterNames(), getParameterTypes(), THROWN_EXCEPTIONS); super.start(); } catch (Exception e) { addError("Could not start evaluator with expression [" + expression + "]", e); } }
public boolean evaluate(E event) throws EvaluationException { if (!isStarted()) { throw new IllegalStateException("Evaluator [" + name + "] was called in stopped state"); } try { Boolean result = (Boolean) scriptEvaluator.evaluate(getParameterValues(event)); return result.booleanValue(); } catch (Exception ex) { errorCount++; if (errorCount >= ERROR_THRESHOLD) { stop(); } throw new EvaluationException("Evaluator [" + name + "] caused an exception", ex); } }
@Override public void start() { try { assert context != null; scriptEvaluator = new ScriptEvaluator(getDecoratedExpression(), EXPRESSION_TYPE, getParameterNames(), getParameterTypes(), THROWN_EXCEPTIONS); super.start(); } catch (Exception e) { addError( "Could not start evaluator with expression [" + expression + "]", e); } }
public boolean evaluate(E event) throws EvaluationException { if (!isStarted()) { throw new IllegalStateException("Evaluator [" + name + "] was called in stopped state"); } try { Boolean result = (Boolean) scriptEvaluator.evaluate(getParameterValues(event)); return result.booleanValue(); } catch (Exception ex) { errorCount++; if (errorCount >= ERROR_THRESHOLD) { stop(); } throw new EvaluationException("Evaluator [" + name + "] caused an exception", ex); } }
@Override public void start() { try { assert context != null; scriptEvaluator = new ScriptEvaluator(getDecoratedExpression(), EXPRESSION_TYPE, getParameterNames(), getParameterTypes(), THROWN_EXCEPTIONS); super.start(); } catch (Exception e) { addError("Could not start evaluator with expression [" + expression + "]", e); } }