Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package software.amazon.jsii;
import software.amazon.jsii.api.Callback;
import software.amazon.jsii.api.CreateRequest;
import software.amazon.jsii.api.JsiiOverride;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import static software.amazon.jsii.Util.extractResource;
/**
* HTTP client for jsii-server.
*/
@Internal
public final class JsiiClient {
/**
* JSON node factory.
*/
private static final JsonNodeFactory JSON = JsonNodeFactory.instance;
/**
* TCP port to connect to (always "localhost").
*/
private final JsiiRuntime runtime;
/**
* Creates a new jsii-runtime client.
* @param runtime The {@link JsiiRuntime}.
*/
public JsiiClient(final JsiiRuntime runtime) {
this.runtime = runtime;
}
/**
* Loads a JavaScript module into the remote sandbox.
* @param module The module to load
*/
public void loadModule(final JsiiModule module) {
try {
Path tarball = extractResource(module.getModuleClass(), module.getBundleResourceName(), null);
try {
ObjectNode req = makeRequest("load");
req.put("tarball", tarball.toString());
req.put("name", module.getModuleName());
req.put("version", module.getModuleVersion());
this.runtime.requestResponse(req);
} finally {
Files.delete(tarball);
Files.delete(tarball.getParent());
}
} catch (IOException e) {
throw new JsiiError("Unable to extract resource " + module.getBundleResourceName(), e);
}
}
/**
* Creates a remote jsii object.
* @param fqn The fully-qualified-name of the class.
* @param initializerArgs Constructor arguments.
* @param overrides A list of async methods to override. If a method is defined as an override, a callback
* will be scheduled when it is called, and the promise it returns will only be fulfilled
* when the callback is completed.
* @return A jsii object reference.
*/
public JsiiObjectRef createObject(final String fqn,
final Collection