npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ella

v1.5.1

Published

Is an NodeJS native plugin to allow Java code execution inside V8/NodeJS container. Is done in C++11 to make use of object oriented design.

Downloads

207

Readme

Ella

Is an NodeJS native plugin to allow Java code execution inside V8/NodeJS container. Is done in C++11 to make use of object oriented design.

###Why

  • Because Java have very good ecosystem of libraries like PDFBox, iText, Solr, etc.., all mature and useful.
  • The objective is to create wrappers around the library you want and use it in your Node app.
  • Easing Node.js integration with legacy Java system.
  • Performance, comunication between JS and a JVM method is ≈<1ms.

Features

  • The JVM run in the same NodeJS process as a native add-on so comunication between each other is fast.
  • Allow you to load jar/classes and use them inside NodeJS like Javascript objects literals.
  • The API can choose the right method giving a set of arguments, so it solves the method overloading in Java. [experimental].
  • Exception handling, exception thrown by JVM are translated to Javascript exception.
Multi-Thread
  • You can send blocking Java calls to a background thread and assign a callback to continue when finished. alt tag
Performance
  • This is part of the LibJNI project, but explain how the performance is achieved by using this broker class to hide the caching/reflection details to the object class, this server class can be easily replace by custom made or platform specific implementantion, you just need to implement the same method signature and thats it. alt tag

Things to be added soon.

  • support to static classes.

  • support to non-void constructor.

  • support for java.lang.object derivatives args/return.

Supported types [for now]

  • Primitive

    • int
    • java.lang.String
    • double
    • byte[] - to Buffer to handle binaries.
  • Object [comming soon...]

Installation

Ella requires Node.js v4+ to run.

$ export JAVA_HOME=/jdk/location/     #finish with / is important here, there is a bug in the installer :(
$ npm install ella

Methods

setClassPath ( path: string array, recursive: true)

path: array, paths where to find the .jars/.class

recursive: true/false, if true look for jar/classes recursively.

This method allow us to configure the classpath,

	var ella = require('ella');
	ella.setClassPath(['/folder/with/.jars/.class', ...], true);  //if true flag, it will look recursively all jars/class. 

getClassPath ( void )

return the classpath configuration.

This method allow us to configure the classpath.

	ella.getClassPath();  //myjar1.jar:myjar2.jar   

start ( callback )

create an JVM instance asynchronously.

callback(instance): function take as parameter an instance of the JVM.

This method allow us to configure the classpath.

	ella.start(function(vm){  /* do some work with vm */   })

vm.new (string qualified classname)

given a classname create a new object.

	var stringBuffer = vm.new('java.lang.StringBuffer');
	
	// stringBuffer.append
	// stringBuffer.insert
	// stringBuffer.substring 
	// ....

sync call

To make an sync call just call the method.

	stringBuffer.append('hello'); 
	console.log(stringBuffer.toString() );  //hello. 

async call

Just call the method as normal and add a function callback as an extra parameter this extra parameter transform the call to async.

	
	var pdf = vm.new('com.pdf.Library'); // method signature  byte[] createPDF(string); 
	
	var buffer = pdf.createPDF('my_blocking.pdf');   // this call will block the interpreter in this position. 
	
	// the addition of an anonymous function make all jvm->js-method async.
	pdf.createPDF('my_async.pdf', function(buffer){  /* do some work with buffer */ }); // non-blocking call.
	
	//js code.......