java.lang.Object
com.iamsoft.util.ui.javafx.script.PolyglotExecutor
- All Implemented Interfaces:
ScriptExecutor
-
Constructor Summary
ConstructorsConstructorDescriptionPolyglotExecutor(Language pLanguage) PolyglotExecutor(Language pLanguage, Consumer<Runnable> pExecutor) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.graalvm.polyglot.Context<T> TEvaluates the specified code.<T> T<T> voideval(String pSource, Map<String, Object> pVarMap, Class<T> pResultType, BiConsumer<T, Exception> pResultConsumer, long pTimeoutMs) Evaluates the specified code and supply the result to the specified result consumer.<T> TEvaluates the specified code using the specified context executor and waits for result without blocking the UI.<T> TevalAsync(String pSource, Function<org.graalvm.polyglot.Value, T> pResultMapper, long pTimeoutMs, Consumer<org.graalvm.polyglot.Context> pBeforeEval, Consumer<org.graalvm.polyglot.Context> pAfterEval) Evaluates the specified code and waits for result without blocking the UI.<T> TEvaluates the specified code and waits for result without blocking the UI.<T> TevalAsync(String pSource, Map<String, Object> pVarMap, Function<org.graalvm.polyglot.Value, T> pResultMapper) Evaluates the specified code using the specified context executor and waits for result without blocking the UI.<T> TevalAsync(String pSource, Map<String, Object> pVarMap, Function<org.graalvm.polyglot.Value, T> pResultMapper, long pTimeoutMs) Evaluates the specified code and waits for result without blocking the UI.evalString(String pSource) Evaluates the specified code and waits for result without blocking the UI.evalString(String pSource, long pTimeoutMs) Evaluates the specified code and waits for result without blocking the UI.evalString(String pSource, Map<String, Object> pVarMap) Evaluates the specified code and waits for result without blocking the UI.evalString(String pSource, Map<String, Object> pVarMap, long pTimeoutMs) Evaluates the specified code using the specified context executor and waits for result without blocking the UI.final LanguagevoidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.iamsoft.util.ui.javafx.script.ScriptExecutor
eval, evalSafe, evalSafe, getLanguageId
-
Constructor Details
-
PolyglotExecutor
-
PolyglotExecutor
- Parameters:
pExecutor- A single-thread executor or an executor which doesn't run the tasks simultaneously - should run them one after the other.
-
-
Method Details
-
getLanguage
- Specified by:
getLanguagein interfaceScriptExecutor
-
getExecutor
- Specified by:
getExecutorin interfaceScriptExecutor
-
createContext
protected org.graalvm.polyglot.Context createContext() -
resetContext
public void resetContext() -
eval
Description copied from interface:ScriptExecutorEvaluates the specified code.- Specified by:
evalin interfaceScriptExecutor
-
eval
public <T> T eval(String pSource, Map<String, Object> pVarMap, Class<T> pResultType, long pTimeoutMs) throws Exception- Throws:
Exception
-
eval
public <T> void eval(String pSource, Map<String, Object> pVarMap, Class<T> pResultType, BiConsumer<T, Exception> pResultConsumer, long pTimeoutMs) Evaluates the specified code and supply the result to the specified result consumer. This method should be invoked only from the JavaFX thread.- Specified by:
evalin interfaceScriptExecutor- Parameters:
pVarMap- A map containing variables with values to pass to guest code execution. The map should be thread-safe.
-
evalAsync
public <T> T evalAsync(String pSource, Function<org.graalvm.polyglot.Value, T> pResultMapper, long pTimeoutMs) throws InterruptedExceptionEvaluates the specified code using the specified context executor and waits for result without blocking the UI. This method must either be called from an input event handler or from the run method of a Runnable passed toPlatform.runLater. It must not be called during animation or layout processing.- Throws:
InterruptedException- if the specified timeout is reached
-
evalAsync
public <T> T evalAsync(String pSource, Map<String, Object> pVarMap, Function<org.graalvm.polyglot.Value, T> pResultMapper) Evaluates the specified code using the specified context executor and waits for result without blocking the UI. This method must either be called from an input event handler or from the run method of a Runnable passed toPlatform.runLater. It must not be called during animation or layout processing. -
evalAsync
public <T> T evalAsync(String pSource, Map<String, Object> pVarMap, Class<T> pResultType, long pTimeoutMs) throws InterruptedExceptionEvaluates the specified code and waits for result without blocking the UI. This method must either be called from an input event handler or from the run method of a Runnable passed toPlatform.runLater. It must not be called during animation or layout processing.- Parameters:
pVarMap- A map containing variables with values to pass to guest code execution. The map should be thread-safe.- Throws:
InterruptedException- if the specified timeout is reached
-
evalAsync
public <T> T evalAsync(String pSource, Map<String, Object> pVarMap, Function<org.graalvm.polyglot.Value, throws InterruptedExceptionT> pResultMapper, long pTimeoutMs) Evaluates the specified code and waits for result without blocking the UI. This method must either be called from an input event handler or from the run method of a Runnable passed toPlatform.runLater. It must not be called during animation or layout processing.- Parameters:
pVarMap- A map containing variables with values to pass to guest code execution. The map should be thread-safe.- Throws:
InterruptedException- if the specified timeout is reached
-
evalAsync
public <T> T evalAsync(String pSource, Function<org.graalvm.polyglot.Value, T> pResultMapper, long pTimeoutMs, Consumer<org.graalvm.polyglot.Context> pBeforeEval, Consumer<org.graalvm.polyglot.Context> pAfterEval) throws InterruptedExceptionEvaluates the specified code and waits for result without blocking the UI. This method must either be called from an input event handler or from the run method of a Runnable passed toPlatform.runLater. It must not be called during animation or layout processing.- Throws:
InterruptedException- if the specified timeout is reached
-
evalString
Evaluates the specified code and waits for result without blocking the UI. This method must either be called from an input event handler or from the run method of a Runnable passed toPlatform.runLater. It must not be called during animation or layout processing. -
evalString
Evaluates the specified code and waits for result without blocking the UI. This method must either be called from an input event handler or from the run method of a Runnable passed toPlatform.runLater. It must not be called during animation or layout processing.- Parameters:
pVarMap- A map containing variables with values to pass to guest code execution. The map should be thread-safe.
-
evalString
Evaluates the specified code and waits for result without blocking the UI. This method must either be called from an input event handler or from the run method of a Runnable passed toPlatform.runLater. It must not be called during animation or layout processing.- Throws:
InterruptedException- if the specified timeout is reached
-
evalString
public String evalString(String pSource, Map<String, Object> pVarMap, long pTimeoutMs) throws InterruptedExceptionEvaluates the specified code using the specified context executor and waits for result without blocking the UI. This method should be invoked only from the JavaFX thread. This method must either be called from an input event handler or from the run method of a Runnable passed toPlatform.runLater. It must not be called during animation or layout processing.- Parameters:
pVarMap- A map containing variables with values to pass to guest code execution. The map should be thread-safe.- Throws:
InterruptedException- if the specified timeout is reached
-