Date post: | 15-Apr-2017 |
Category: |
Software |
Upload: | nedelcho-delchev |
View: | 148 times |
Download: | 0 times |
Enterprise JavaScript…what the heck?
Nedelcho Delchev [SAP]2016-10-25
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
What the Enterprise JavaScript is?
• A JavaScript for Enterprises?• A script for Java-focused Enterprises?• Enterprise ready JavaScript?
The Problem
We wanted The Perfect
Development Platform
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
The Solution
Instantly accessible
• http://trial.dirigible.io• You can deploy on any Cloud • Complex landscapes can be easily organized
The shortest development turn-around time
• Leveraging the In-System Programming paradigm
• Avoid the side-effects of the sandbox systems
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• …
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 …
You have to code – yeah!
What do you want to code today?
We Chose the Default
JavaScript
Hello World!
var response = require('net/http/response');
response.println("Hello World!");
response.flush();response.close();
Hello World!
var response = require('net/http/response');
response.println("Hello World!");
response.flush();response.close();
Hello World!
var response = require('net/http/response');
response.println("Hello World!");
response.flush();response.close();
Hello World!
var response = require('net/http/response');
response.println("Hello World!");
response.flush();response.close();
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();
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'");}}
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);
More about HTTP
• Session• Cookies• Headers• Attributes• Roles
Is it all about HTTP only?
What about WebSockets?
var websocket = require("net/websocket");…var websocketSession = websocket.getSession();…websocketSession.sendText("Welcome!”);
‘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());
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();}
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);
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);…
… 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…
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);
Internal Services
• Exec• Generator• Lifecycle• Repository• Workspaces
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();…
Plenty of Utilities
• Assert• Config• Context• Console• Env• Globals• Extensions• Base64
• Digest• Error• Hex• Uuid• Xml• Xss
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.
Benefits - Completeness
• Rich, but still standardized APIs;• Expose legacy components and frameworks
to the new environment;
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;
Benefits - Lifecycle
• The API itself is a standard Eclipse Dirigible project, hence can have the same lifecycle as the rest of the projects;
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
Thank You!
References
• http://api.dirigible.io• http://samples.dirigible.io• http://www.dirigible.io/blogs/2016/08/01/
blogs_why_enterprise_js.html