@Test public void testMT01() throws Exception { String source = "$f1 + $f2"; IExpression expr = getEngine().compile(source); int poolSize = 10; AtomicInteger successCount = new AtomicInteger(0); CountDownLatch doneSignal = new CountDownLatch(poolSize); for (int i = 0; i < poolSize; i++) { Thread t = new Thread(new TestRunner(expr, doneSignal, successCount)); t.setDaemon(false); t.start(); } doneSignal.await(); assertEquals(poolSize, successCount.get()); }
@Override public IExpression compile(String source) { if (source == null || source.length() == 0) { throw new ExpressionParseException("expression can't be empty!"); } try { CompiledScript jsScript = compiler.compile(source); return new ScriptExpression(jsScript, source); } catch(Throwable t) { throw new ExpressionParseException(source, t); } }
ScriptExpressionEngine implements IExpressionEngine { @Override public IExpression compile(String source) { if (source == null || source.length() == 0) { throw new ExpressionParseException("expression can't be empty!"); } try { CompiledScript jsScript = compiler.compile(source); return new ScriptExpression(jsScript, source); } catch(Throwable t) { throw new ExpressionParseException(source, t); } } }
ScriptExpressionEngine implements IExpressionEngine { @Override public IExpression compile(String source) { if (source == null || source.length() == 0) { throw new ExpressionParseException("expression can't be empty!"); } try { CompiledScript jsScript = compiler.compile(source); return new ScriptExpression(jsScript, source); } catch(Throwable t) { throw new ExpressionParseException(source, t); } } private  ScriptExpressionEngine(); }
ScriptExpressionEngine implements IExpressionEngine { @Override public IExpression compile(String source) { if (source == null || source.length() == 0) { throw new ExpressionParseException("expression can't be empty!"); } try { CompiledScript jsScript = compiler.compile(source); return new ScriptExpression(jsScript, source); } catch(Throwable t) { throw new ExpressionParseException(source, t); } } private  ScriptExpressionEngine(); static IExpressionEngine getInstance(); @Override Object evaluate(IExpression expression, IExpressionContext context); @Override IExpression compile(String source); }
ScriptExpressionEngine implements IExpressionEngine { @Override public IExpression compile(String source) { if (source == null || source.length() == 0) { throw new ExpressionParseException("expression can't be empty!"); } try { CompiledScript jsScript = compiler.compile(source); return new ScriptExpression(jsScript, source); } catch(Throwable t) { throw new ExpressionParseException(source, t); } } private  ScriptExpressionEngine(); static IExpressionEngine getInstance(); @Override Object evaluate(IExpression expression, IExpressionContext context); @Override IExpression compile(String source);  }