@Test public void testSetLocalValue() throws Exception { System.out.println(" setLocalValue"); final String varName = "foo"; final int[] values = {1, 2}; final CountDownLatch latch = new CountDownLatch(2); class Task implements Runnable { private final int threadIndex; public Task(int threadIndex) { this.threadIndex = threadIndex; } public void run() { EnvFunction.setLocalValue(varName, values[threadIndex]); latch.countDown(); try { latch.await(); } catch (InterruptedException ex) { throw new IllegalStateException(ex); } Object result = ff.function("env", ff.literal(varName)).evaluate(null); int value = ((Number) result).intValue(); assertEquals(values[threadIndex], value); } } Future f1 = executor.submit(new Task(0)); Future f2 = executor.submit(new Task(1)); f1.get(); f2.get(); }
public static void setLocalValue(String name, Object value) { localLookup.getTable().put(name.toUpperCase(), value); }
EnvFunction extends FunctionExpressionImpl { public static void setLocalValue(String name, Object value) { localLookup.getTable().put(name.toUpperCase(), value); } }
EnvFunction extends FunctionExpressionImpl { public static void setLocalValue(String name, Object value) { localLookup.getTable().put(name.toUpperCase(), value); } EnvFunction(); }
EnvFunction extends FunctionExpressionImpl { public static void setLocalValue(String name, Object value) { localLookup.getTable().put(name.toUpperCase(), value); } EnvFunction(); static void setLocalValues(Map<String, Object> values); static void clearLocalValues(); static void setGlobalValues(Map<String, Object> values); static void clearGlobalValues(); static void setLocalValue(String name, Object value); static void setGlobalValue(String name, Object value); @Override int getArgCount(); @Override Object evaluate(Object feature); @Override void setParameters(List params); @Override void setFallbackValue(Literal fallback); }
EnvFunction extends FunctionExpressionImpl { public static void setLocalValue(String name, Object value) { localLookup.getTable().put(name.toUpperCase(), value); } EnvFunction(); static void setLocalValues(Map<String, Object> values); static void clearLocalValues(); static void setGlobalValues(Map<String, Object> values); static void clearGlobalValues(); static void setLocalValue(String name, Object value); static void setGlobalValue(String name, Object value); @Override int getArgCount(); @Override Object evaluate(Object feature); @Override void setParameters(List params); @Override void setFallbackValue(Literal fallback); static FunctionName NAME; }