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 loggingHandlerusing givenOutputStream.logHandler(Handler logHandler) Installs a new loggingHandler.Shortcut for setting multipleoptionsusing 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 propertiesif 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 anIllegalArgumentExceptionwhen the context is built.- Since:
- 19.0
-
useSystemProperties
Specifies whether the engine should usesystem propertiesif no explicit option isset. The default value istrueindicating 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 thebuildmethod to fail using anIllegalArgumentException. System properties are read once when the engine is built and are never updated after that.- Parameters:
enabled- iftruesystem properties will be used as options.- Since:
- 19.0
- See Also:
-
option
Sets an option for anengine,languageorinstrument.If one of the set option keys or values is invalid then an
IllegalArgumentExceptionis 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 multipleoptionsusing 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 ofMessageTransportto 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'sLevelconfiguration is done using theEngine's options. The level option key has the following format:log.languageId.loggerName.levelorlog.instrumentId.loggerName.level. The value is either the name of pre-definedLevelconstant or a numericLevelvalue. 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 levelto allTruffleLoggers.
builder.option("log.js.level","FINE");sets theFINE levelto JavaScriptTruffleLoggers.
builder.option("log.js.com.oracle.truffle.js.parser.JavaScriptLanguage.level","FINE");sets theFINE leveltoTruffleLoggerfor theJavaScriptLanguageclass.- Parameters:
logHandler- theHandlerto use for logging in engine'sContexts. The passedlogHandleris closed when the engine isclosed.- Returns:
- the
Engine.Builder - Since:
- 19.0
-
logHandler
Installs a new loggingHandlerusing givenOutputStream. The logger'sLevelconfiguration is done using theEngine's options. The level option key has the following format:log.languageId.loggerName.levelorlog.instrumentId.loggerName.level. The value is either the name of pre-definedLevelconstant or a numericLevelvalue. 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 levelto allTruffleLoggers.
builder.option("log.js.level","FINE");sets theFINE levelto JavaScriptTruffleLoggers.
builder.option("log.js.com.oracle.truffle.js.parser.JavaScriptLanguage.level","FINE");sets theFINE leveltoTruffleLoggerfor theJavaScriptLanguageclass.- Parameters:
logOut- theOutputStreamto use for logging in engine'sContexts. The passedlogOutstream 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
-