nodejs-jdbc
Version:
JDBC wrapper for Node
60 lines • 2.34 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.events = exports.getOnJvmCreated = exports.getOptions = exports.getClasspath = exports.getInstance = exports.shutdownJVM = exports.setupClasspath = exports.addOption = exports.isJvmCreated = void 0;
const node_events_1 = require("node:events");
const java = require("java");
const Helper_1 = require("./Helper");
function isJvmCreated() {
return typeof java.onJvmCreated !== 'function';
}
exports.isJvmCreated = isJvmCreated;
function addOption(option) {
if (!isJvmCreated() && option) {
java.asyncOptions = {
asyncSuffix: undefined,
syncSuffix: 'Sync',
promiseSuffix: 'Promise',
promisify: require('util').promisify,
};
java.options.push(option);
}
else if (isJvmCreated()) {
Helper_1.logger.error("You've tried to add an option to an already running JVM!");
Helper_1.logger.error("This isn't currently supported. Please add all option entries before calling any java methods");
Helper_1.logger.error('You can test for a running JVM with the isJvmCreated funtion.');
}
}
exports.addOption = addOption;
function setupClasspath(dependencyArr) {
if (!isJvmCreated() && dependencyArr) {
java.classpath.push(...dependencyArr);
}
else if (isJvmCreated()) {
Helper_1.logger.error("You've tried to add an entry to the classpath of an already running JVM!");
Helper_1.logger.error("This isn't currently supported. Please add all classpath entries before calling any java methods");
Helper_1.logger.error('You can test for a running JVM with the isJvmCreated funtion.');
}
}
exports.setupClasspath = setupClasspath;
async function shutdownJVM() {
await java.callStaticMethodSync('java.lang.System', 'exit', 0);
}
exports.shutdownJVM = shutdownJVM;
function getInstance() {
return java;
}
exports.getInstance = getInstance;
function getClasspath() {
return java.classpath;
}
exports.getClasspath = getClasspath;
function getOptions() {
return java.options;
}
exports.getOptions = getOptions;
function getOnJvmCreated() {
return java.onJvmCreated;
}
exports.getOnJvmCreated = getOnJvmCreated;
exports.events = new node_events_1.EventEmitter();
//# sourceMappingURL=jinst.js.map