Enterprise JavaScript APIs build for Eclipse Dirigible.
The complete set of APIs, documentation and examples can be found here.
- Module: ('db/database')
- Issue: #9
- Example:
/* globals $ */
/* eslint-env node, dirigible */
var database = require('db/database');
var response = require('net/http/response');
var datasource = database.getDatasource(); // default
//var datasource = db.getNamedDatasource("name-of-the-datasource");
var connection = datasource.getConnection();
try {
var statement = connection.prepareStatement("select * from DGB_FILES where FILE_PATH like ?");
var i = 0;
statement.setString(++i, "%");
var resultSet = statement.executeQuery();
while (resultSet.next()) {
response.println("[path]: " + resultSet.getString("FILE_PATH"));
}
resultSet.close();
statement.close();
} catch(e) {
console.trace(e);
response.println(e.message);
} finally {
connection.close();
}
response.flush();
response.close();
- Module: ('core/config')
- Issue: #16
- Example:
/* globals $ */
/* eslint-env node, dirigible */
var config = require('core/config');
var response = require('net/http/response');
var properties = {
"property1": "value1",
"property2": "value2"
}
config.set("/path/to/property", "key1", "value1");
config.setJson("/path/to/properties", JSON.stringify(properties));
response.println(config.get("/path/to/property", "key1"));
var result = JSON.parse(config.getJson("/path/to/properties"));
response.println(result.property2);
config.delete("/path/to/property");
config.delete("/path/to/properties");
response.println(config.get("/path/to/property"));
response.println(config.get("/path/to/properties"));
response.flush();
response.close();
- Module ('net/http/response')
- Issue: #1
- Example:
/* globals $ */
/* eslint-env node, dirigible */
var response = require('net/http/response');
response.println("Hello World!");
response.flush();
response.close();
- Module ('net/http/request')
- Issue: #4
- Example:
/* globals $ */
/* eslint-env node, dirigible */
var request = require('net/http/request');
var response = require('net/http/response');
var method = request.getMethod();
response.println("[Method]: " + method);
response.flush();
response.close();
- Module ('net/http/session')
- Issue: #5
- Example:
/* globals $ */
/* eslint-env node, dirigible */
var session = require('net/http/session');
var response = require('net/http/response');
response.println("SessionId: " + session.getId());
var attributeNames = session.getAttributeNames();
while(attributeNames.hasMoreElements()) {
var attributeName = attributeNames.nextElement();
var value = session.getAttribute(attributeName);
response.println(attributeName + "=" + value);
}
response.flush();
response.close();
- Module ('net/http/client')
- Issue: #3
- Example:
/* globals $ */
/* eslint-env node, dirigible */
var http = require('net/http/client');
var response = require('net/http/response');
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);
response.flush();
response.close();
- Module ('service/mail')
- Issue: #12
- Example:
/* globals $ */
/* eslint-env node, dirigible */
var mail = require('service/mail');
var response = require('net/http/response');
var from = "dirigiblelabs@eclipse.org";
var to = "example@gmail.com";
var subject = "Subject";
var content = "Content";
mail.send(from, to, subject, content);
response.println("Mail sent");
response.flush();
response.close();
- Module ('utils/xss')
- Issue: #12
- Example:
/* globals $ */
/* eslint-env node, dirigible */
var xss = require('utils/xss');
var response = require('net/http/response');
raw = "John's bag";
escaped = xss.escapeSql(raw);
response.println(raw); // John's bag
response.println(escaped); // John''s bag
response.flush();
response.close();
- Module built-in
- Issue: #2
- Example:
/* globals $ /
/ eslint-env node, dirigible */
console.info("Info message: %s", "Hello World!");
console.error("Error message.");
console.warn("Warning message.");
console.log("Log message.");
console.trace("Trace.");
- Module ('service/messaging')
- Issue: #11
- Example:
/* globals $ */
/* eslint-env node, dirigible */
var response = require('net/http/response');
var messaging = require('service/messaging');
messaging.registerClient("client1");
messaging.registerClient("client2");
messaging.registerTopic("topic1");
messaging.registerTopic("topic2");
messaging.subscribe("client1", "topic1");
messaging.send("client1", "topic1", "Subject on Topic 1 from Client 1", "Message from Client1");
messaging.send("client1", "topic2", "Subject on Topic 2 from Client 1", "Message from Client1");
messaging.route();
var messages = messaging.receive("client1");
for(var i = 0; i < messages.length; i ++) {
var message = messages[i];
response.println(message.subject + " -> " + message.body);
}
response.flush();
response.close();
- Module ('io/files')
- Issue: #21
- Example:
/* globals $ */
/* eslint-env node, dirigible */
var files = require('io/files');
var response = require('net/http/response');
var file = files.get("../temp/./..");
response.println("[File Exists?]: " + file.exists());
response.println("[File CanonicalPath]: " + file.getCanonicalPath());
response.println("[File Path]: " + file.getPath());
response.println("[File Name]: " + file.getName());
response.println("[File Parent]: " + file.getParent());
response.println("[File Is Directory?]: " + file.isDirectory());
response.println("[File Is File?]: " + file.isFile());
response.println("[File Is Hidden?]: " + file.isHidden());
response.println("[File Last Modified]: " + file.lastModified());
response.println("[File Length]: " + file.length());
response.flush();
response.close();
Fore more samples see the TestCases folder and the Issues for more details.