redseal-java
Advanced tools
Comparing version 0.5.1 to 0.5.2
@@ -111,3 +111,3 @@ 'use strict'; | ||
// This function launches the JVM asynchronously. The application can be notified | ||
// This function ensures that the JVM has been launched, asynchronously. The application can be notified | ||
// when the JVM is fully created via either a node callback function, or via a promise. | ||
@@ -118,3 +118,6 @@ // If the parameter `callback` is provided, it is assume be a node callback function. | ||
// promisified function. | ||
java.launchJvm = function(callback) { | ||
// This function may be called multiple times -- the 2nd and subsequent calls are no-ops. | ||
// However, once this method has been called (or the JVM is launched as a side effect of calling other java | ||
// methods), then clients can no longer use the registerClient API. | ||
java.ensureJvm = function(callback) { | ||
@@ -125,3 +128,3 @@ // First see if the promise-style API should be used. | ||
// Create a promisified version of this function. | ||
var launchJvmPromise = java.asyncOptions.promisify(java.launchJvm.bind(java)); | ||
var launchJvmPromise = java.asyncOptions.promisify(java.ensureJvm.bind(java)); | ||
// Call the promisified function, returning its result, which should be a promise. | ||
@@ -136,5 +139,6 @@ return launchJvmPromise(); | ||
// Now check if the JVM has already been created, and if so return an error via the callback. | ||
// Now check if the JVM has already been created. If so, we assume that the jvm was already successfully | ||
// launched, and we can just implement idempotent behavior, i.e. silently notify that the JVM has been created. | ||
else if (java.isJvmCreated()) { | ||
return setImmediate(callback, new Error('java.launchJvm(cb) called after JVM already created.')); | ||
return setImmediate(callback); | ||
} | ||
@@ -141,0 +145,0 @@ |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"engines": { | ||
@@ -13,0 +13,0 @@ "node": ">=0.10.0" |
@@ -24,3 +24,3 @@ // testClientBeforeError.js | ||
java.launchJvm(function(err) { | ||
java.ensureJvm(function(err) { | ||
test.ok(_.isObject(err)); | ||
@@ -27,0 +27,0 @@ test.ok(err instanceof Error); |
@@ -24,3 +24,3 @@ // testClientBeforeThrows.js | ||
java.launchJvm(function(err) { | ||
java.ensureJvm(function(err) { | ||
test.ok(_.isObject(err)); | ||
@@ -27,0 +27,0 @@ test.ok(err instanceof Error); |
@@ -30,3 +30,3 @@ // testClientPBeforeError.js | ||
java.launchJvm().done( | ||
java.ensureJvm().done( | ||
function () { | ||
@@ -33,0 +33,0 @@ test.ok(false); |
@@ -30,3 +30,3 @@ // testClientPBeforeThrows.js | ||
java.launchJvm().done( | ||
java.ensureJvm().done( | ||
function () { | ||
@@ -33,0 +33,0 @@ test.ok(false); |
@@ -12,3 +12,3 @@ // testDefacto.js | ||
launch: function(test) { | ||
test.expect(8); | ||
test.expect(9); | ||
var api = _.functions(java); | ||
@@ -37,6 +37,11 @@ test.ok(_.includes(api, 'isJvmCreated'), 'Expected `isJvmCreated` to be present, but it is NOT.'); | ||
java.launchJvm(function(err) { | ||
java.ensureJvm(function(err) { | ||
test.ifError(err); | ||
test.ok(java.isJvmCreated()); | ||
test.done(); | ||
// Verify that ensureJvm is idempotent | ||
java.ensureJvm(function(err) { | ||
test.ifError(err); | ||
test.done(); | ||
}); | ||
}); | ||
@@ -43,0 +48,0 @@ }, |
@@ -37,3 +37,3 @@ // testDefactoPlusPromise.js | ||
java.launchJvm().done(function() { | ||
java.ensureJvm().done(function() { | ||
test.ok(java.isJvmCreated()); | ||
@@ -40,0 +40,0 @@ test.done(); |
@@ -18,4 +18,4 @@ // testInvalidLaunch.js | ||
// First show that if asyncOptions.promisify is undefined, using the promise variant of launchJvm throws an error. | ||
test.throws(function() { java.launchJvm(); }, Error, /requires its one argument to be a callback function/); | ||
// First show that if asyncOptions.promisify is undefined, using the promise variant of ensureJvm throws an error. | ||
test.throws(function() { java.ensureJvm(); }, Error, /requires its one argument to be a callback function/); | ||
@@ -36,3 +36,3 @@ test.ok(!java.isJvmCreated()); | ||
test.throws(function() { java.launchJvm('foo'); }, Error, /requires its one argument to be a callback function/); | ||
test.throws(function() { java.ensureJvm('foo'); }, Error, /requires its one argument to be a callback function/); | ||
@@ -55,3 +55,3 @@ test.ok(!java.isJvmCreated()); | ||
java.launchJvm().done(function() { | ||
java.ensureJvm().done(function() { | ||
test.ok(java.isJvmCreated()); | ||
@@ -58,0 +58,0 @@ test.done(); |
@@ -43,3 +43,3 @@ // testNoAsync.js | ||
java.launchJvm().done(function() { | ||
java.ensureJvm().done(function() { | ||
test.ok(java.isJvmCreated()); | ||
@@ -46,0 +46,0 @@ test.done(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
2612719
2578
2