Slide 1

Slide 1 text

ENTERPRISE JAVA WRITTEN IN JAVASCRIPT PROJECT AVATAR: MORE THAN JUST NODE.JS ON THE JAVA VIRTUAL MACHINE NIKO KÖBLER HEIKO SPINDLER QUALITECTS GROUP

Slide 2

Slide 2 text

Agenda  The Web as a Plattform  Avatar Basics  Avatar Features  Avatar Demo

Slide 3

Slide 3 text

„JavaScript is the new black“ The Web as a Plattform  The web becomes a plattform  unique standards  JavaScript is used as a general programming language for nearly all devices  JavaScript is fast enough  Differences of browsers are reduced (frameworks, standards)  Best-Practices and KnowHow is available  QA tools and activites emerge

Slide 4

Slide 4 text

Web Applications in Change Static HTML or usage of plug-ins (Flash, Applets, …) Generation of HTML, business logic, validation, authorization, authenication, integration HTTP HTML Legacy web-application Static HTML with some dynamic elements (AJAX, PPR) Generation of HTML, business logic, validation, authorization, authenication, integration HTTP HTML and JSON/XML Legacy web-application with AJAX Dynamic Uis with business logic, validation and integration Services for business logic, authentication, authorization, validation HTTP JSON (XML) Single page web-application Server Client

Slide 5

Slide 5 text

Modern Web Application Architecture JavaEE / JVM Browser Presentation Presentation Connectivity (WebSockets, SSE, Rest) Enterprise Integration and Business Logic

Slide 6

Slide 6 text

Avatar Basics  Plattform for server-side JavaScript on top of the JVM  Based on Nashorn JavaScript engine (JDK 8)  Open-source project on java.net started by Oracle  95% Node.js-API compatibility  code in JavaScript  single threaded event loops  many of the npm-packages work (express, async, etc.)  same prerequisites as Node.js  no Chrome V8 native APIs

Slide 7

Slide 7 text

Avatar.js on the server Image: https://avatar-js.java.net/

Slide 8

Slide 8 text

Avatar Features  Access to Java frameworks, libraries and tools  via JavaScript wrappers  via asynchronuous adapters  Embedded in Security Manager  Consists of a server- and client-component

Slide 9

Slide 9 text

Avatar Architecture Image: https://avatar.java.net

Slide 10

Slide 10 text

Interaction of client and server components Image: https://avatar.java.net

Slide 11

Slide 11 text

Definition of the model var AddMathModel = function() { this.left = 0; this.right = 0; this.reset = function() { this.left = this.right = 0; }; };

Slide 12

Slide 12 text

2-way-binding of model and UI-elements The result is #{add.left} + #{add.right} = #{add.left + add.right} Reset

Slide 13

Slide 13 text

Avatar DataProvider var avatar = require("org/glassfish/avatar"); var itemsFileProvider = new avatar.FileDataProvider( { filename: "rest-sample.txt", key: "key"} ); var itemsJpaProvider = new avatar.JPADataProvider( { persistenceUnit:"rest", createTables:"true", entityType:"Item"} );

Slide 14

Slide 14 text

Avatar JMS var avatar = require("org/glassfish/avatar"); var myJMS = new avatar.JMS( { connectionFactoryName: "jms/myConnFactory", destinationName: "jms/myQueue"} ); myJMS.addListener(function(message) { avatar.log("Got message: " + message); }).then(function() { return myJMS.send("Test message"); });

Slide 15

Slide 15 text

Avatar RestService avatar.registerRestService({url:"data/items/{item}"}, function() { this.onGet = function(request, response) { itemsFileProvider.get( this.item, function(error, itemValue) { if (!itemValue) { itemValue = {} }; response.send(itemValue).done(); } ); }; });

Slide 16

Slide 16 text

Demo Time

Slide 17

Slide 17 text

Timeline (without obligation) Period Milestone JavaOne 2013 Project Avatar Launch GlassFish Runtime Q2/2014 WebLogic Runtime (WLS 12.1.3) Mid 2015 WebLogic 12.1.4 Avatar Commercial Support

Slide 18

Slide 18 text

Conclusion  Lightweight integration in JavaEE and Enterprise context  JMS, JPA, REST, Java-APIs, …  WebLogic Runtime  Perfect interaction between client and server  Use of client-component is not a MUST  But neither of the server-component  Commercial support from Oracle (in future)

Slide 19

Slide 19 text

Q & A NIKO KÖBLER – @dasniko HEIKO SPINDLER – @brainbrix QUALITECTS GROUP – www.qualitects-group.com PROJECT AVATAR

Slide 20

Slide 20 text

Links  Project Avatar: avatar.java.net  Avatar.js: avatar-js.java.net  Nashorn Blog: blogs.oracle.com/nashorn  Qualitects Group: www.qualitects-group.com