Overview
WebVM is an extension of a CLDC VM which allows the VM, and libraries loaded by the VM, to be scripted using languages such as JavaScript. WebVM previously had a working title of JSX(JBlend Scripting Extension).
WebVM is intended to be used in conjunction with any environment that allows scripting of markup-based content, such as HTML browsers, standalone SVG players, and JavaScript/XML-based widget engines. This document concentrates on the requirements that apply to a browser-based setting.
The philosophy of WebVM is that it provides the maximum possible useful functionality within the following constraints:
- it is supportable using existing browser plugin APIs;
- it is supportable using ECMAScript standard features and classes2;
- it is supportable using a CLDC-class VM3.
WebVM is therefore designed so that it is not intrusive to the browser or scripting engine.
For use with an HTML browser, WebVM is presented as a scriptable browser
plugin. The most common plugin API used in all major desktop browsers (apart
from IE) is the Netscape Plugin API (NPAPI) which now supports scripting of
plugins via a portable interface. This allows web pages to access WebVM
functionality by referencing the plugin implementation and Java library using
an <OBJECT> tag.
Although the implementation of WebVM is to be tied to JBlend, there is no reason why the standards and conventions defined by WebVM are not supportable in any other VM.
Key features
Multiple bindings
The basic WebVM mechanism is essentially a language-level mechanism that connects Java and JavaScript; therefore many features are independent of the specific profiles available in the installed Java system. However, in order to ensure continued compliance of the Java system, it is important to ensure that the Java “environment†exposed by WebVM conforms fully to a valid Java configuration and set of profiles in order to remain compliant and certifiable under Java licensing rules. The specific formats and conventions used for packaging and presenting the Java code therefore depend on the Java profile(s) that are exposed by the WebVM system.
The system has been designed so that a number of different specific “bindings†between the Web environment and the Java system can be supported — so as not to be unduly prescriptive about the capabilities required of the Java installation, or about the specific manner in which the Java functionality is used by the web app. Section 2 describes these bindings in detail.
Section 4 defines the general mapping (eg of types and classes) between Java and JavaScript.
Security model
WebVM also addresses the security issues that arise when web applications have the potential to interact directly with platform services. It has been necessary to develop a security model that takes advantage of the security mechanisms provided by the Java system, but uses these to enforce a policy that is better suited to web applications than the standard MIDP2 security model would be. It is expected that the WebVM implementation would implement the policy described here, but in fact the policy would be valid if extended to cover all aspects of a browser’s operation, not just the WebVM plugin. Whether or not it is possible to do this will depend on each browser.
The security model is described in section 3.
JavaScript module system
Although WebVM will provide the ability for web pages to interface directly to Java functionality (and thus platform functionality) within WebVM libraries, it is intended that this it is used to create (and deploy) JavaScript libraries (or modules) that encapsulate that functionality. These modules would then provide a JavaScript-level API for each particular service, and would be reusable across any number of different web applications. For example, a JavaScript location API, leveraging the underlying JSR179 API, might provide services to a number of location-aware web applications.
In order to facilitate this, WebVM includes a JavaScript module loader which can be used to load and manage a number of JavaScript modules within an web application. This loader is compatible with the OpenAjax Hub API and provides a number of additional services that are specific to WebVM.
The module system is described in section 5.