javascript topic maps in server environments

20
WEBVEVERIET Ravn Webveveriet AS, 2010-10-01 Jan Schreiber <[email protected] > JavaScript Topic Maps in server environments 1

Upload: tmra

Post on 18-Dec-2014

572 views

Category:

Education


3 download

DESCRIPTION

This paper is about the JavaScript-based Topic Maps Engine tmjs.

TRANSCRIPT

Page 1: JavaScript Topic Maps in server environments

W E B V E V E R I E T

Ravn Webveveriet AS, 2010-10-01

Jan Schreiber <[email protected]>

JavaScript Topic Maps in server environments

1

Page 2: JavaScript Topic Maps in server environments

W E B V E V E R I E T

Outline

• JavaScript

• The tmjs Topic Maps engine

• Use Case: A PSI Server

• Outlook

2

Page 3: JavaScript Topic Maps in server environments

W E B V E V E R I E T

JavaScript

• JavaScript is LISP with a C-like syntax

• Virtually every personal computer in the world has at least one JavaScript interpreter installed on it and in active use.

3

Page 4: JavaScript Topic Maps in server environments

W E B V E V E R I E T

tmjs• A Topic Maps engine

• Written in pure JavaScript

• Full TMDM including Variants

• TMAPI 2.0-based

• In-memory backend, JTM import/export, experimental XTM 2.0 import (requires DOM)

4

Page 5: JavaScript Topic Maps in server environments

W E B V E V E R I E T

tmjs• Platform independent: All modern

browsers, mobile devices (iPhone & Android), server-side JavaScript

• Unit tests, CXTM tests (partly) & JSLint validating

• Small changes to TMAPI due to the lack of method overloading

• Syntactic sugar: Supports chaining of TMAPI calls

5

Page 6: JavaScript Topic Maps in server environments

W E B V E V E R I E T

Chaining

tm.createTopic().addSubjectIdentifier(foo).

createName('bar').getParent().

createOccurrence(type,'baz').

addScopingTopic(quux);

1

2

3

4

6

Page 7: JavaScript Topic Maps in server environments

W E B V E V E R I E T

tmjs: Outlook• More import/export formats: XTM 2.0, CTM

• Complete TMAPI, add more tests, full CXTM

• Persistence:

• Web SQL Database backend

• Persistent backend for Node (couchdb?)

• Later: Query language

7

Page 8: JavaScript Topic Maps in server environments

W E B V E V E R I E T

Use Case: A PSI Server

• Idea: Start the server with a Topic Map and it will serve information about all Subject Identifiers for a given domain

8

Page 9: JavaScript Topic Maps in server environments

W E B V E V E R I E T

• Screenshot node-psi-server

9

Page 10: JavaScript Topic Maps in server environments

W E B V E V E R I E T

Server-side JavaScript

• 1996: Netscape releases LiveWire as part of Netscape Enterprise Server 2.0

• 2009: Ryan Dahl writes Node

10

Page 11: JavaScript Topic Maps in server environments

W E B V E V E R I E T

Node• A framework for low-level network

applications based on Google's V8 engine

• TCP, DNS and HTTP are first-class protocols

• Event-based, asynchronous programming

• All I/O is non-blocking

11

Page 12: JavaScript Topic Maps in server environments

W E B V E V E R I E T

result = db_query(db, "SELECT * FROM topic");

12

Page 13: JavaScript Topic Maps in server environments

W E B V E V E R I E T

db_query(db, "SELECT * FROM topic", callback);

13

Page 14: JavaScript Topic Maps in server environments

W E B V E V E R I E T

db_query(db, "SELECT * FROM topic", callback);

callback = function (err, result) {

// ...

}

14

Page 15: JavaScript Topic Maps in server environments

W E B V E V E R I E T

var tm, servername;

// assumes that the TopicMap object tm has been initialized and

// the topic map in question has been imported successfuly.

// servername is set from a command line parameter

http.createServer(function (req, res) {

var url = 'http://'+servername+req.url, loc, topic;

loc = tm.createLocator(url);

topic = tm.getTopicBySubjectIdentifier(loc);

if (topic) {

res.writeHead(200, {'Content-Type': 'text/html'});

// create a page with information about the PSI

} else {

// Not found: create a 404 response

}

res.close();

}).listen(80);

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

15

Page 16: JavaScript Topic Maps in server environments

W E B V E V E R I E T

Use Case: A PSI Server

• More output formats: XHTML, JTM, XTM

• Support for logging, caching, templates

• Configurable list of information elements that are included on generated pages (e.g. dc:description, supertype-subtype)

• PSI black-listing

• subj3ct.com integration

16

Page 17: JavaScript Topic Maps in server environments

W E B V E V E R I E T

PSI Server: Observations

• Easy to implement

• It’s really fast: 200+200ms to read the Opera topic map, 1ms to serve a PSI page

• tmjs can be used on server and client side Reuse of application code

17

Page 18: JavaScript Topic Maps in server environments

W E B V E V E R I E T

Summary & Outlook

• Server side Topic Maps with JavaScript: possible!

• Asynchronous TMAPI?

• In its current state maybe best suited for low-level applications

18

Page 19: JavaScript Topic Maps in server environments

W E B V E V E R I E T

What could it be good for?

• TMRAP, TM REST API

• SDshare

• P2P applications

• DNS servers

19

Page 20: JavaScript Topic Maps in server environments

W E B V E V E R I E T

Questions?

Download tmjs now!

http://github.com/jansc/tmjs

Coming soon:

http://github.com/jansc/node-psi-server

20