Class Engine.Builder
- Enclosing class:
Engine
- Since:
- 19.0
-
Method Summary
Modifier and TypeMethodDescriptionallowExperimentalOptions
(boolean enabled) Allow experimental options to be used for instruments and engine options.build()
Creates a new engine instance from the configuration provided in the builder.err
(OutputStream err) Sets the standard error stream to be used for this engine.in
(InputStream in) Sets the standard input stream to be used for this engine.logHandler
(OutputStream logOut) Installs a new loggingHandler
using givenOutputStream
.logHandler
(Handler logHandler) Installs a new loggingHandler
.Shortcut for setting multipleoptions
using a map.out
(OutputStream out) Sets the standard output stream to be used for this engine.sandbox
(SandboxPolicy policy) Sets a code sandbox policy to an engine.serverTransport
(MessageTransport serverTransport) Take over transport of message communication with a server peer.useSystemProperties
(boolean enabled) Specifies whether the engine should usesystem properties
if no explicit option isset
.
-
Method Details
-
out
Sets the standard output stream to be used for this engine. Every context that uses this engine will inherit the configured output stream if it is not specified in the context. If not set then the system output stream will be used.- Since:
- 19.0
-
err
Sets the standard error stream to be used for this engine. Every context that uses this engine will inherit the configured error stream if it is not specified in the context. If not set then the system error stream will be used.- Since:
- 19.0
-
in
Sets the standard input stream to be used for this engine. Every context that uses this engine will inherit the configured input stream if it is not specified in the context. If not set then the system input stream will be used.- Since:
- 19.0
-
allowExperimentalOptions
Allow experimental options to be used for instruments and engine options. Do not use experimental options in production environments. If set tofalse
(the default), then passing an experimental option results in anIllegalArgumentException
when the context is built.- Since:
- 19.0
-
useSystemProperties
Specifies whether the engine should usesystem properties
if no explicit option isset
. The default value istrue
indicating that the system properties should be used. System properties are looked up with the prefix "polyglot" in order to disambiguate existing system properties. For example, for the option with the key"js.ECMACompatiblity"
, the system property"polyglot.js.ECMACompatiblity"
is read. Invalid options specified using system properties will cause thebuild
method to fail using anIllegalArgumentException
. System properties are read once when the engine is built and are never updated after that.- Parameters:
enabled
- iftrue
system properties will be used as options.- Since:
- 19.0
- See Also:
-
option
Sets an option for anengine
,language
orinstrument
.If one of the set option keys or values is invalid then an
IllegalArgumentException
is thrown when the engine isbuilt
. The given key and value must not benull
.See
Engine.getOptions()
to list all available options for engines.See
Language.getOptions()
to list all available options for alanguage
.See
Instrument.getOptions()
to list all available options for aninstrument
.- Since:
- 19.0
-
sandbox
Sets a code sandbox policy to an engine. By default, the engine's sandbox policy isSandboxPolicy.TRUSTED
, there are no restrictions to the engine configuration.- Since:
- 23.0
- See Also:
-
options
Shortcut for setting multipleoptions
using a map. All values of the provided map must be non-null.- Parameters:
options
- a map options.- Since:
- 19.0
- See Also:
-
serverTransport
Take over transport of message communication with a server peer. Provide an implementation ofMessageTransport
to virtualize a transport of messages to a server endpoint.MessageTransport.open(java.net.URI, org.graalvm.polyglot.io.MessageEndpoint)
corresponds to accept of a server socket.- Parameters:
serverTransport
- an implementation of message transport interceptor- Since:
- 19.0
- See Also:
-
logHandler
Installs a new loggingHandler
. The logger'sLevel
configuration is done using theEngine's options
. The level option key has the following format:log.languageId.loggerName.level
orlog.instrumentId.loggerName.level
. The value is either the name of pre-definedLevel
constant or a numericLevel
value. If not explicitly set in options the level is inherited from the parent logger.Examples of setting log level options:
builder.option("log.level","FINE");
sets theFINE level
to allTruffleLogger
s.
builder.option("log.js.level","FINE");
sets theFINE level
to JavaScriptTruffleLogger
s.
builder.option("log.js.com.oracle.truffle.js.parser.JavaScriptLanguage.level","FINE");
sets theFINE level
toTruffleLogger
for theJavaScriptLanguage
class.- Parameters:
logHandler
- theHandler
to use for logging in engine'sContext
s. The passedlogHandler
is closed when the engine isclosed
.- Returns:
- the
Engine.Builder
- Since:
- 19.0
-
logHandler
Installs a new loggingHandler
using givenOutputStream
. The logger'sLevel
configuration is done using theEngine's options
. The level option key has the following format:log.languageId.loggerName.level
orlog.instrumentId.loggerName.level
. The value is either the name of pre-definedLevel
constant or a numericLevel
value. If not explicitly set in options the level is inherited from the parent logger.Examples of setting log level options:
builder.option("log.level","FINE");
sets theFINE level
to allTruffleLogger
s.
builder.option("log.js.level","FINE");
sets theFINE level
to JavaScriptTruffleLogger
s.
builder.option("log.js.com.oracle.truffle.js.parser.JavaScriptLanguage.level","FINE");
sets theFINE level
toTruffleLogger
for theJavaScriptLanguage
class.- Parameters:
logOut
- theOutputStream
to use for logging in engine'sContext
s. The passedlogOut
stream is closed when the engine isclosed
.- Returns:
- the
Engine.Builder
- Since:
- 19.0
-
build
Creates a new engine instance from the configuration provided in the builder. The same engine builder can be used to create multiple engine instances.- Since:
- 19.0
-