project avatar: server side javascript on the jvm geecon ...€¦ · node.js programming model...

42
Project Avatar: Server Side JavaScript on the JVM GeeCon - May 2014 David Delabassee @delabassee Software Evangelist - Oracle

Upload: others

Post on 09-Aug-2020

14 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Project Avatar: Server Side JavaScript on the JVM GeeCon - May 2014

!David Delabassee @delabassee Software Evangelist - Oracle

Page 2: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.2

The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

Page 3: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Agenda

▪ Web Application Architecture Evolution ▪ JavaScript and Node on the JVM ▪ Project Avatar – Advanced JavaScript Services ▪ Avatar Client Framework ▪ Summary

3

Page 4: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Evolution of Web Application Architecture

4

ClientServer

Pre

sent

atio

n !

(Ser

vlet

/ JS

P)

Ent

erpr

ise

Con

nect

ivity

and

Bus

ines

s Lo

gic

Http

▪ Request / Response ▪ Multi-Page Application

BrowserJava EE / JVM

A Java EE Perspective

Page 5: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Evolution of Web Application Architecture

5

A Java EE Perspective

Pre

sent

atio

n !

(Ser

vlet

/ JS

P,

JSF)

Con

nect

ivity

(RE

ST

SS

E)

Ent

erpr

ise

Con

nect

ivity

and

Bus

ines

s Lo

gic

Http

REST

Java EE / JVM

▪ Multi-Page Application ▪ In-page updates (AJAX)

JavaScript

BrowserClientServer

Page 6: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Evolution of Web Application Architecture

6

A Java EE Perspective

Http, REST

REST, SSE, WebSockets

Pre

sent

atio

n !

(Ser

vlet

/ JS

P,

JSF)

Con

nect

ivity

(Web

Soc

ket,

RE

ST,

SS

E)

Ent

erpr

ise

Con

nect

ivity

and

Bus

ines

s Lo

gic

Java EE / JVM

▪ Single-page applications ▪ View/Controller in browser ▪ Model on server

View

Con

trolle

r

JavaScript

BrowserClientServer

Page 7: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Java EE – The Latest in Enterprise Java

7

ENTERPRISE EDITIONDEVELOPER

PRODUCTIVITYMEETING ENTERPRISE DEMANDS

Java EE 7

▪ Batch ▪ Concurrency ▪ Simplified JMS

▪ More annotated POJOs ▪ Less boilerplate code ▪ Cohesive integrated

platform▪ WebSockets ▪ JSON ▪ Servlet 3.1 NIO ▪ REST

Page 8: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Node.js

▪ Server-side JavaScript platform based on Chrome v8 ▪ Created by Ryan Dahl (2009), Open Source ▪ Designed for fast, scalable network applications ▪ Event-driven, non-blocking I/O model ▪ “Melting pot community”

▪ JavaScript, Java, .NET, PHP, … ▪ Very active, with 60,000+ modules

8

Server Side JavaScript

Page 9: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Node.js Programming Model

▪ Multi-threading is hard ▪ Thousands of concurrent connections ▪ Deal with deadlocks and race conditions

▪ Blocking I/O is bad

9

▪ Single threaded ▪ Event-loop

▪ Callback model ▪ Non-blocking I/O calls

HTTP Callback Example:

Page 10: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Node.js Event Loop

10

Single-ThreadedEvent Loop

Resource-Intensive Operations

Network

File System

Network

Compute

Register Callback

CompleteOperation

Client Requests

(Http)

Response

Page 11: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.11

REST/SSE/WebSockets

Java

Scr

ipt

ClientServerNode

Evolution of Web Application Architecture

▪ Project-based end-to-end JavaScript ▪ Rapid prototyping & API layer ▪ Leverage backend resources

▪ Aggregate & transform content ▪ Return JSON to browser

Mobile-enabling existing services

View

Con

trolle

r

JavaScript

Browser

Page 12: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.12

Evolution of Web Application ArchitectureMobile-enabling existing services

Ent

erpr

ise

Con

nect

ivity

and

Bus

ines

s Lo

gic

Java EE / JVM

Java

Scr

ipt

What if we could run Nodealongside Java EE inthe same JVM?

View

Con

trolle

r

JavaScript

Browser

REST / SSE/ WebSockets

Node

ClientServer

Page 13: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.13

JavaScript and Node on the JVM

Page 14: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Project Nashorn

▪ ECMAScript 5.1 compliant ▪ Bundled with JDK 8

▪ Replaces Rhino ▪ Faster (2x – 10x) ▪ More secure

▪ Java <-> JavaScript interoperability

14

JavaScript on the JVM

http://download.java.net/jdk8/docs/technotes/guides/scripting/nashorn/index.html

Page 15: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Avatar.js

▪ Platform for server side JavaScript applications ▪ Requires Nashorn (JDK 8) ▪ 95% Node compatibility

▪ Use popular packages (Express, async, commander, etc) ▪ Uses same portability libraries as Node.js ▪ Limitation: No Chrome v8 native APIs

▪ Avatar.js Advantages ▪ Leverage JVM ▪ e.g. Java frameworks, libraries, tools…

15

Page 16: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Avatar.js = Node + Java

16

Leverage Java, including Threads

Java

JavaScript

java.lang.Thread

java.util.SortedSet

java.math.BigInteger

Node App

JVM Process

com.myorg.MyObj

require (‘async’)

postE

vent(

)▪ Node Programming Model

▪ Code in JavaScript ▪ Single event loop / thread ▪ Require (import) Node modules

▪ Invoke Java code ▪ Java types and libraries ▪ new java.lang.Thread(); ▪ new com.myorg.MyObj(); ▪ …

Page 17: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.17

Project Avatar:Advanced JavaScript ServicesLeveraging Java EE

Page 18: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Project Avatar

▪ Similar in spirit to Servlets, but focused on REST, WebSocket, Server Sent Event endpoints

▪ Use familiar Node.js event-driven programming model and modules ▪ Layers on Avatar.js Node-compatible runtime ▪ Adds integrated enterprise features

18

A Server Side JavaScript Services Framework

Page 19: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Project Avatar

▪ Multi-threading, lightweight message passing, no mutable shared state

▪ HTTP listener / load-balancer managed by framework ▪ Model Store – Object Relational Mapping ▪ Messaging – JMS on Java EE container

19

Leveraging the JVM and Java EE

Page 20: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Avatar Architecture

20

Server sideServer Database

Data

Notification

JDK 8 / Nashorn

Avatar Runtime

Node Modules

Avatar Modules

Server Runtime (Java EE)

Application Services

= Java framework= JavaScript framework= Application code

Avatar.js

Page 21: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Avatar Services

21

Java

JVM Process

JavaScriptServices Services ServicesServices

Database

Data

Notification

shared state

JSON JSON JSON JSON

HTTP Load Balancer

Multi-core, state sharing, data storage

Page 22: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Shared State

▪ MessageBus ▪ Publish/subscribe message passing ▪ Shared State

▪ Simple map API ▪ Application-scoped instance ▪ Session-scoped instance

▪ Named ▪ Leased, with configurable timeout

▪ Provide required serialization, concurrency, and caching

22

Lightweight inter-thread communication

Page 23: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Shared State Example

23

var avatar = require(‘org/glassfish/avatar’);! var threads = require(‘org/glassfish/avatar/threads’);! var app = avatar.application;! var name = app.name;! var bus = app.bus;!! // Listen for messages on the ‘alert’ topic! bus.on(‘alert’, function(msg) {! print(name + ‘ got ‘ + msg); ! });!! // Start a background thread which publishes to the ‘alert’ topic! threads.newBackgroundThread(‘alert’, ‘monitor.js’).start();!

Page 24: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Shared State Example

24

// monitor.js! var avatar = require('org/glassfish/avatar');! var app = avatar.application;! var state = app.state;! var bus = app.bus;!! …! // Something’s wrong! bus.publish('alert', ‘ some info ’ );! …!

Page 25: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Push Service Example

25

var avatar = require(‘org/glassfish/avatar’);! var threads = require('org/glassfish/avatar/threads');! var bus = avatar.application.bus;!! // Register a push service that forwards background messages! avatar.registerPushService({url: 'push/message'}, function () { ! this.onOpen = function (context) {! bus.on(’background', function(msg) {! context.sendMessage({body: msg});! });! };! });!! // Create and start a background thread that publishes messages! threads.newBackgroundThread(‘background’, ‘monitor.js’).start();!

Page 26: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

WebSocket Service Example

26

// Load avatar module! var avatar = require(‘org/glassfish/avatar’); !! // Register service instance! avatar.registerSocketService({ url:‘websocket/chat’ },function() { !

this.data = { transcript : ‘’ };!

this.onMessage = function (peer, message) { this.data.transcript += message; this.data.transcript += ‘\n’; peer.getContext().sendAll(this.data);! };! });!

Page 27: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Model-Store Framework

▪ JavaScript ORM library ▪ Pure JavaScript API that

▪ Supports relational and non-relational databases ▪ Integration with other Avatar services

▪ Similar to pure Node.js libraries ▪ Sequelize, JugglingDB, db…

27

Page 28: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Model-Store API

28

Model and Database setup

var Product = avatar.newModel({! "name": {! type: "string",! primary: true! },! "price": "number",! "quantity": "integer"! });!

var store = avatar.newStore(‘mysql’, {! host: ‘localhost’,! port: 3306,! database: ‘test’,! username: ‘someUser’,! password: ‘gu3ssIt’,! createDb: true,! dropTables: true! });!

Page 29: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Model-Store Example

29

Creating and Storing an Object

// Binds Product model with store! Product.bind(store); ! // Insert a new product into the db! store.connect(function() { Product.create({ name: 'Widget',! price: 1.00, quantity: 2 }, function(err, w1) { console.log(JSON.stringify(w1)); store.disconnect(function() { // Done! }); }); });

▪ Bind Model to Store !▪ Connect to Store

▪ Creates Product table if required ▪ Callback adds product to table

Page 30: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Model-Store Example

30

Relationships var Family = avatarModel.newModel('family',{! "name": {! type: "string",! primary: true! },! "description": "string"! });!! var Product = avatarModel.newModel('product',{! "name": {! type: "string",! primary: true! },! "madeBy": "string",! "price": "number",! "quantity": "integer"! });!

! Family.hasMany(Product, {! as: 'products',! foreign: 'family'! });!! store.bind(Family, Product);

…! // for a given ‘f’! f.products.create(o).then(function(p) {! // Creating prod. (p.name) ! // in family (f.name)! …

Page 31: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Model-Store API

▪ Models can have relationships with other models ▪ 1:1, 1:n, M,N

▪ Relational Data Stores ▪ Tested: Oracle DB, MySQL, Derby (Embedded, Network) ▪ Non-tested: Any other JDBC driver

▪ Non-relational Data Stores ▪ Oracle NoSQL, MongoDB (in progress)

31

Page 32: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Model-Store API

▪ Lots of possibilities and ideas ▪ Configure JPA provider using properties ▪ Generate JavaScript model from database schema ▪ User transactions ▪ 2nd level JPA cache, TopLink Grid ▪ Oracle RAC Support, …

▪ Maintain pure JavaScript API ▪ We’re looking for YOUR feedback!

32

Opportunities to leverage JPA

Page 33: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

JMS Example

33

!    var  myJMS  =  new  avatar.JMS({connectionFactoryName:  “MyConnectionFactory",                          destinationName:  “MyTopic"}  );  !    //  Adding  listener…      myJMS.$addListener(  function(message)  {                        console.log("Got  message:  "+message);      })      .then(  function()  {                        //  Sending  message…                        return  myJMS.$send("Some  message.");      })      .then(  function()  {                        console.log("Message  sent.");      });  

Page 34: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.34

Avatar Client Framework

Page 35: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Avatar Architecture - Server and Client

35

Server

Client

REST/WebSocket/SSE

*.html

*.css

*.js HTP

Database

Data

Notification

JDK 8 / Nashorn

Avatar Compiler

Avatar Runtime

Node Modules

Avatar Modules

Server Runtime (Java EE)

Application Services

Application Views

= Java framework= JavaScript framework= Application code

Avatar.js

Page 36: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Hello World

36

<script data-model=”local” data-instance="name">!       var NameModel = function() {!             this.first = "John";!             this.last = "Doe";!             this.clear = function() { this.first = this.last = "”; }; ! };! </script>!

View

<form>! <label for="first">First Name</label>! <input id="first" type="text” data-value="#{name.first}"/>! <label for=“last">Last Name</label>! <input id=“last" type="text” data-value="#{name.last}"/>! Hello #{name.first} #{name.last}! <button onclick="#{name.clear()}”>Clear</button>! </form>!

Model

Page 37: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Chat WebSocket Example

37

<script data-model="socket">! var ChatModel = function() {! …! this.sendMsg = function() {! this.send(this.user + ":" + this.message);! this.message = "";! };! };! </script>!! <script data-type="ChatModel" data-instance="chat”! data-url=“websocket/chat”>! </script>!

Page 38: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.38

Server-side JavaScript on the JVM

Page 39: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Project Avatar

39

Server-side JavaScript on the JVM

▪ Leverage the JVM ▪ Multi-threading optimizations

▪ Share state across threads, JVMs ▪ Built-in load balancing across threads

▪ Leverage Java EE services ▪ Deploy on existing Java EE infrastructure

▪ Leverage AppServer features (clustering, lifecycle management)

Page 40: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Status

40

▪ Launched JavaOne 2013 ▪ GlassFish 4.0 Open Source Edition ▪ Open Source

▪ 2014 ▪ Add WebLogic runtime

Page 41: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Next steps

41

1) Download https://avatar.java.net/

2) Try it out !3) Give us feedback https://avatar.java.net/mailing.html

Page 42: Project Avatar: Server Side JavaScript on the JVM GeeCon ...€¦ · Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1242

slides