Comparing version 0.2.9 to 0.3.0
{ | ||
"name": "java", | ||
"description": "Bridge API to connect with existing Java APIs.", | ||
"author": "Joe Ferner <joe.ferner@nearinfinity.com>", | ||
"author": "Joe Ferner <joe@fernsroth.com>", | ||
"keywords": [ | ||
@@ -10,3 +10,3 @@ "java", | ||
], | ||
"version": "0.2.9", | ||
"version": "0.3.0", | ||
"engines": { | ||
@@ -17,12 +17,8 @@ "node": ">=0.6.0" | ||
{ | ||
"name": "Jeff Kunkle", | ||
"email": "jeff.kunkle@nearinfinity.com" | ||
}, | ||
{ | ||
"name": "Joe Ferner", | ||
"email": "joe.ferner@nearinfinity.com" | ||
"email": "joe@fernsroth.com" | ||
} | ||
], | ||
"bugs": { | ||
"url": "https://github.com/nearinfinity/node-java/issues" | ||
"url": "https://github.com/joeferner/node-java/issues" | ||
}, | ||
@@ -32,5 +28,6 @@ "license": "MIT", | ||
"type": "git", | ||
"url": "https://github.com/nearinfinity/node-java.git" | ||
"url": "https://github.com/joeferner/node-java.git" | ||
}, | ||
"dependencies": { | ||
"find-java-home": "0.0.3" | ||
}, | ||
@@ -37,0 +34,0 @@ "devDependencies": { |
@@ -22,2 +22,4 @@ # java | ||
This path cannot have quotes. | ||
* If you see an error such as "Call to 'node findJavaHome.js' returned exit status 1" | ||
Try running `node findJavaHome.js` in the node-java directory to see the full failure message. | ||
@@ -437,2 +439,51 @@ | ||
# Signal Handling | ||
The JVM intercepts signals (Ctrl+C, etc.) before node/v8 gets to handle them. To fix this there are a couple options. | ||
## Signal Handling Option 1 | ||
One option to capture these events is to add the following. | ||
``` | ||
java.options.push('-Xrs'); | ||
``` | ||
## Signal Handling Option 2 | ||
Hook into the runtime shutdown hook. | ||
First create a java wrapper around the Runtime.addShutdownHook method to allow using a proxy object. | ||
```java | ||
public class ShutdownHookHelper { | ||
public static void setShutdownHook(final Runnable r) { | ||
Runtime.getRuntime().addShutdownHook(new Thread() { | ||
@Override | ||
public void run() { | ||
r.run(); | ||
} | ||
}); | ||
} | ||
} | ||
``` | ||
Compile ShutdownHookHelper and then use it as follows. | ||
```javascript | ||
var java = require('./'); | ||
java.classpath.push('.'); | ||
var ShutdownHookHelper = java.import('ShutdownHookHelper'); | ||
ShutdownHookHelper.setShutdownHookSync(java.newProxy('java.lang.Runnable', { | ||
run: function () { | ||
console.log("do shutdown stuff here instead."); | ||
} | ||
})); | ||
``` | ||
# Object lifetime | ||
When you call a Java method through node-java, any arguments (V8/JavaScript objects) will be converted to Java objects on the v8 main thread via a call to v8ToJava (found in utils.cpp). The JavaScript object is not held on to and can be garbage collected by v8. If this is an async call, the reference count on the Java objects will be incremented. The Java method will be invoked in a node.js async thread (see uv_queue_work). When the method returns, the resulting object will be returned to the main v8 thread and converted to JavaScript objects via a call to javaToV8 and the Java object's reference count will then be decremented to allow for garbage collection. The resulting v8 object will then be returned to the callers callback function. | ||
## License | ||
@@ -439,0 +490,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
2280382
58
931
511
1
+ Addedfind-java-home@0.0.3
+ Addedfind-java-home@0.0.3(transitive)