Live from JavaOne: Web Widgets and MSA

I continue my buzzword morning. After RESTful, I am getting information about Web Widgets for Java ME.

The idea is to introduce a new application model for Java ME for Web applications. What exists today is LWUIT XHTML component, and JSR 290, which is at the final draft stage (more at keynote, according to the presenter?).

A Web widget is a client-side application that is authored using Web standards and packaged for distribution (www.w3.org/TR/widgets).

A mobile web widget is a bit different: (1) it is intended as a client-side application stored on a mobile device, (2) it can run without the need to connect to the Web, (3) it is created with Java or Web technologies, and (4) it should have access to the device resource and be able to cache content in memory. A bit more ambitious than basic Web widgets.

The presentation is obviously based on an ongoing prototype development, and the way in which it will be integrated in the roadmpa is not clear. The idea is to develop a Web runtime on top of Java ME, with JavaScript extensions, to introduce multiple application models beyond Midlets, to be well integrated in the AMS, and be portable.

In practice, there is a Java environment, a Web engine, and a Java/Javascript bridge between the two. With that, we can make Java applications, Web applications, and blended applications, which are the new things here.

A blended application combines Web Widgets and Java classes. JavaScript code has access to Java APIs, and the system will also support dynamically downloadable classes. The main use cases are:

  • Accessing device peripherals, like sensors, GPS, etc.
  • Complex business logic in Java, combined with fancy Web UI.
  • Security that goes beyond “same origin” by using the Java ME security model.

This prototype is built on top of Java ME, with significant changes. For instance, the AMS has been modified significantly, with new elements in the config.xml file. Basically, if I understand correctly, we now have a specific descriptor for widgets, and a widget that requires some JAR files to function is a blended application. A widget file therefore contains a config.xml file, as well as a set of traditional Web resources (CSS, PNG, etc.).

The next thing is JavaScript-Java interaction. It is possible to call a platform Java API directly via the JavaScript-Java bridge. The bridge uses the Netscape Plugin API, and the mapping is made between JavaScript properties and Java fields (through get/set methods), and JavaScript method invocations to Java method calls. Java classes are simply available on JavaScript with a “bridge.JavaPackages” prefix on their names. So, here is the code to call a method myMethod defined in a method MyClass in package com.vetilles.example.

  var MyClass = bridge.JavaPackages.com.vetilles.example.MyClass;
  var myClassObject = new MyClass();
  myClassObject.myMethod()

In terms of security, the config.xml file needs to list the required packages, as well as the required permissions. In the current prototype, widgets follow the full MIDP security model, and the users are queried about security. However, in future evolution, this may evolve to a model where the user is only queried at installation time.

No Comments

Leave a Reply

Your email is never shared.Required fields are marked *