Server-Side JavaScript auf der JVM. Peter Doschkinow Senior Java Architect



Similar documents
Glassfish, JAVA EE, Servlets, JSP, EJB

NoSQL web apps. w/ MongoDB, Node.js, AngularJS. Dr. Gerd Jungbluth, NoSQL UG Cologne,

Microservices Technology Enabler from Oracle ijug / Oracle Roadshow 2015

<Insert Picture Here> GlassFish v3 - A Taste of a Next Generation Application Server

Oracle im Open Source Kontext Abgrenzung GlassFish vs. JBoss und wozu noch WebLogic?

CERTIFIED MULESOFT DEVELOPER EXAM. Preparation Guide

<Insert Picture Here> Java, the language for the future

MEAN/Full Stack Web Development - Training Course Package

ICON UK 2015 node.js for Domino developers. Presenter: Matt White Company: LDC Via

Oracle WebLogic Foundation of Oracle Fusion Middleware. Lawrence Manickam Toyork Systems Inc

Glassfish Architecture.

Learning GlassFish for Tomcat Users

Oracle Communications WebRTC Session Controller: Basic Admin. Student Guide

2012 LABVANTAGE Solutions, Inc. All Rights Reserved.

<Insert Picture Here> Java EE 7: the New Cloud Platform

White Paper: 1) Architecture Objectives: The primary objective of this architecture is to meet the. 2) Architecture Explanation

<Insert Picture Here> Java EE 7: the New Cloud Platform

GlassFish v3. Building an ex tensible modular Java EE application server. Jerome Dochez and Ludovic Champenois Sun Microsystems, Inc.

applications. JBoss Enterprise Application Platform

An introduction to creating JSF applications in Rational Application Developer Version 8.0

Programming IoT Gateways With macchina.io

socketio Documentation

<Insert Picture Here> Java EE 7. Linda DeMichiel Java EE Platform Lead

OUR COURSES 19 November All prices are per person in Swedish Krona. Solid Beans AB Kungsgatan Göteborg Sweden

Framework Adoption for Java Enterprise Application Development

Introducing Apache Pivot. Greg Brown, Todd Volkert 6/10/2010

PROFESSIONAL. Node.js BUILDING JAVASCRIPT-BASED SCALABLE SOFTWARE. Pedro Teixeira WILEY. John Wiley & Sons, Inc.

Ruby on Rails in GlassFish Sun Microsystems

Case Studies of Running the Platform. NetBeans UML Servlet JSP GlassFish EJB

Building A Self-Hosted WebRTC Project

Extending Tizen Native Framework with Node.js

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

NetBeans IDE Field Guide

ORACLE DATA SHEET KEY FEATURES AND BENEFITS ORACLE WEBLOGIC SERVER STANDARD EDITION

White Paper: Why Upgrade from WebSphere Application Server (WAS) v7 to v8.x?

Enterprise Application Development In Java with AJAX and ORM

Configuring Nex-Gen Web Load Balancer

Internet Engineering: Web Application Architecture. Ali Kamandi Sharif University of Technology Fall 2007

How To Create A C++ Web Service

FIVE SIGNS YOU NEED HTML5 WEBSOCKETS

Converting Java EE Applications into OSGi Applications

How To Build A Web App

OpenShift is FanPaaStic For Java EE. By Shekhar Gulati Promo Code JUDCON.IN

Collaborative Open Market to Place Objects at your Service

Apache Jakarta Tomcat

GlassFish. Developing an Application Server in Open Source

Project SailFin: Building and Hosting Your Own Communication Server.

Sample copy. Introduction To WebLogic Server Property of Web 10.3 Age Solutions Inc.

JBoss Seam Performance and Scalability on Dell PowerEdge 1855 Blade Servers

How To Write A Web Framework In Java

<Insert Picture Here> Oracle Mobile Enterprise Application Platform Overview

Integrating Mobile apps with your Enterprise

Aplicações empresariais de elevada performance com Oracle WebLogic e Coherence. Alexandre Vieira Middleware Solutions Team Leader

An Oracle White Paper May Ready for Business: Oracle GlassFish Server

Oracle EXAM - 1Z Java EE 6 Web Services Developer Certified Expert Exam. Buy Full Product.

Adobe ColdFusion (2016 release) Enterprise Edition

Basic TCP/IP networking knowledge of client/server concepts Basic Linux commands and desktop navigation (if don't know we will cover it )

Oracle Cloud Platform. For Application Development

INTRODUCTION TO JAVA PROGRAMMING LANGUAGE

WebLogic & Coherence. Best backend for Mobile Apps. July 2014 INSERT PRESENTER TITLE AND DATE

The Java EE 6 Platform. Alexis Moussine-Pouchkine GlassFish Team

How to Build an E-Commerce Application using J2EE. Carol McDonald Code Camp Engineer

Experiences with Open-Source BPM/SOA-based Stack using Java EE Rok Povše, Matjaž B. Jurič

MarkLogic Server. Reference Application Architecture Guide. MarkLogic 8 February, Copyright 2015 MarkLogic Corporation. All rights reserved.

WebSphere Server Administration Course

Oracle Net Services for Oracle10g. An Oracle White Paper May 2005

IBM WebSphere Server Administration

Platform Architecture & Integration with OpenShift

Open Source Technologies on Microsoft Azure

Oracle WebLogic Server: Remote Monitoring and Management

ORACLE MOBILE SUITE. Complete Mobile Development Solution. Cross Device Solution. Shared Services Infrastructure for Mobility

Reusing Existing * Java EE Applications from Oracle SOA Suite

WEB SERVICES. Revised 9/29/2015

Oracle Service Bus. Situation. Oracle Service Bus Primer. Product History and Evolution. Positioning. Usage Scenario

Collaborative Open Market to Place Objects at your Service

Introduction to Oracle Mobile Application Framework Raghu Srinivasan, Director Development Mobile and Cloud Development Tools Oracle

NoSQL replacement for SQLite (for Beatstream) Antti-Jussi Kovalainen Seminar OHJ-1860: NoSQL databases

WEB11 WebSphere extreme Scale et WebSphere DataPower XC10 Appliance : les solutions de caching élastique WebSphere

Introducing. Cathal McGloin, VP & General Manager, Mobile Platforms Javier Perez, Director of Product Management and Global Consulting

Agenda. Success Stories with OpenShift. 11:15-11:45 am. OpenShift Tech Overview 9:40-10:30 am. Red Hat Mobile on OpenShift 10:45-11:15 am

-8*6-DYD6HPLQDU 6HUYOHW$UFKLWHFWXUHV 5DLQHU+LVV$QGUHDV.DSS 6<6725$*

RED HAT SOFTWARE COLLECTIONS BRIDGING DEVELOPMENT AGILITY AND PRODUCTION STABILITY

Adobe ColdFusion 11 Enterprise Edition

Course Description. Course Audience. Course Outline. Course Page - Page 1 of 5

Oracle WebLogic Server

WHITE PAPER. Domo Advanced Architecture

EclipseLink. Solutions Guide for EclipseLink Release 2.5

Introduction to WebSphere Process Server and WebSphere Enterprise Service Bus

Web Cloud Architecture

Understanding Evolution's Architecture A Technical Overview

Various Load Testing Tools

MOBILIZING ORACLE APPLICATIONS ERP. An Approach for Building Scalable Mobility Solutions. A RapidValue Solutions Whitepaper

Why IBM WebSphere Application Server V8.0?

Preface. Motivation for this Book

Load and Performance Load Testing. RadView Software October

Oracle Identity Analytics Architecture. An Oracle White Paper July 2010

JBoss JEE5 with EJB3.0 on NonStop. JAVA SIG, San Jose

Transcription:

Server-Side JavaScript auf der JVM Peter Doschkinow Senior Java Architect

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.

Agenda Web Application Architecture JavaScript and Node.js on the JVM Project Avatar Advanced JavaScript Services Avatar Client Framework Summary

Evolution of Web Application Architecture A Java EE Perspective Request / Response Multi-Page Application HTTP Servlet / JSP Presentation Enterprise Connectivity and Business Logic Browser Client Server Java EE / JVM

Evolution of Web Application Architecture A Java EE Perspective Multi-Page Application In-page updates (AJAX) JavaScript HTTP Browser Client Server REST Servlet / JSP JSF Connectivity Presentation Enterprise Connectivity and Business Logic Java EE / JVM

Modern Web Application Architecture A Java EE Perspective Single-Page Application View/Controller in browser Model on client and/or server JavaScript Browser View Controller REST/SSE/WebSocket Client Server REST/SSE WebSocket Connectivity Enterprise Connectivity and Business Logic Java EE / JVM

The Rise of JavaScript http://redmonk.com/sogrady/2014/06/13/language-rankings-6-14/

Java EE 7 The Latest in Enterprise Java DEVELOPER PRODUCTIVITY MEETING ENTERPRISE DEMANDS Java EE 7 More annotated POJOs Less boilerplate code Cohesive integrated platform WebSockets JSON Servlet 3.1 NIO REST Batch Concurrency Simplified JMS

Node.js http://www.nodejs.org Platform built on Chrome s JavaScript runtime V8 for easily building fast, scalable network applications (Ryan Dahl, 2009) perfect for DIRTy(Data Intensive Real-Time) apps Uses event-driven non-blocking I/O model The async programming model is harder to develop to, but it allows scalability and high levels of concurrency Melting pot community Java,.NET, Browser, PHP, etc Very successful, second-most-watched project on GitHub with 60,000+ modules

Node.js Programming Model Multi-threading is hard Thousands of concurrent connections Deal with deadlocks and race conditions Blocking on I/O is bad Single threaded Event-loop Callback model Non-blocking I/O calls Heavily parallelized Minimal Web Server Example :

Node.js Event Loop Client Requests (Http) Resource- Intensive Operations Network Single-Threaded Event Loop File System Network Compute

Ressource Utilization: sync vs. async I/O http://bijoor.me/2013/06/09/java-ee-threads-vs-node-js-which-is-better-for-concurrent-data-processing-operations/ Node.js, Vert.x are based on an async programming model Java EE introduces many new async API - Servlet, EJB, JAX-RS, Concurrency for Java EE,...

Evolution of Web Application Architecture Mobile-enabling existing services Project-based end-to-end JavaScript Rapid prototyping & API layer Leverage backend resources - Aggregate & transform content - Return JSON to browser JavaScript Browser View Controller REST/SSE/WebSocket Client Server Node.js REST/SSE WebSocket Connectivity Java EE / JVM Enterprise Connectivity and Business Logic

Evolution of Web Application Architecture Mobile-enabling existing services What if we could run Node.js alongside Java EE in the same JVM? JavaScript Controller Browser View REST/SSE/WebSocket Client Server Node.js Connectivity Enterprise Connectivity and Business Logic Java EE / JVM

Project Nashorn JavaScript on the JVM ECMAScript 5.1 compliant Bundled with JDK 8 Replaces Rhino in earlier JVMs Faster (2x 10x) New command-line tool jjs to run JavaScript Seamless Java JavaScript interoperability http://download.java.net/jdk8/docs/technotes/guides/scripting/nashorn/index.html

Avatar.js Node.js on the JVM Platform for server side JavaScript applications Requires Nashorn (JDK 8) 95% Node.js compatibility Use popular packages (Express, async, commander, etc) Uses same portability libraries as Node.js Java bindings for libuv and http-parser Limitation: No Chrome v8 native APIs Avatar.js Advantages Leverage JVM, Java frameworks and libraries, Security manager

Avatar.js = Node.js + Java Leverage Java, including Threads require ( express ) JavaScript java.lang.thread Node App com.mydom.myobj java.util.sortedset java.math.biginteger JVM Process Java Node.js 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.mydom.myobj()

Demo Pictures web app with Node.js and Avatar.js

Nodyn http://nodyn.io Node.js compatible open-source framework by RedHat compatibility achieved by implementing process.binding(c/c++ dependencies in newer Node.js code) in Java Components DynJS: JavaScript runtime (for now slower than Nashorn) Netty: asynchronous event-driven network application framework Vert.x No distribution available yet Similar to avatar.js

Project Avatar the Backend A Server Side JavaScript Services Framework Similar in spirit to Servlets, but focused on REST, WebSocket, Server Sent Event (SSE) endpoints Use familiar Node.js event-driven programming model and modules Layers on Avatar.js NodeJS-compatible runtime Adds integrated enterprise features

Avatar Architecture - Server Server side Server Database Data Application Services Notification Avatar Modules Node Modules Avatar.js Avatar Runtime Server Runtime (Java EE) JDK 8 / Nashorn = Application code = JavaScript framework = Java framework

Project Avatar Backend Features Leveraging the JVM and Java EE in the Node.js programming model Out-of-the-box support for REST, WebSocket, SSE communications Multi-threading, lightweight message passing, shared state HTTP listener / load-balancer is managed by framework (unlike Node) Model Store Object Relational Mapping DataProvider API Simple key-value based collection abstraction FileDataProvider, JPADataProvider, NoSqlDataProvider Messaging integration with JMS on Java EE container Through configuration of SSE- and WebSocket communication types

WebSocket Service Example // 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); };

WebSocket Service Example With JMS integration // Load avatar module var avatar = require( org/glassfish/avatar ); // Register service instance avatar.registersocketservice({ url: "/websockets/jmschat/{chatroom}", jms: { connectionfactoryname: "jms/avatarconnectionfactory", destinationname: "jms/avatartopic", messageselector: "chatroom='#{this.chatroom}'", messageproperties: { chatroom: "#{this.chatroom}" } } }, function() { this.onmessage(peer, message) { }};

Avatar Services Scalability Multi-core, state sharing, data storage HTTP Load Balancer Database Services Services Services Services JavaScript Data Notification JSON JSON JSON JSON shared state JVM Process Java

Shared State Lightweight inter-thread communication Two Models 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

State Sharing Example var avatar = require( org/glassfish/avatar ); var threads = require( org/glassfish/avatar/threads ); var appname = avatar.application.name; var bus = avatar.application.bus; // Listen for messages on the hello topic bus.on( echo, function(msg) { print(appname + got + msg); }); // Start a background thread which publishes to the echo topic new threads.thread( background, monitor.js ).start(); // or publish to the same topic in this thread settimeout(function() bus.publish('echo', { x : 'x', y : 'y' }), 3000);

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, Mongoose

Model-Store API 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: root, password: gu3ssit createdb: true, droptables: true });

Model-Store Example 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 data store Connect to store Creates Product table if required Callback adds product to table

Model-Store API Models can have relationships with other models 1:1, 1:n, M,N Data Stores Relational Tested: Oracle DB, MySQL, Derby (Embedded, Network) Non-tested: Any other JDBC driver Non-relational Oracle NoSQL, MongoDB (in progress)

Demo Porting of a HTML5 Applicaton to Avatar Client implementation in AngularJS Server implemented with Java EE 7, then ported to use Avatar services Focus on the server side Demonstrate usage of Avatar Services built-in support for REST/WebSocket/SSE communication patterns Shared state Message bus Running on GlassFish 4.x or WebLogic 12.1.3

Drawing Board HTML5 Demo http://github.com/doschkinow/hol-sse-websocket/solutions/exercise5 Collaborative drawing Two-page application List of drawings Drawing Demonstrating Server-side: JAX-RS, JSON, WebSocket, SSE Java API Client-side: JAX-RS, WebSocket, SSE Java and JavaScript API JavaFX hybrid Java/HTML5 application

WS Endpoint JAX-RS/SSE Jersey Drawing Board HTML5 Demo Thin Server Architecture Clients GlassFish 4.0 HTTP/S Data Service JSON HTML5 Browser send(...) onevent(...) SSE JSON DataProvider POJO (Map with Drawings) DrawingService.query(...) websocketsend.send(...) WebView/WebKit JavaFX Web Sockets

Drawing Board HTML5 Demo Technology usage JAX-RS: CRUD for drawings SSE: distributing the list of drawings to all connected clients WebSocket: distributing the updates of a drawing to all connected clients JSON: implementing of encoder/decoder of the WebSocket server endpoint Java JavaScript bridge(webengine): modifying the AngularJS client by replacing the WebSocket/SSE JavaScript client communication with a Java implementation in the JavaFX client

Avatar Comm. Services Internal Load Balancer Avatar Comm. Services Avatar Shared State Avatar Message Bus Drawing Board HTML5 Demo Using Avatar Services (http://github.com/doschkinow/hol-sse-websocket/solutions/exercise7) Clients Java EE Server HTTP/S JSON JavaScript Execution Context (Thread) HTML5 Browser SSE send(...) onevent(...) DrawingService.query(...) websocketsend.send(...) WebView/WebKit JavaFX JSON Web Sockets JavaScript Execution Context (Thread)

Avatar Roadmap Project Avatar launch JavaOne, 2013 WebLogic Runtime GlassFish 4 Runtime 2013 2014 2015 WebLogic 12.2.1 Avatar Commercial Support

Avatar-SE Lightweight implementation on Java SE Internal project Seeking to deliver a very lightweight implementation Zip-distribution, based on Grizzly as protocol engine Includes JPA and JavaDB Running the Avatar examples application java -jar lib/avatar-se.jar start avatar-se-1.0- ea/project-avatar-examples/hangman

Summary Server Side JavaScript on the JVM Invoke Java code 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)