SlideShare a Scribd company logo
1 of 32
Download to read offline
David 
Delabassee 
(@delabassee) 
Oracle 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
| 
Avatar 
2.0 
J-­‐Fall 
2014 
1
Safe 
Harbor 
Statement 
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. 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
2
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
3 
Java 
EE 
Java 
Platform 
Java 
on 
the 
Server 
Side 
Agenda
JavaScript 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
4 
Java 
EE 
Java 
Platform 
Java 
on 
the 
Server 
Side 
Agenda
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
Node.js 
• Server-­‐side 
JavaScript 
based 
on 
Chrome 
v8 
engine 
• Created 
in 
2009, 
Open 
Source 
• Designed 
for 
scalable 
Internet 
applications 
• Melting 
pot 
community 
– Java, 
.NET, 
Browser, 
PHP, 
etc, 
experience 
• Node 
Packaged 
Modules 
– Very 
active, 
with 
+98,000 
modules 
(YMMV) 
5 
Server 
Side 
JavaScript
Node.js 
Programming 
Model 
• Multi-­‐threading 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
is 
hard 
– Thousands 
of 
concurrent 
connections 
– Deal 
with 
deadlocks 
and 
race 
conditions 
• Blocking 
on 
I/O 
is 
bad 
• Event 
Loop 
– Reactive 
Model 
– Non-­‐blocking 
I/O 
calls 
• Application 
code 
executes 
in 
a 
single 
thread 
6 
Event 
Clients Loop 
Non-­‐blocking 
Worker
Node.js 
Programming 
Model 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
7 
var http = require("http");! 
! 
http.createServer( … ).listen(80);
Node.js 
Programming 
Model 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
8 
var http = require("http");! 
! 
http.createServer(function(request, response) {! 
! response.writeHead(200, {"Content-type": "text/plain"});! 
! response.write("Hello World";)! 
! response.end();! 
}).listen(80);
6 
4,5 
3 
1,5 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
Nashorn 
! 
• Bundled 
with 
Java 
7 
and 
8 
• ECMAScript 
5.1 
compatibility 
• Performance 
(vs 
Rhino) 
• Java 
Interoperability 
9 
0 
crypto earley-­‐boyer mandreel pdas regexp splay 
rhino 
nashorn 
jdk8 
nashorn 
jdk9 
JavaScript 
Engine
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
Nashorn 
Quick 
Demo 
10
Scaling 
Server-­‐Side 
JavaScript 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
11
What 
If 
I’m 
in 
a 
Java 
Shop? 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
• Java 
Developer 
Investments 
– In-­‐house 
Java-­‐based 
frameworks 
– 3rd 
party 
commercial 
and/or 
open 
source 
libraries 
– Lots 
of 
experience 
with 
Java 
development 
• Investment 
in 
Java 
infrastructure 
– Java 
EE 
application 
servers 
– JMX-­‐based 
monitoring 
and 
management 
– Established 
data 
center 
processes 
and 
best 
practices 
– “We 
are 
a 
Java 
company”, 
or 
“We 
already 
do 
Java 
and 
.NET” 
12
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
Project 
Avatar 
13 
Bridging 
the 
gap 
Avatar 
Node 
on 
the 
JVM 
! 
Thousands 
of 
Node 
libraries 
! 
Thousands 
of 
Java 
libraries 
Java 
EE 
Interoperability 
! 
Leverage 
Existing 
Infrastructure 
! 
Build 
Enterprise 
Applications 
in 
JavaScript 
!
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
Avatar 
2.0 
• 95% 
Node 
compatibility 
provided 
by 
Avatar.js 
• Uses 
same 
C 
portability 
libraries 
as 
Node.js 
– libuv, 
http-­‐parser 
• No 
Chrome 
v8 
native 
APIs! 
• Run 
popular 
packages 
– Express, 
async, 
commander, 
etc. 
14
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
Avatar 
2.0 
• Enterprise 
Features 
– Advanced 
multithreading 
– State 
sharing 
– Avatar 
Persistence 
– Java 
EE 
Interoperability 
(EJB, 
JMS) 
15
Avatar 
Process 
Application JavaScript Modules & Java Jars 
Bundled Third-Party JavaScript Modules 
Avatar API Modules 
WLS T3 thin client 
EclipseLink, NoSQL 
MBeans 
Avatar 
Flight Recorder Probes 
Application 
JavaScript 
& 
Java 
JavaScript 
code 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
16 
Avatar 
2.0 
Architecture 
REST/WS/SSE 
JVM 
Core Node Modules 
Nashorn & JRE 8 
Mission 
Control 
Mgmt Plugin Admin Agent 
EJB/JMS WebLogic 
Data Database 
libuv + JNI bindings 
Java 
code 
Platform 
specific 
native 
code 
Optional 
Processes 
Coherence State Coherence
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
17 
Nashorn 
-­‐ 
Using 
Java 
8 
within 
a 
Node 
app 
var http = require("http");! 
var list = new java.util.ArrayList();! 
! 
list.add("Blue"); list.add(“Green"); list.add("Yellow");! 
list.add("Red"); list.add("Dark Red"); list.add("Light Red”);! 
! 
http.createServer(function(request, response) {! 
response.writeHead(200, {"Content-Type": "application/json"});! ! 
var count = list.parallelStream()! 
.filter(function(t) { return t.match('Red') } )! 
.count();! ! 
response.end(“{'reds': count}”);! 
}).listen(8080);
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
Avatar 
Multithreading 
• Multiple 
instances 
of 
an 
application 
in 
single 
JVM 
process 
– Each 
instance 
has 
its 
own 
event 
loop 
thread 
and 
JavaScript 
context 
– Shared 
sockets 
– 
every 
instance 
listens 
on 
the 
same 
port 
– Optional 
coordination 
via 
JavaScript 
state 
sharing 
APIs 
– Messaging 
API 
– Map 
API 
• Can 
dynamically 
create 
background 
threads 
as 
well 
18 
Taking 
advantage 
of 
the 
multithreaded 
JVM
Avatar 
Application 
Scaling 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
19 
A 
picture 
is 
worth 
a 
thousand 
threads
Creating 
New 
Event 
Threads 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
20 
!var threads = require('avatar/threads');! 
var createBallThread = function(ballInfo) {! 
! var deferred = when.defer();! 
! var eventThread = threads.newEventThread("BouncingBallThread", ! 
! ! __dirname + "/ball.js", [! 
! ! ! "color=" + ballInfo.color,! 
! ! ! "gravity=" + ballInfo.gravity,! 
! ! ! "rowid=" + ballInfo.id_! 
!! ! ]);! 
! eventThread.start(function (event, error) {! 
! ! switch(event) {! 
! ! ! case "started":! 
! ! ! ! console.log("Thread ", eventThread.thread.index(), "Started");! 
! ! ! ! ballInfo.id = eventThread.thread.index();! 
…
Avatar 
Shared 
State 
Framework 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
• Message 
Bus 
– Publish 
/ 
subscribe 
message 
passing 
• Shared 
State 
– Simple 
map 
API 
– Application-­‐scoped 
instance 
– Session-­‐scoped 
instance 
• Named 
• Leased, 
with 
configurable 
timeout 
• Avatar 
provides 
required 
serialization, 
concurrency 
control, 
and 
caching 
21 
Lightweight 
inter-­‐thread 
communication
Message 
Bus 
(Subscribe) 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
22 
bus.on("kill", function (id) {! 
if (_interval && _id && (_id.toString() === id.toString())) {! 
clearInterval(_interval);! 
process.exit();! 
}! 
});! 
! 
bus.subscribe("argsUpdate", function (data) {! 
if (data.id === app.threadIndex) {! 
gravity = data.gravity;! 
}! 
});
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
23 
Message 
Bus 
(Publish) 
_interval = setInterval(function () {! 
var msg = {! 
id: _id, ! 
color: app.args.color,! 
heartbeat: heartbeat++, ! 
…! 
};! ! 
msg.message = "Thread " + app.threadIndex + " | Heartbeat: " +! 
heartbeat + " | Gravity: " + gravity;! ! 
bus.publish("messages", msg);! ! 
}, 2000);
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
• Supports 
Relational 
& 
NoSQL 
databases 
• Similar 
to 
Sequelize, 
JugglingDB, 
etc 
• Leverages 
EclipseLink 
JPA 
Provider 
• Leverages 
mature, 
feature 
rich 
Java 
ecosystem 
– Tooling 
to 
generate 
JavaScript 
model 
for 
existing 
database 
schema 
– 2nd 
level 
JPA 
cache 
(TopLink 
Grid) 
– Oracle 
RAC 
connection 
pooling, 
etc. 
24 
Avatar 
Persistence 
Framework 
JavaScript 
API
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
25 
Avatar 
Persistence 
(Model) 
var avatar = require("avatar");! 
var model = require("avatar/model");! ! 
var store = model.newStore(config.db.name, {! 
database: config.db.database,! 
username: config.db.username,! 
properties: { "eclipselink.logging.level": “INFO” }! 
});! ! 
var BallModel = model.newModel("Ball", {! 
"color": "string",! 
"gravity": "number"! 
});! ! 
store.bind(BallModel);
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
26 
Avatar 
Persistence 
(Model) 
var avatar = require("avatar");! 
var model = require("avatar/model");! ! 
var store = model.newStore(config.db.name, {! 
database: config.db.database,! 
username: config.db.username,! 
properties: { "eclipselink.logging.level": “INFO” }! 
});! ! 
var BallModel = model.newModel("Ball", {! 
"color": "string",! 
"gravity": "number"! 
});! ! 
store.bind(BallModel);
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
27 
Avatar 
Persistence 
return {! 
! getThreads: function() {! 
! ! return BallModel.getAll();! 
! },! 
! ! 
! createThread: function(thread) {! 
! ! return BallModel.create(aBall);! 
! },! 
! ! 
! deleteThread: function(id) {! 
! ! return BallModel.delete(id);! 
! },! 
! ! 
! updateThread: function(data) {! 
! ! var deferred = when.defer();! 
! ! BallModel.get(data.id_).then(function(row) {! 
! ! row.gravity = parseInt(data.gravity);! 
! ! BallModel.put(row).then(function(updatedRow) {
model.js 
heartbeat gravity heartbeat heartbeat Message 
Bus 
express.js ws.js avatar.js 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
28 
Browser main.js ball.js ball.js ball.js 
. 
. 
. 
ball.js 
newEventThread(‘ball.js’) 
REST 
WebSocket 
Avatar 
Process 
Database 
Demo
Additional 
Features 
and 
Potential 
• Expand 
Java 
Mission 
Control 
/ 
Flight 
Recorder 
support 
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
• Remote 
EJB 
and 
JMS 
support 
– Using 
WebLogic 
t3 
thin 
client 
• Automatically 
reload 
application 
on 
file 
change 
(development 
feature) 
• Work 
in 
progress 
– Coherence 
(JCache) 
integration 
for 
cross-­‐JVM 
state 
sharing 
– Manage 
using 
WebLogic 
and/or 
Oracle 
Enterprise 
Manager 
29
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
Next 
• Check 
Project 
Avatar 
(aka 
“Avatar 
1.0”) 
- http://avatar.java.net 
• We 
plan 
to 
open 
source 
Avatar 
2.0 
soon 
• We 
need 
your 
feedback! 
! 
• Thank 
You! 
30
Copyright 
© 
2014, 
Oracle 
and/or 
its 
affiliates. 
All 
rights 
reserved. 
31
Avatar 2.0

More Related Content

What's hot

Java EE 8: On the Horizon
Java EE 8:  On the HorizonJava EE 8:  On the Horizon
Java EE 8: On the HorizonJosh Juneau
 
Reactive Java EE - Let Me Count the Ways!
Reactive Java EE - Let Me Count the Ways!Reactive Java EE - Let Me Count the Ways!
Reactive Java EE - Let Me Count the Ways!Reza Rahman
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 UpdateRyan Cuprak
 
Java: Create The Future Keynote
Java: Create The Future KeynoteJava: Create The Future Keynote
Java: Create The Future KeynoteSimon Ritter
 
3 rad extensibility-srilakshmi_s_rajesh_k
3 rad extensibility-srilakshmi_s_rajesh_k3 rad extensibility-srilakshmi_s_rajesh_k
3 rad extensibility-srilakshmi_s_rajesh_kIBM
 
Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Ryan Cuprak
 
Avoiding Java EE Application Design Traps to Achieve Effective Use of Cloud C...
Avoiding Java EE Application Design Traps to Achieve Effective Use of Cloud C...Avoiding Java EE Application Design Traps to Achieve Effective Use of Cloud C...
Avoiding Java EE Application Design Traps to Achieve Effective Use of Cloud C...Dr. Spock
 
Sling models by Justin Edelson
Sling models by Justin Edelson Sling models by Justin Edelson
Sling models by Justin Edelson AEM HUB
 
Java EE Revisits GoF Design Patterns
Java EE Revisits GoF Design PatternsJava EE Revisits GoF Design Patterns
Java EE Revisits GoF Design PatternsMurat Yener
 
Oracle REST Data Services
Oracle REST Data ServicesOracle REST Data Services
Oracle REST Data ServicesChris Muir
 
Batch Applications for Java Platform 1.0: Java EE 7 and GlassFish
Batch Applications for Java Platform 1.0: Java EE 7 and GlassFishBatch Applications for Java Platform 1.0: Java EE 7 and GlassFish
Batch Applications for Java Platform 1.0: Java EE 7 and GlassFishArun Gupta
 
Oracle ADF Architecture TV - Design - Task Flow Navigation Options
Oracle ADF Architecture TV - Design - Task Flow Navigation OptionsOracle ADF Architecture TV - Design - Task Flow Navigation Options
Oracle ADF Architecture TV - Design - Task Flow Navigation OptionsChris Muir
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules uploadRyan Cuprak
 
What's Coming in Java EE 8
What's Coming in Java EE 8What's Coming in Java EE 8
What's Coming in Java EE 8PT.JUG
 
Sling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak KhetawatSling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak KhetawatAEM HUB
 
Get Rid Of OutOfMemoryError messages
Get Rid Of OutOfMemoryError messagesGet Rid Of OutOfMemoryError messages
Get Rid Of OutOfMemoryError messagesPoonam Bajaj Parhar
 
Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Reza Rahman
 

What's hot (19)

Java EE 8: On the Horizon
Java EE 8:  On the HorizonJava EE 8:  On the Horizon
Java EE 8: On the Horizon
 
Reactive Java EE - Let Me Count the Ways!
Reactive Java EE - Let Me Count the Ways!Reactive Java EE - Let Me Count the Ways!
Reactive Java EE - Let Me Count the Ways!
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 Update
 
Java: Create The Future Keynote
Java: Create The Future KeynoteJava: Create The Future Keynote
Java: Create The Future Keynote
 
Web servicesoverview
Web servicesoverviewWeb servicesoverview
Web servicesoverview
 
3 rad extensibility-srilakshmi_s_rajesh_k
3 rad extensibility-srilakshmi_s_rajesh_k3 rad extensibility-srilakshmi_s_rajesh_k
3 rad extensibility-srilakshmi_s_rajesh_k
 
Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]
 
Avoiding Java EE Application Design Traps to Achieve Effective Use of Cloud C...
Avoiding Java EE Application Design Traps to Achieve Effective Use of Cloud C...Avoiding Java EE Application Design Traps to Achieve Effective Use of Cloud C...
Avoiding Java EE Application Design Traps to Achieve Effective Use of Cloud C...
 
Sling models by Justin Edelson
Sling models by Justin Edelson Sling models by Justin Edelson
Sling models by Justin Edelson
 
Java EE Revisits GoF Design Patterns
Java EE Revisits GoF Design PatternsJava EE Revisits GoF Design Patterns
Java EE Revisits GoF Design Patterns
 
Oracle REST Data Services
Oracle REST Data ServicesOracle REST Data Services
Oracle REST Data Services
 
Web servicesoverview
Web servicesoverviewWeb servicesoverview
Web servicesoverview
 
Batch Applications for Java Platform 1.0: Java EE 7 and GlassFish
Batch Applications for Java Platform 1.0: Java EE 7 and GlassFishBatch Applications for Java Platform 1.0: Java EE 7 and GlassFish
Batch Applications for Java Platform 1.0: Java EE 7 and GlassFish
 
Oracle ADF Architecture TV - Design - Task Flow Navigation Options
Oracle ADF Architecture TV - Design - Task Flow Navigation OptionsOracle ADF Architecture TV - Design - Task Flow Navigation Options
Oracle ADF Architecture TV - Design - Task Flow Navigation Options
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
 
What's Coming in Java EE 8
What's Coming in Java EE 8What's Coming in Java EE 8
What's Coming in Java EE 8
 
Sling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak KhetawatSling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak Khetawat
 
Get Rid Of OutOfMemoryError messages
Get Rid Of OutOfMemoryError messagesGet Rid Of OutOfMemoryError messages
Get Rid Of OutOfMemoryError messages
 
Have You Seen Java EE Lately?
Have You Seen Java EE Lately?Have You Seen Java EE Lately?
Have You Seen Java EE Lately?
 

Similar to Avatar 2.0

Project Avatar (Lyon JUG & Alpes JUG - March 2014)
Project Avatar (Lyon JUG & Alpes JUG  - March 2014)Project Avatar (Lyon JUG & Alpes JUG  - March 2014)
Project Avatar (Lyon JUG & Alpes JUG - March 2014)David Delabassee
 
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur! Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur! David Delabassee
 
Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...
Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...
Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...Marco Antonio Maciel
 
What's new in Java 8
What's new in Java 8What's new in Java 8
What's new in Java 8jclingan
 
Java EE 7 (Lyon JUG & Alpes JUG - March 2014)
Java EE 7 (Lyon JUG & Alpes JUG  - March 2014)Java EE 7 (Lyon JUG & Alpes JUG  - March 2014)
Java EE 7 (Lyon JUG & Alpes JUG - March 2014)David Delabassee
 
Pushing JavaEE outside of the enterprise: Home Automation & IoT - David Delab...
Pushing JavaEE outside of the enterprise: Home Automation & IoT - David Delab...Pushing JavaEE outside of the enterprise: Home Automation & IoT - David Delab...
Pushing JavaEE outside of the enterprise: Home Automation & IoT - David Delab...Codemotion Tel Aviv
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Ran Mizrahi
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Ran Mizrahi
 
Building Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaBuilding Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaWO Community
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)slire
 
Introdução ao Oracle NoSQL
Introdução ao Oracle NoSQLIntrodução ao Oracle NoSQL
Introdução ao Oracle NoSQLBruno Borges
 
Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014Arun Gupta
 
Java EE 7 for WebLogic 12c Developers
Java EE 7 for WebLogic 12c DevelopersJava EE 7 for WebLogic 12c Developers
Java EE 7 for WebLogic 12c DevelopersBruno Borges
 
Servidores de Aplicação: por que ainda precisamos deles?
Servidores de Aplicação: por que ainda precisamos deles?Servidores de Aplicação: por que ainda precisamos deles?
Servidores de Aplicação: por que ainda precisamos deles?Bruno Borges
 
Cross Site Scripting (XSS) Defense with Java
Cross Site Scripting (XSS) Defense with JavaCross Site Scripting (XSS) Defense with Java
Cross Site Scripting (XSS) Defense with JavaJim Manico
 

Similar to Avatar 2.0 (20)

Project Avatar (Lyon JUG & Alpes JUG - March 2014)
Project Avatar (Lyon JUG & Alpes JUG  - March 2014)Project Avatar (Lyon JUG & Alpes JUG  - March 2014)
Project Avatar (Lyon JUG & Alpes JUG - March 2014)
 
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur! Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
Java EE 7 et ensuite pourquoi pas JavaScript sur le serveur!
 
Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...
Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...
Tweet4Beer (atualizada): Torneira de Chopp Controlada por Java, JavaFX, IoT ...
 
What's new in Java 8
What's new in Java 8What's new in Java 8
What's new in Java 8
 
Java EE 7 (Lyon JUG & Alpes JUG - March 2014)
Java EE 7 (Lyon JUG & Alpes JUG  - March 2014)Java EE 7 (Lyon JUG & Alpes JUG  - March 2014)
Java EE 7 (Lyon JUG & Alpes JUG - March 2014)
 
Web Application Defences
Web Application DefencesWeb Application Defences
Web Application Defences
 
Pushing JavaEE outside of the enterprise: Home Automation & IoT - David Delab...
Pushing JavaEE outside of the enterprise: Home Automation & IoT - David Delab...Pushing JavaEE outside of the enterprise: Home Automation & IoT - David Delab...
Pushing JavaEE outside of the enterprise: Home Automation & IoT - David Delab...
 
01 java intro
01 java intro01 java intro
01 java intro
 
40020
4002040020
40020
 
Noonan_resume
Noonan_resumeNoonan_resume
Noonan_resume
 
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (27/8/2014)
 
Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)Intro to node.js - Ran Mizrahi (28/8/14)
Intro to node.js - Ran Mizrahi (28/8/14)
 
Building Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaBuilding Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with Scala
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Introdução ao Oracle NoSQL
Introdução ao Oracle NoSQLIntrodução ao Oracle NoSQL
Introdução ao Oracle NoSQL
 
Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014
 
AJppt.pptx
AJppt.pptxAJppt.pptx
AJppt.pptx
 
Java EE 7 for WebLogic 12c Developers
Java EE 7 for WebLogic 12c DevelopersJava EE 7 for WebLogic 12c Developers
Java EE 7 for WebLogic 12c Developers
 
Servidores de Aplicação: por que ainda precisamos deles?
Servidores de Aplicação: por que ainda precisamos deles?Servidores de Aplicação: por que ainda precisamos deles?
Servidores de Aplicação: por que ainda precisamos deles?
 
Cross Site Scripting (XSS) Defense with Java
Cross Site Scripting (XSS) Defense with JavaCross Site Scripting (XSS) Defense with Java
Cross Site Scripting (XSS) Defense with Java
 

More from David Delabassee

JVMs in Containers - Best Practices
JVMs in Containers - Best PracticesJVMs in Containers - Best Practices
JVMs in Containers - Best PracticesDavid Delabassee
 
Serverless Java Challenges & Triumphs
Serverless Java Challenges & TriumphsServerless Java Challenges & Triumphs
Serverless Java Challenges & TriumphsDavid Delabassee
 
Serverless Java - Challenges and Triumphs
Serverless Java - Challenges and TriumphsServerless Java - Challenges and Triumphs
Serverless Java - Challenges and TriumphsDavid Delabassee
 
Randstad Docker meetup - Serverless
Randstad Docker meetup - ServerlessRandstad Docker meetup - Serverless
Randstad Docker meetup - ServerlessDavid Delabassee
 
Java Serverless in Action - Voxxed Banff
Java Serverless in Action - Voxxed BanffJava Serverless in Action - Voxxed Banff
Java Serverless in Action - Voxxed BanffDavid Delabassee
 
Java EE 8 - February 2017 update
Java EE 8 - February 2017 updateJava EE 8 - February 2017 update
Java EE 8 - February 2017 updateDavid Delabassee
 
Java EE Next - BeJUG JavaOne Afterglow 2016
Java EE Next - BeJUG JavaOne Afterglow 2016Java EE Next - BeJUG JavaOne Afterglow 2016
Java EE Next - BeJUG JavaOne Afterglow 2016David Delabassee
 
Java EE 8 - Work in progress
Java EE 8 - Work in progressJava EE 8 - Work in progress
Java EE 8 - Work in progressDavid Delabassee
 
HTTP/2 comes to Java (Dec. 2015 version)
HTTP/2 comes to Java (Dec. 2015 version)HTTP/2 comes to Java (Dec. 2015 version)
HTTP/2 comes to Java (Dec. 2015 version)David Delabassee
 
EJB and CDI - Alignment and Strategy
EJB and CDI - Alignment and StrategyEJB and CDI - Alignment and Strategy
EJB and CDI - Alignment and StrategyDavid Delabassee
 
Java EE 8 - What’s new on the Web front
Java EE 8 - What’s new on the Web frontJava EE 8 - What’s new on the Web front
Java EE 8 - What’s new on the Web frontDavid Delabassee
 
What's coming in Java EE 8
What's coming in Java EE 8What's coming in Java EE 8
What's coming in Java EE 8David Delabassee
 

More from David Delabassee (20)

JVMs in Containers - Best Practices
JVMs in Containers - Best PracticesJVMs in Containers - Best Practices
JVMs in Containers - Best Practices
 
JVMs in Containers
JVMs in ContainersJVMs in Containers
JVMs in Containers
 
Serverless Java Challenges & Triumphs
Serverless Java Challenges & TriumphsServerless Java Challenges & Triumphs
Serverless Java Challenges & Triumphs
 
Serverless Java - Challenges and Triumphs
Serverless Java - Challenges and TriumphsServerless Java - Challenges and Triumphs
Serverless Java - Challenges and Triumphs
 
Randstad Docker meetup - Serverless
Randstad Docker meetup - ServerlessRandstad Docker meetup - Serverless
Randstad Docker meetup - Serverless
 
Java Serverless in Action - Voxxed Banff
Java Serverless in Action - Voxxed BanffJava Serverless in Action - Voxxed Banff
Java Serverless in Action - Voxxed Banff
 
Serverless Kotlin
Serverless KotlinServerless Kotlin
Serverless Kotlin
 
REST in an Async World
REST in an Async WorldREST in an Async World
REST in an Async World
 
JAX-RS 2.1 Reloaded
JAX-RS 2.1 ReloadedJAX-RS 2.1 Reloaded
JAX-RS 2.1 Reloaded
 
Java EE 8 - February 2017 update
Java EE 8 - February 2017 updateJava EE 8 - February 2017 update
Java EE 8 - February 2017 update
 
Java EE Next
Java EE NextJava EE Next
Java EE Next
 
Java EE Next - BeJUG JavaOne Afterglow 2016
Java EE Next - BeJUG JavaOne Afterglow 2016Java EE Next - BeJUG JavaOne Afterglow 2016
Java EE Next - BeJUG JavaOne Afterglow 2016
 
HTTP/2 comes to Java
HTTP/2 comes to JavaHTTP/2 comes to Java
HTTP/2 comes to Java
 
Java EE 8 - Work in progress
Java EE 8 - Work in progressJava EE 8 - Work in progress
Java EE 8 - Work in progress
 
HTTP/2 comes to Java (Dec. 2015 version)
HTTP/2 comes to Java (Dec. 2015 version)HTTP/2 comes to Java (Dec. 2015 version)
HTTP/2 comes to Java (Dec. 2015 version)
 
EJB and CDI - Alignment and Strategy
EJB and CDI - Alignment and StrategyEJB and CDI - Alignment and Strategy
EJB and CDI - Alignment and Strategy
 
HTTP/2 Comes to Java
HTTP/2 Comes to JavaHTTP/2 Comes to Java
HTTP/2 Comes to Java
 
Java EE 8 - What’s new on the Web front
Java EE 8 - What’s new on the Web frontJava EE 8 - What’s new on the Web front
Java EE 8 - What’s new on the Web front
 
HTTP/2 Comes to Java
HTTP/2 Comes to JavaHTTP/2 Comes to Java
HTTP/2 Comes to Java
 
What's coming in Java EE 8
What's coming in Java EE 8What's coming in Java EE 8
What's coming in Java EE 8
 

Recently uploaded

Making an RFC in Today's IETF, presented by Geoff Huston at IETF 119
Making an RFC in Today's IETF, presented by Geoff Huston at IETF 119Making an RFC in Today's IETF, presented by Geoff Huston at IETF 119
Making an RFC in Today's IETF, presented by Geoff Huston at IETF 119APNIC
 
Tari Eason Warriors Come Out To Play T Shirts
Tari Eason Warriors Come Out To Play T ShirtsTari Eason Warriors Come Out To Play T Shirts
Tari Eason Warriors Come Out To Play T Shirtsrahman018755
 
Power of Social Media for E-commerce.pdf
Power of Social Media for E-commerce.pdfPower of Social Media for E-commerce.pdf
Power of Social Media for E-commerce.pdfrajats19920
 
办理澳洲USYD文凭证书学历认证【Q微/1954292140】办理悉尼大学毕业证书真实成绩单GPA修改/办理澳洲大学文凭证书Offer录取通知书/在读证明...
办理澳洲USYD文凭证书学历认证【Q微/1954292140】办理悉尼大学毕业证书真实成绩单GPA修改/办理澳洲大学文凭证书Offer录取通知书/在读证明...办理澳洲USYD文凭证书学历认证【Q微/1954292140】办理悉尼大学毕业证书真实成绩单GPA修改/办理澳洲大学文凭证书Offer录取通知书/在读证明...
办理澳洲USYD文凭证书学历认证【Q微/1954292140】办理悉尼大学毕业证书真实成绩单GPA修改/办理澳洲大学文凭证书Offer录取通知书/在读证明...vmzoxnx5
 
draft-harrison-sidrops-manifest-number-01, presented at IETF 119
draft-harrison-sidrops-manifest-number-01, presented at IETF 119draft-harrison-sidrops-manifest-number-01, presented at IETF 119
draft-harrison-sidrops-manifest-number-01, presented at IETF 119APNIC
 
Basic Security.pptx is a awsome PPT on your mobiel
Basic Security.pptx is a awsome PPT on your mobielBasic Security.pptx is a awsome PPT on your mobiel
Basic Security.pptx is a awsome PPT on your mobielpratamakiki860
 
Summary ID-IGF 2016 National Dialogue - English (tata kelola internet / int...
Summary  ID-IGF 2016 National Dialogue  - English (tata kelola internet / int...Summary  ID-IGF 2016 National Dialogue  - English (tata kelola internet / int...
Summary ID-IGF 2016 National Dialogue - English (tata kelola internet / int...ICT Watch - Indonesia
 
IPv6 Operational Issues (with DNS), presented by Geoff Huston at IETF 119
IPv6 Operational Issues (with DNS), presented by Geoff Huston at IETF 119IPv6 Operational Issues (with DNS), presented by Geoff Huston at IETF 119
IPv6 Operational Issues (with DNS), presented by Geoff Huston at IETF 119APNIC
 
IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119APNIC
 
Is DNS ready for IPv6, presented by Geoff Huston at IETF 119
Is DNS ready for IPv6, presented by Geoff Huston at IETF 119Is DNS ready for IPv6, presented by Geoff Huston at IETF 119
Is DNS ready for IPv6, presented by Geoff Huston at IETF 119APNIC
 
Summary IGF 2013 Bali - English (tata kelola internet / internet governance)
Summary  IGF 2013 Bali - English (tata kelola internet / internet governance)Summary  IGF 2013 Bali - English (tata kelola internet / internet governance)
Summary IGF 2013 Bali - English (tata kelola internet / internet governance)ICT Watch - Indonesia
 

Recently uploaded (11)

Making an RFC in Today's IETF, presented by Geoff Huston at IETF 119
Making an RFC in Today's IETF, presented by Geoff Huston at IETF 119Making an RFC in Today's IETF, presented by Geoff Huston at IETF 119
Making an RFC in Today's IETF, presented by Geoff Huston at IETF 119
 
Tari Eason Warriors Come Out To Play T Shirts
Tari Eason Warriors Come Out To Play T ShirtsTari Eason Warriors Come Out To Play T Shirts
Tari Eason Warriors Come Out To Play T Shirts
 
Power of Social Media for E-commerce.pdf
Power of Social Media for E-commerce.pdfPower of Social Media for E-commerce.pdf
Power of Social Media for E-commerce.pdf
 
办理澳洲USYD文凭证书学历认证【Q微/1954292140】办理悉尼大学毕业证书真实成绩单GPA修改/办理澳洲大学文凭证书Offer录取通知书/在读证明...
办理澳洲USYD文凭证书学历认证【Q微/1954292140】办理悉尼大学毕业证书真实成绩单GPA修改/办理澳洲大学文凭证书Offer录取通知书/在读证明...办理澳洲USYD文凭证书学历认证【Q微/1954292140】办理悉尼大学毕业证书真实成绩单GPA修改/办理澳洲大学文凭证书Offer录取通知书/在读证明...
办理澳洲USYD文凭证书学历认证【Q微/1954292140】办理悉尼大学毕业证书真实成绩单GPA修改/办理澳洲大学文凭证书Offer录取通知书/在读证明...
 
draft-harrison-sidrops-manifest-number-01, presented at IETF 119
draft-harrison-sidrops-manifest-number-01, presented at IETF 119draft-harrison-sidrops-manifest-number-01, presented at IETF 119
draft-harrison-sidrops-manifest-number-01, presented at IETF 119
 
Basic Security.pptx is a awsome PPT on your mobiel
Basic Security.pptx is a awsome PPT on your mobielBasic Security.pptx is a awsome PPT on your mobiel
Basic Security.pptx is a awsome PPT on your mobiel
 
Summary ID-IGF 2016 National Dialogue - English (tata kelola internet / int...
Summary  ID-IGF 2016 National Dialogue  - English (tata kelola internet / int...Summary  ID-IGF 2016 National Dialogue  - English (tata kelola internet / int...
Summary ID-IGF 2016 National Dialogue - English (tata kelola internet / int...
 
IPv6 Operational Issues (with DNS), presented by Geoff Huston at IETF 119
IPv6 Operational Issues (with DNS), presented by Geoff Huston at IETF 119IPv6 Operational Issues (with DNS), presented by Geoff Huston at IETF 119
IPv6 Operational Issues (with DNS), presented by Geoff Huston at IETF 119
 
IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119
 
Is DNS ready for IPv6, presented by Geoff Huston at IETF 119
Is DNS ready for IPv6, presented by Geoff Huston at IETF 119Is DNS ready for IPv6, presented by Geoff Huston at IETF 119
Is DNS ready for IPv6, presented by Geoff Huston at IETF 119
 
Summary IGF 2013 Bali - English (tata kelola internet / internet governance)
Summary  IGF 2013 Bali - English (tata kelola internet / internet governance)Summary  IGF 2013 Bali - English (tata kelola internet / internet governance)
Summary IGF 2013 Bali - English (tata kelola internet / internet governance)
 

Avatar 2.0

  • 1. David Delabassee (@delabassee) Oracle Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Avatar 2.0 J-­‐Fall 2014 1
  • 2. Safe Harbor Statement 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. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 2
  • 3. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 3 Java EE Java Platform Java on the Server Side Agenda
  • 4. JavaScript Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 4 Java EE Java Platform Java on the Server Side Agenda
  • 5. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Node.js • Server-­‐side JavaScript based on Chrome v8 engine • Created in 2009, Open Source • Designed for scalable Internet applications • Melting pot community – Java, .NET, Browser, PHP, etc, experience • Node Packaged Modules – Very active, with +98,000 modules (YMMV) 5 Server Side JavaScript
  • 6. Node.js Programming Model • Multi-­‐threading Copyright © 2014, Oracle and/or its affiliates. All rights reserved. is hard – Thousands of concurrent connections – Deal with deadlocks and race conditions • Blocking on I/O is bad • Event Loop – Reactive Model – Non-­‐blocking I/O calls • Application code executes in a single thread 6 Event Clients Loop Non-­‐blocking Worker
  • 7. Node.js Programming Model Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 7 var http = require("http");! ! http.createServer( … ).listen(80);
  • 8. Node.js Programming Model Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 8 var http = require("http");! ! http.createServer(function(request, response) {! ! response.writeHead(200, {"Content-type": "text/plain"});! ! response.write("Hello World";)! ! response.end();! }).listen(80);
  • 9. 6 4,5 3 1,5 Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Nashorn ! • Bundled with Java 7 and 8 • ECMAScript 5.1 compatibility • Performance (vs Rhino) • Java Interoperability 9 0 crypto earley-­‐boyer mandreel pdas regexp splay rhino nashorn jdk8 nashorn jdk9 JavaScript Engine
  • 10. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Nashorn Quick Demo 10
  • 11. Scaling Server-­‐Side JavaScript Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 11
  • 12. What If I’m in a Java Shop? Copyright © 2014, Oracle and/or its affiliates. All rights reserved. • Java Developer Investments – In-­‐house Java-­‐based frameworks – 3rd party commercial and/or open source libraries – Lots of experience with Java development • Investment in Java infrastructure – Java EE application servers – JMX-­‐based monitoring and management – Established data center processes and best practices – “We are a Java company”, or “We already do Java and .NET” 12
  • 13. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Project Avatar 13 Bridging the gap Avatar Node on the JVM ! Thousands of Node libraries ! Thousands of Java libraries Java EE Interoperability ! Leverage Existing Infrastructure ! Build Enterprise Applications in JavaScript !
  • 14. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Avatar 2.0 • 95% Node compatibility provided by Avatar.js • Uses same C portability libraries as Node.js – libuv, http-­‐parser • No Chrome v8 native APIs! • Run popular packages – Express, async, commander, etc. 14
  • 15. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Avatar 2.0 • Enterprise Features – Advanced multithreading – State sharing – Avatar Persistence – Java EE Interoperability (EJB, JMS) 15
  • 16. Avatar Process Application JavaScript Modules & Java Jars Bundled Third-Party JavaScript Modules Avatar API Modules WLS T3 thin client EclipseLink, NoSQL MBeans Avatar Flight Recorder Probes Application JavaScript & Java JavaScript code Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 16 Avatar 2.0 Architecture REST/WS/SSE JVM Core Node Modules Nashorn & JRE 8 Mission Control Mgmt Plugin Admin Agent EJB/JMS WebLogic Data Database libuv + JNI bindings Java code Platform specific native code Optional Processes Coherence State Coherence
  • 17. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 17 Nashorn -­‐ Using Java 8 within a Node app var http = require("http");! var list = new java.util.ArrayList();! ! list.add("Blue"); list.add(“Green"); list.add("Yellow");! list.add("Red"); list.add("Dark Red"); list.add("Light Red”);! ! http.createServer(function(request, response) {! response.writeHead(200, {"Content-Type": "application/json"});! ! var count = list.parallelStream()! .filter(function(t) { return t.match('Red') } )! .count();! ! response.end(“{'reds': count}”);! }).listen(8080);
  • 18. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Avatar Multithreading • Multiple instances of an application in single JVM process – Each instance has its own event loop thread and JavaScript context – Shared sockets – every instance listens on the same port – Optional coordination via JavaScript state sharing APIs – Messaging API – Map API • Can dynamically create background threads as well 18 Taking advantage of the multithreaded JVM
  • 19. Avatar Application Scaling Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 19 A picture is worth a thousand threads
  • 20. Creating New Event Threads Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 20 !var threads = require('avatar/threads');! var createBallThread = function(ballInfo) {! ! var deferred = when.defer();! ! var eventThread = threads.newEventThread("BouncingBallThread", ! ! ! __dirname + "/ball.js", [! ! ! ! "color=" + ballInfo.color,! ! ! ! "gravity=" + ballInfo.gravity,! ! ! ! "rowid=" + ballInfo.id_! !! ! ]);! ! eventThread.start(function (event, error) {! ! ! switch(event) {! ! ! ! case "started":! ! ! ! ! console.log("Thread ", eventThread.thread.index(), "Started");! ! ! ! ! ballInfo.id = eventThread.thread.index();! …
  • 21. Avatar Shared State Framework Copyright © 2014, Oracle and/or its affiliates. All rights reserved. • Message Bus – Publish / subscribe message passing • Shared State – Simple map API – Application-­‐scoped instance – Session-­‐scoped instance • Named • Leased, with configurable timeout • Avatar provides required serialization, concurrency control, and caching 21 Lightweight inter-­‐thread communication
  • 22. Message Bus (Subscribe) Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 22 bus.on("kill", function (id) {! if (_interval && _id && (_id.toString() === id.toString())) {! clearInterval(_interval);! process.exit();! }! });! ! bus.subscribe("argsUpdate", function (data) {! if (data.id === app.threadIndex) {! gravity = data.gravity;! }! });
  • 23. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 23 Message Bus (Publish) _interval = setInterval(function () {! var msg = {! id: _id, ! color: app.args.color,! heartbeat: heartbeat++, ! …! };! ! msg.message = "Thread " + app.threadIndex + " | Heartbeat: " +! heartbeat + " | Gravity: " + gravity;! ! bus.publish("messages", msg);! ! }, 2000);
  • 24. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. • Supports Relational & NoSQL databases • Similar to Sequelize, JugglingDB, etc • Leverages EclipseLink JPA Provider • Leverages mature, feature rich Java ecosystem – Tooling to generate JavaScript model for existing database schema – 2nd level JPA cache (TopLink Grid) – Oracle RAC connection pooling, etc. 24 Avatar Persistence Framework JavaScript API
  • 25. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 25 Avatar Persistence (Model) var avatar = require("avatar");! var model = require("avatar/model");! ! var store = model.newStore(config.db.name, {! database: config.db.database,! username: config.db.username,! properties: { "eclipselink.logging.level": “INFO” }! });! ! var BallModel = model.newModel("Ball", {! "color": "string",! "gravity": "number"! });! ! store.bind(BallModel);
  • 26. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 26 Avatar Persistence (Model) var avatar = require("avatar");! var model = require("avatar/model");! ! var store = model.newStore(config.db.name, {! database: config.db.database,! username: config.db.username,! properties: { "eclipselink.logging.level": “INFO” }! });! ! var BallModel = model.newModel("Ball", {! "color": "string",! "gravity": "number"! });! ! store.bind(BallModel);
  • 27. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 27 Avatar Persistence return {! ! getThreads: function() {! ! ! return BallModel.getAll();! ! },! ! ! ! createThread: function(thread) {! ! ! return BallModel.create(aBall);! ! },! ! ! ! deleteThread: function(id) {! ! ! return BallModel.delete(id);! ! },! ! ! ! updateThread: function(data) {! ! ! var deferred = when.defer();! ! ! BallModel.get(data.id_).then(function(row) {! ! ! row.gravity = parseInt(data.gravity);! ! ! BallModel.put(row).then(function(updatedRow) {
  • 28. model.js heartbeat gravity heartbeat heartbeat Message Bus express.js ws.js avatar.js Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 28 Browser main.js ball.js ball.js ball.js . . . ball.js newEventThread(‘ball.js’) REST WebSocket Avatar Process Database Demo
  • 29. Additional Features and Potential • Expand Java Mission Control / Flight Recorder support Copyright © 2014, Oracle and/or its affiliates. All rights reserved. • Remote EJB and JMS support – Using WebLogic t3 thin client • Automatically reload application on file change (development feature) • Work in progress – Coherence (JCache) integration for cross-­‐JVM state sharing – Manage using WebLogic and/or Oracle Enterprise Manager 29
  • 30. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. Next • Check Project Avatar (aka “Avatar 1.0”) - http://avatar.java.net • We plan to open source Avatar 2.0 soon • We need your feedback! ! • Thank You! 30
  • 31. Copyright © 2014, Oracle and/or its affiliates. All rights reserved. 31