Coder Social home page Coder Social logo

vert-x / mod-lang-js Goto Github PK

View Code? Open in Web Editor NEW
14.0 5.0 13.0 2.18 MB

Vert.x 2.x is deprecated - use instead

Home Page: https://github.com/vert-x3/vertx-lang-js

License: Other

JavaScript 98.66% Shell 0.18% CSS 0.82% Java 0.13% Batchfile 0.15% HTML 0.06%

mod-lang-js's Introduction

Vert.x 2.x is deprecated - use instead https://github.com/vert-x3/vertx-lang-js

Javascript Language Module for Vert.x

Build Status

This is the Javascript language module used by mod-lang-dynjs and mod-lang-rhino. This module is not typically used directly, but rather both mod-lang-rhino and mod-lang-dynjs have a dependency on this module which provides the core Javascript API for Vert.x.

Documentation

Continuous Integration

The module is built on our Cloudbees CI server, as well as on Travis CI with each push to GitHub.

Running the tests

You'll need to have Maven and JDK7 or better installed. If you don't, do that first. Then you can clone and build.

$ git clone https://github.com/vert-x/mod-lang-js.git
$ cd mod-lang-js
$ mvn verify

This will run all of the integration tests against both mod-lang-rhino and mod-lang-dynjs.

If you're hacking on this code and want to install this module locally:

$ mvn install

Now your local vert.x installation will pick up the local version when testing against mod-lang-dynjs or mod-lang-rhino.

By default, vert.x runs Javascript verticles and modules with Rhino. Change this by creating a langs.properties file at the root of your project that looks like this for dynjs.

dynjs=io.vertx~lang-dynjs~1.0.1:org.dynjs.vertx.DynJSVerticleFactory
.js=dynjs

Or if you want to use the experimental nashorn module, do this.

nashorn=io.vertx~lang-nashorn~1.0.0-beta2-SNAPSHOT:org.vertx.java.platform.impl.NashornVerticleFactory
.js=nashorn

Enjoy. And if you have any problems, hit us on on freenode at #dynjs or #vertx.

mod-lang-js's People

Contributors

lance avatar purplefox avatar t-beckmann avatar vietj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mod-lang-js's Issues

JSON array deserialization problem on the event bus

Arrays cannot be used as "top level" structure on the event bus. The following code exhibits the problem:

var console = require('vertx/console');
var container = require('vertx/container');
var eb = require('vertx').eventBus;

var sendData  = ['abc'];

eb.registerHandler('ebAdr', function (data, replier) {
    console.log('DATA: ' + JSON.stringify(data));
});

eb.send('ebAdr', sendData, function (reply) {
    container.exit();
});

The following error is thrown:

org.mozilla.javascript.WrappedException: Wrapped org.vertx.java.core.json.DecodeException: Failed to decode:Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token

Nashorn can't complete test suite

Nashorn considers JavaThing#op(String arg) and JavaThing#op(CharSequence arg) to be ambiguous. I think this is probably a bug in nashorn, since it should at least not fail. However tests begin failing with error messages like:

SEVERE: Exception in Nashorn JavaScript verticle
java.lang.RuntimeException: java.lang.NoSuchMethodException: Can't unambiguously select between fixed arity signatures [(java.lang.String, java.lang.String), (java.lang.CharSequence, java.lang.CharSequence)] of the method org.vertx.java.core.http.impl.HttpHeadersAdapter.set for argument types [java.lang.String, jdk.nashorn.internal.runtime.ConsString]
at org.vertx.java.core.Handler$$NashornJavaAdapter.handle(Unknown Source)
at org.vertx.java.core.http.impl.DefaultHttpServer$4$1.run(DefaultHttpServer.java:250)

Mistake in file_system.js - chown/chmod confusion

While creating the TypeScript definitions I have noticed a mistake in file_system.js where the newly created method which should be called chownSync is in fact called chmodSync. I've issued a pull request and signed the Eclipse CLA. Not sure if I can link this to the pull request after the fact but I'll try. Thanks.

Don't assume an event bus message has an address property

This commit breaks backwards compatibility.

#7

The fix requires that the event bus always call jMsg.address(), which hasn't always existed. Therefore, with older versions of vert.x users will see this message.

org.dynjs.exception.ThrowException: TypeError: not callable: [DerefRef: value=undefined; ref=[Reference: name=address; base=org.vertx.java.core.eventbus.impl.JsonObjectMessage@809f86c (org.vertx.java.core.eventbus.impl.JsonObjectMessage)]]

This would cause breakage for users of lang-rhino 2.0.0-final or any recent SNAPSHOT of lang-rhino or lang-dynjs who upgrade their language module to 2.1 for rhino or 1.0 for dynjs, but don't update their vert.x. Admittedly a silly thing to do, but there you go.

Implement new EventBus send timeouts

The Java eventbus now supports sends with timeout, also the Message class supports replies with timeouts.

We should expose this new functionality in the JS API too

setTimeout or setImmediate shim

I'm sure this is not the first time it's come up, but I would like to see the Vert.x JavaScript module support support some form of the setTimeout or setImmediate functions out of the box. This would make it immediately compatible with tools which require this, such as Q or async.

I created a pull request for Q, but kriskowal suggest adding support for one of these functions in Vert.x itself, and to be honest I agree. I make extensive use for both async and Q throughout my code, and I've had to use custom versions of both in order to make them work. Would it be possible to just add a shim around vertx.runOnContext or similar? If it already exists in the code, can we enable it by default?

Add support to pass config objects to modules and verticles deployed from JavaScript

Need support for the equivalent Java methods of:

deployVerticle(name, config)
deployModule(name, config)
deployVerticle(name, config, ResultHandler)
deployModule(name, config, ResultHandler)

Currently, if I want to deploy the JDBC Persistor module, I have to deploy it from Java because JavaScript doesn't allow the passing of config objects to programmatically deployed modules and verticles. This means that MUST write code in a language which the rest of my team cannot easily support.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.