Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Project Avatar - more than just Node.js on the ...

Project Avatar - more than just Node.js on the JVM @ JavaLand 2014

Niko Köbler

March 26, 2014
Tweet

More Decks by Niko Köbler

Other Decks in Programming

Transcript

  1. ENTERPRISE JAVA WRITTEN IN JAVASCRIPT PROJECT AVATAR: MORE THAN JUST

    NODE.JS ON THE JAVA VIRTUAL MACHINE NIKO KÖBLER HEIKO SPINDLER QUALITECTS GROUP
  2. Agenda  The Web as a Plattform  Avatar Basics

     Avatar Features  Avatar Demo
  3. „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
  4. 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
  5. Modern Web Application Architecture JavaEE / JVM Browser Presentation Presentation

    Connectivity (WebSockets, SSE, Rest) Enterprise Integration and Business Logic
  6. 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
  7. 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
  8. Definition of the model <script data-model="local" data-instance="add"> var AddMathModel =

    function() { this.left = 0; this.right = 0; this.reset = function() { this.left = this.right = 0; }; }; </script>
  9. 2-way-binding of model and UI-elements <input id="lfa" type="text" data-value="#{add.left}"/> <input

    id="rta" type="text" data-value="#{add.right}"/> <span id="output1">The result is #{add.left} + #{add.right} = #{add.left + add.right}</span> <button onclick="#{add.reset()}" id="reset">Reset</button>
  10. 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"} );
  11. 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"); });
  12. 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(); } ); }; });
  13. 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
  14. 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)
  15. Q & A NIKO KÖBLER – @dasniko HEIKO SPINDLER –

    @brainbrix QUALITECTS GROUP – www.qualitects-group.com PROJECT AVATAR
  16. Links  Project Avatar: avatar.java.net  Avatar.js: avatar-js.java.net  Nashorn

    Blog: blogs.oracle.com/nashorn  Qualitects Group: www.qualitects-group.com