wiki.webvm.net/ webvm/ Howto create a WebVM module

Intended audience: Software integrators who want to expose device APIs

This documentation is unstable, as WebVM is not released yet

  1. (optional) The Javascript interface wrapper
  2. Instancing the plugin
  3. The jar/jad that implements the module (java)
  4. Security policy
  5. Helper scripts
  6. Related

How to create your WebVM module.

(optional) The Javascript interface wrapper

Example: http://api.webvm.net/java/location/0.1/default

A Javascript wrapper is not absolutely neccessary, though your users will probably want to use:

x = gpslocation.getX( callback );

Instead of directly scripting the WebVM plugin object:

x = function() {return document.getElementById("pluginobj").getX();}

The URL that serves the module could have some extra logic, like handling version and other extra parameters.

Instancing the plugin

You the module vendor (or Web developer) should instance the plugin by calling a helper function in the WebVM AJAX API. Example using the addInstance helper function:

webvm.addInstance('pluginobj', { 'archive': 'http://plugin.webvm.net/204/204.jad', 'log': 'logdiv', 'launch': 'true'})
webvm.runOnLoad(function() {
// Your JavaScript
})

The log parameter in this example will output debugging information between the #logdiv tag:

<div id="logdiv"></div>

The launch parameter in this example will instance the Virtual machine immediately on load, which is optimal for testing. Instead of the default ‘false’ which only loads the VM when the WebVM plugin is used or called.

The jar/jad that implements the module (java)

An example .jad file:

MIDlet-Jar-URL: http://api.webvm.net/modules/location/0.1/location.jar
MIDlet-Name: net.webvm.location.LocationMIDlet
webvm-script-interface: net.webvm.location.LocationInterface

Here the Java developer decides how to expose the JSRs of the underlying Java VM (e.g JBlend).

Java MIDlet developers could consider migrating their applications over to the Web and using webvm as a means for doing so.

Security policy

The security example has not been finalised yet. Basically a vendor should be able to optionally include a fragment of what permissions the module requires, for the client to accept. This policy fragment should make the module more manageable and easier to use.

Helper scripts

A couple of helper scripts have been developed to act as a good starting point for writing a Java module. Please enquire about them.

Related