Interface LockableScriptEngine
- All Superinterfaces:
ScriptEngine
This interface is used to indicate that a
ScriptEngine is lockable, i.e. that it doesn't support
concurrency and should run scripts inside a lock.- Author:
- Ravi Nadahar - Initial contribution
-
Field Summary
Fields inherited from interface javax.script.ScriptEngine
ARGV, ENGINE, ENGINE_VERSION, FILENAME, LANGUAGE, LANGUAGE_VERSION, NAME -
Method Summary
Modifier and TypeMethodDescriptiongetLock()default longGet the lock acquisition timeout for use withLock.tryLock(long, java.util.concurrent.TimeUnit).Methods inherited from interface javax.script.ScriptEngine
createBindings, eval, eval, eval, eval, eval, eval, get, getBindings, getContext, getFactory, put, setBindings, setContext
-
Method Details
-
getLock
Lock getLock()- Returns:
- The
Lockinstance that should be used to guard script execution.
-
getLockAcquisitionTimeoutMs
default long getLockAcquisitionTimeoutMs()Get the lock acquisition timeout for use withLock.tryLock(long, java.util.concurrent.TimeUnit). The lock should always be acquired with a timeout to avoid deadlocks.- Returns:
- The timeout period to wait when trying to acquire the
Lockin milliseconds before considering the acquisition a failure. - Implementation note:
- A default implementation with a 5 seconds timeout exists.
-