Package software.amazon.jsii
Class JsiiEngine
java.lang.Object
software.amazon.jsii.JsiiEngine
- All Implemented Interfaces:
JsiiCallbackHandler
The javascript engine which supports jsii objects.
-
Method Summary
Modifier and TypeMethodDescriptioncreateNewObject(Object uninitializedNativeObject, Object... args) Given an uninitialized native object instance, reads the @Jsii annotations to determine the jsii module and FQN, and creates a JS object.Enum<?>findEnumValue(String enumRef) Given a jsii enum ref in the form "fqn/member" returns the Java enum value for it.static JsiiEnginegetObject(com.fasterxml.jackson.databind.JsonNode objRefNode) Given an obj ref, returns a Java object that represents it.getObject(JsiiObjectRef objRef) Gets an object by reference.com.fasterxml.jackson.databind.JsonNodehandleCallback(Callback callback) Invokes a local callback and returns the result/error.voidloadModule(Class<? extends JsiiModule> moduleClass) Loads a JavaScript module into the remote jsii-server.nativeFromObjRef(JsiiObjectRef objRef) Returns the native java object for a given jsii object reference.nativeToObjRef(Object nativeObject) Returns the jsii object reference given a native object.voidDequeues and processes pending jsii callbacks until there are no more callbacks to process.static voidsetQuietMode(boolean value) Silences any error and warning logging from the Engine.
-
Method Details
-
getInstance
- Returns:
- The singleton instance.
-
setQuietMode
public static void setQuietMode(boolean value) Silences any error and warning logging from the Engine. Useful when testing.- Parameters:
value- whether to silence the logs or not.
-
getClient
- Returns:
- The jsii-server HTTP client.
-
loadModule
Loads a JavaScript module into the remote jsii-server. No-op if the module is already loaded.- Parameters:
moduleClass- The jsii module class.
-
nativeFromObjRef
Returns the native java object for a given jsii object reference. If it already exists in our native objects cache, we return it. If we can't find the object in the cache, it means it was created in javascript-land, so we need to create a native wrapper with the correct type and add it to cache.- Parameters:
objRef- The object reference.- Returns:
- The jsii object the represents this remote object.
-
nativeToObjRef
Returns the jsii object reference given a native object. If the object does not have one yet, a new object reference is requested from the jsii kernel, and gets assigned to the instance before being returned.- Parameters:
nativeObject- The native object to obtain the reference for- Returns:
- A jsii object reference
-
getObject
Gets an object by reference. Throws if the object cannot be found.- Parameters:
objRef- The object reference- Returns:
- a JsiiObject
- Throws:
JsiiError- If the object is not found.
-
getObject
Given an obj ref, returns a Java object that represents it. A new object proxy object will be allocated if needed.- Parameters:
objRefNode- The objref- Returns:
- A Java object
-
findEnumValue
Given a jsii enum ref in the form "fqn/member" returns the Java enum value for it.- Parameters:
enumRef- The jsii enum ref.- Returns:
- The java enum value.
-
processAllPendingCallbacks
public void processAllPendingCallbacks()Dequeues and processes pending jsii callbacks until there are no more callbacks to process. -
handleCallback
Invokes a local callback and returns the result/error.- Specified by:
handleCallbackin interfaceJsiiCallbackHandler- Parameters:
callback- The callback to invoke.- Returns:
- The return value
- Throws:
JsiiError- if the callback failed.
-
createNewObject
Given an uninitialized native object instance, reads the @Jsii annotations to determine the jsii module and FQN, and creates a JS object. Any methods implemented on the native object are passed in as "overrides", which are overridden in the javascript side to call-back to the native method.- Parameters:
uninitializedNativeObject- An uninitialized native objectargs- Initializer arguments- Returns:
- An object reference for the new object.
-