enterprise javascript ... what the heck?

38
Enterprise JavaScript… what the heck? Nedelcho Delchev [SAP] 2016-10-25

Upload: nedelcho-delchev

Post on 15-Apr-2017

153 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Enterprise JavaScript ... what the heck?

Enterprise JavaScript…what the heck?

Nedelcho Delchev [SAP]2016-10-25

Page 2: Enterprise JavaScript ... what the heck?

Who am I?

I am Development Architect in HANA Cloud Platform Core team in the area of extensions for large enterprises in the cloud.

Project lead of Eclipse Dirigible – a Cloud Development Platform project that provides full-fledged capabilities for developing, running and operating cloud applications – http://www.dirigible.io

Page 3: Enterprise JavaScript ... what the heck?

What the Enterprise JavaScript is?

• A JavaScript for Enterprises?• A script for Java-focused Enterprises?• Enterprise ready JavaScript?

Page 4: Enterprise JavaScript ... what the heck?

The Problem

We wanted The Perfect

Development Platform

Page 5: Enterprise JavaScript ... what the heck?

We wanted it …

• … to be instantly accessible• … to give the shortest development turn-around

time• … to provide all the needed features• … to fully cover the DevOps cycles• … to be highly adaptable and flexible• … to be turbo- mega- super- scalable• … must be Open Source• … to be beloved by the developers

Page 6: Enterprise JavaScript ... what the heck?
Page 7: Enterprise JavaScript ... what the heck?

The Solution

Page 8: Enterprise JavaScript ... what the heck?

Instantly accessible

• http://trial.dirigible.io• You can deploy on any Cloud • Complex landscapes can be easily organized

Page 9: Enterprise JavaScript ... what the heck?

The shortest development turn-around time

• Leveraging the In-System Programming paradigm

• Avoid the side-effects of the sandbox systems

Page 10: Enterprise JavaScript ... what the heck?

Providing all the features you may need

• Database modeling• Scripting Services• User Interfaces• Flows and Jobs• Mobile Apps• Debugging• Git Integration• Project & Artifacts Templates• Shell Access via Terminal• Log Console & Raw Logs

• Content Transport• Security Management• Access Management• Browse the Content• Discover Endpoints• Monitoring Basic Metrics• …

Page 11: Enterprise JavaScript ... what the heck?

Beloved by the Developers

• RAD technics – wizards, modeling tools• Multiple templates producing ready to use

RESTful services, CRUD User Interfaces, Mobile Apps, etc.

• Configurable and customizable• Extension Points and Extensions• Injected Services – Built-in and Platform services• Powerful source code editing by Orion …

Page 12: Enterprise JavaScript ... what the heck?

You have to code – yeah!

What do you want to code today?

Page 13: Enterprise JavaScript ... what the heck?

We Chose the Default

JavaScript

Page 14: Enterprise JavaScript ... what the heck?

Hello World!

var response = require('net/http/response');

response.println("Hello World!");

response.flush();response.close();

Page 15: Enterprise JavaScript ... what the heck?

Hello World!

var response = require('net/http/response');

response.println("Hello World!");

response.flush();response.close();

Page 16: Enterprise JavaScript ... what the heck?

Hello World!

var response = require('net/http/response');

response.println("Hello World!");

response.flush();response.close();

Page 17: Enterprise JavaScript ... what the heck?

Hello World!

var response = require('net/http/response');

response.println("Hello World!");

response.flush();response.close();

Page 18: Enterprise JavaScript ... what the heck?

HTTP Request & Response

var request = require('net/http/request');var response = require('net/http/response');

var parameter = request.getParameter("name");

response.println("[Parameter]: " + parameter);

response.flush();response.close();

Page 19: Enterprise JavaScript ... what the heck?

HTTP Upload

if (request.getMethod() === "POST") {if (upload.isMultipartContent()) {var files = upload.parseRequest();files.forEach(function(file) {response.println("[File Name] " + file.name);});} else {response.println("The request must be 'multipart'");}}

Page 20: Enterprise JavaScript ... what the heck?

HTTP Client

var options = { method: 'GET', // default host: 'http://services.odata.org', port: 80, path: '/V4/Northwind/Northwind.svc/', binary: false };var httpResponse = http.request(options);response.println(httpResponse.statusMessage);response.println(httpResponse.data);

Page 21: Enterprise JavaScript ... what the heck?

More about HTTP

• Session• Cookies• Headers• Attributes• Roles

Is it all about HTTP only?

Page 22: Enterprise JavaScript ... what the heck?

What about WebSockets?

var websocket = require("net/websocket");…var websocketSession = websocket.getSession();…websocketSession.sendText("Welcome!”);

Page 23: Enterprise JavaScript ... what the heck?

‘Enterprise’ without SOAP?var soap = require("net/soap");...var requestMessage = soap.createMessage();var part = requestMessage.getPart();var envelope = part.getEnvelope();envelope.addNamespaceDeclaration("ws", "http://ws.cdyne.com/");var body = envelope.getBody();var resolveIPElement = body.addChildElement("ResolveIP", "ws");...var mimeHeaders = requestMessage.getMimeHeaders();mimeHeaders.addHeader("SOAPAction", "http://ws.cdyne.com/ResolveIP");...var responseMessage = soap.call(requestMessage, "http://ws.cdyne.com/ip2geo/ip2geo.asmx");response.println("Response: " + responseMessage.getText());

Page 24: Enterprise JavaScript ... what the heck?

Relational Databases?var datasource = database.getDatasource();var connection = datasource.getConnection();try { var statement = connection.prepareStatement("select * from ..."); ... var resultSet = statement.executeQuery(); while (resultSet.next()) { response.println("[path]: " + resultSet.getString("...")); } resultSet.close(); statement.close();} catch(e) { …} finally { connection.close();}

Page 25: Enterprise JavaScript ... what the heck?

Files?var files = require('io/files');var response = require('net/http/response');

files.createFile(”sample.txt");

var file = files.get(”sample.txt");response.println("[File Exists?]: " + file.exists());response.println("[File Is File?]: " + file.isFile());

files.writeText("sample.txt", "Some content");

var content = files.readText(”sample.txt");response.println("[File Content]: " + content);

Page 26: Enterprise JavaScript ... what the heck?

Even Streams?!…var outputStream = streams.createByteArrayOutputStream();

streams.writeText(outputStream, "Some text content");

var bytes = outputStream.getBytes();response.println("[Stream Content as Bytes]: " + bytes);

var inputStream = streams.createByteArrayInputStream(bytes);var outputStreamCopy = streams.createByteArrayOutputStream();streams.copy(inputStream, outputStreamCopy);…

Page 27: Enterprise JavaScript ... what the heck?

… and Threads?!var threads = require('core/threads');var response = require('net/http/response');// Define a JavaScript functionfunction runnable() {response.println("Hello World from a Thread!");};// Pass the JavaScript function to a threadvar worker = threads.create(runnable, "I am a thread");response.println(worker.getName());worker.start();worker.join(); // to be able to print to the response…

Page 28: Enterprise JavaScript ... what the heck?

Services like Mail, Messaging, Indexing?

var mail = require('service/mail');var response = require('net/http/response');

var from = "[email protected]";var to = "[email protected]";var subject = "Subject";var content = "Content";

mail.send(from, to, subject, content);

Page 29: Enterprise JavaScript ... what the heck?

Internal Services

• Exec• Generator• Lifecycle• Repository• Workspaces

Page 30: Enterprise JavaScript ... what the heck?

Does it look familiar?

…var workspace = workspaces.getWorkspace();var workspaceRoot = workspace.getRoot();var project = workspaceRoot.getProject(“project1");project.create();project.open();var folder = project.getFolder(”folder1");folder.create();…

Page 31: Enterprise JavaScript ... what the heck?

Plenty of Utilities

• Assert• Config• Context• Console• Env• Globals• Extensions• Base64

• Digest• Error• Hex• Uuid• Xml• Xss

Page 32: Enterprise JavaScript ... what the heck?

Finally – the mission statement?

The ultimate goal of the “Enterprise JavaScript” is to provide a set of a standard APIs, which can be used by the business applications developers.

Page 33: Enterprise JavaScript ... what the heck?

Benefits - Completeness

• Rich, but still standardized APIs;• Expose legacy components and frameworks

to the new environment;

Page 34: Enterprise JavaScript ... what the heck?

Benefits - Portability

• No tight vendor lock-in to the currently chosen underlying JavaScript platform;• OS, platform and database agnostic;• Developers can stick to native JavaScript

objects and primitives only in their source code;

Page 35: Enterprise JavaScript ... what the heck?

Benefits - Lifecycle

• The API itself is a standard Eclipse Dirigible project, hence can have the same lifecycle as the rest of the projects;

Page 36: Enterprise JavaScript ... what the heck?

You already know…

• … what the Enterprise JavaScript really is.• … how to continue to rely on your knowledge &

experience in Java frameworks and APIs.• … that this effort is just the beginning and you

can join in the definition and implementation work

• … the reference implementation in the Cloud Development Platform project called Eclipse Dirigible: http://www.dirigible.io

Page 37: Enterprise JavaScript ... what the heck?

Thank You!