包详细信息

nodeschnaps

killmag1052LGPL-3.00.12.0

A NodeJS compatibility layer for Java (Rhino).

node, nodejs, java, rhino

自述文件

Nodeschnaps

Nodeschnaps is a node.js compatibility layer for Java Javscript engines like Rhino. The main inspiration is to run ETL transformation with the same code we use in node.js to save development time.

Travis npm npm

Features

We work hard to implement the full API of node.js. So you could load Nodeschnaps into your Rhino environment and use your node.js code without restrictions. Take a look at the current development status to get a overview of what we done so far.

Supported Platforms

  • Rhino JS
    • Pentaho Data-Integration (Kettle)
  • Nashorn
    • Pentaho Data-Integration (Kettle)

Installation

npm install nodeschnaps

Testing

Install dev dependencies:

npm install

Run tests with rhinojs:

make test

Run tests with nodejs:

make testNode

Configuration

Environment Variables

NODESCHNAPS_PATH

(required)

Path to search for modules/files (Last must be the nodeschnaps lib folder).

One path of the variable must be set to the lib folder of nodeschnaps. The path separator is like in the other path variables ":".

Nodeschnaps need to know his location to load his own modules.

The paths should be absolute to be independent from applications CWD like in the case of Kettle.

Example:

/home/you/project/node_modules:/home/you/project/node_modules/nodeschnaps/lib
NODESCHNAPS_MODIFIER

(optional)

A path to a module, what will be loaded at the start to modify the environment.

Load nodeschnaps

To load nodeschnaps the environment variable NODESCHNAPS_PATH must be set.

Optional you can use for rhino the includet rhino jar in the deps/rhino/lib folder.

Example for rhino:

java \
    -cp ./node_modules/nodeschnaps/deps/rhino/lib/rhino-1.7.11.jar \
    -DNODESCHNAPS_PATH=/home/you/project/node_modules/nodeschnaps/lib \
    org.mozilla.javascript.tools.shell.Main \
    test.js

Rhino JS / Nashorn

load('./node_modules/nodeschnaps/loader.js');

// Your code here ...

NodeJS();

Pentaho Data-Integration (Kettle)

Load on Transformation (Modified Java Script Value):

Start Script

LoadScriptFile(getEnvironmentVar('NODESCHNAPS_LOADER_FILE'));

// Your code here ...

NodeJS();

Transform Script


// Your code here ...

NodeJS();

End Script

// Your code here ...

NodeJS();
Load on Job (JavaScript):
new Function(
    org.apache.commons.io.FileUtils.readFileToString(
      new java.io.File(parent_job.getVariable('NODESCHNAPS_LOADER_FILE'))
    )
)();

// Your code here ...

NodeJS();

For a example look at: kitchen-stove

Start from Command-line

Rhino

java \
    -DNODESCHNAPS_PATH=./node_modules/nodeschnaps/lib \
    -cp ./node_modules/nodeschnaps/deps/rhino/lib/rhino-1.7.11.jar \
    org.mozilla.javascript.tools.shell.Main \
    YOUR.js

Nashorn

jjs \
    --language=es5 \
    -DNODESCHNAPS_PATH=./node_modules/nodeschnaps/lib \
    YOUR.js

Coding

Start main loop

As callback:

NodeJS(function(){
    // Your code here ...
});

Or before:

// Your code here ...

NodeJS();

更新日志

Version 0.12.0

Version 0.11.0

Version 0.10.0

Version 0.9.1

  • 669d554 [bug] Downgrade to node module buffer@4 for start issue.

Version 0.9.0

Version 0.8.0

  • 1f46fb4 [core] Add support for Nashorn Javascript.
  • 57b8925 [core] Add support for Nashorn Javascript.
  • 6ac7f78 [core] Add support for Nashorn Javascript.
  • c065a31 [core] Add support for Nashorn Javascript.
  • ec7737a [core] Add support for Nashorn Javascript.
  • b9e989e [core] Improve support for Nashorn JavaScript.
  • 41a5c0d [improvement][docs] Update README.md.
  • 0c543e6 [improvement][testing] Support skipped tests.
  • cd16abd [testing][bug] Run only testRhino on travis (Nashorn need java 8).
  • ee1f608 [testing][enhancement] Include nashorn testing in test target.
  • 2fd1cdf [testing][enhancement] Update travis configuration for nashorn testing.

Version 0.7.0

  • 1ca2689 [bug][core] Fix readed size of -1 in fs binding.
  • cf9ccdb [bug][docs] Fix travis build status.
  • a221dcd [bug][docs] Fix #13 - Cannot find module '/nodeschnaps/node.js'
  • b1825fe [bug][testing] Fix testing exit status.
  • a93e5f9 [core][deps] Update to nodejs 0.12.18.
  • 64ac4f5 [deps] Update npm dependencies.
  • ef6213a [deps] Update npm dev dependencies.
  • 13166ad [improvement][deps] Upgrade to NodeJS 0.12.17.
  • facbeec [testing] Use openjdk-7-jdk for travis.

Version 0.6.1

  • f14e5ff [core] Fix #11. Correct module loading for npm 3.

Version 0.6.0

Version 0.5.3

  • [core][fs] Correct binary data reading and writing in fs binding.
  • [core] Remove useless java sync block in async call.
  • [config] Add coding style config.

Version 0.5.2

  • 787d27f [core][deps] Update to nodejs 0.12.7.

Version 0.5.1

  • 847b7c3 [core][fs] Fix fs binding for better support of java 6.
  • 77e1bba [docs] Add shields to readme.
  • 0f80ca7 [setup] add .travis.yml

Version 0.5.0

  • 78085ee [core][crypto] Add partial node crypto support.
  • 8a02e73 [core][deps] Update to nodejs 0.12.4.
  • f67fdd9 [core] Update to nodejs 0.12.2.
  • a41e3ac [core][zlib] Add partial node zlib support.
  • e799df7 [deps] Upgrade to Rhino 1.7.6 (https://github.com/mozilla/rhino/releases/tag/Rhino1_7_6_RELEASE)
  • 0978251 [setup][docs] Add jsdoc.
  • e03f9da [setup] Remove timer debug mode.

Version 0.4.1

  • 87db1f0 [core][fs] Fix IndexOutOfBoundsException on write on BSD

Version 0.4.0

  • 336b0a0 [#9][core][require] Fix json require bug.
  • 0f1b705 [#2][core][fs] Update fs binding methods
  • 7d3d6f8 [#2][core][fs] Update fs binding methods
  • 71e4cf5 [#2][core][fs] Update fs binding methods
  • e17cebe [deps][core] Update node to 0.10.35.
  • cd69d33 [core] Add NODESCHNAPS_MODIFIER env var.
  • 67cb3dc [#2][core][fs] Update fs binding methods
  • ce65b30 [#2][core][fs] Update fs binding methods
  • 37e22a9 [deps][core] Update node to 0.10.33.
  • 3441cec [core][fs] Add first fs binding methods.

Version 0.3.1

  • aba66d2 [core][loader] Correct global, set really global.
  • 3e8558f [testing] Add testing for nashorn.

Version 0.3.0

  • 2a197a6 [deps][core] Update node to 0.10.31.
  • 9570f4e [core][timer] Correct timer functions.
  • 4d21599 [core] Optimize main loop.
  • 87fa024 [core] Implement process.env

Version 0.2.0

  • eecc505 [core] Update constants for node 0.10.30.
  • 12761e2 [deps][core] Update node to 0.10.30 and correct bindings.
  • 127381b [core] Implement "process.maxTickDepth".
  • b9978db [core] Correct loader main module.
  • 63d7022 [core] Add dummy for process umask and maxTickDepth.
  • 2ed59f4 [core][main][error] Refactor main loop and error handling.
  • add11e2 [Core][Timer] Fixed scope problem on timer run method and switched run of the timer callback on the main thread.

Version 0.1.0

  • First release.