Weblog

Microsoft wants royalties from open source users

Today everybody is talking about this article in fortune: Microsoft takes on the free world. According to Microsoft Linux is violating 235 patents, with the Linux kernel violating 42 Microsoft patents. (Nice number, Douglas Adams would be proud of the linux developers. Maybe Linux is the ultimate answer to everything?) You can find a lot of the reactions on Techmeme.

Im my opinion, software patents have become more or less without value because of the large number of nonsense patents. According to one commenter on Scobleizer, Microsoft about to enter into patent war?:

Royalties are an accepted way to be compensated for your IP…. Doesn’t it seem fair for them to be able to seek compensation for the results achieved from their R&D efforts? It happens in every other industry.

I agree, if someone is using you R&D efforts, it’s fair to be paid. But so many software patents are based on zero R&D efforts, just some people who translated common practice to software. Also, many innovations are thought of by many people at the same time. Which means that they all put in a lot of R&D effort. Why would only one party profit from all this R&D investment? I don’t think a lot of opensource programmers copied Microsoft R&D into Linux, they were just clever enough to think of it themselves. Of course, this is not how the legal world works.

I work mainly with Oracle and Java software, both contain a lot of opensource components. Two thoughts come to mind. One, we’ll finally see what Oracle’s indemnification for Linux is worth. Personally, i find this a very scary sentence in their indemnification document:

Oracle may choose to either modify the material to be non-infringing (while substantially preserving its utility or functionality) or obtain a license to allow for continued use, or if these alternatives are not commercially reasonable, then Oracle may, upon 30 days notice to you terminate your right to receive indemnification for your further use of the materials specified; and refund any prepaid Enterprise Linux support fees you have paid for the covered programs.

So what they are basically saying is that you may get your money back, and not be indemnified at all.

And the second thought is about Mono, the opensource implementation of the Java alternative .Net. How is this impacting them? Many people have warned about using Mono, because they might be exceptionally vulnerable to Microsoft Patent threads. Are any of those 235 patents violated by .Net?

JDeveloper 11g Technical Preview available

Shay Shmeltzer just posted that JDeveloper 11g is available for download: Download of the Day – JDeveloper 11 Technology Preview. The new features page has a long list of improvements, too long for me to list here.

The most awaited feature is probably the new ADF Faces Richt Client components, with full support of AJAX. For AJAX development a Javascript debugger and editor is included, and for database developers, all of the functionality of SQLDeveloper is included.

You can also download a new versions of oc4j and toplink, and JDeveloper is also available as a download for Apple Mac.

Use ajax treecompontent in jsp with DOJO

If you need a treecomponent which can load a tree structure dynamic based on the selected node, here’s a howto. This article adds a treecompontent to a simple struts jsp page and loads form details using ajax technology with Dojo.

Dojo has a tree component which does all the hard work for you. It can be fitted with a TreeLoadingController which can load JSON data from a servlet (and thus using ajax).

First create a jsp in which you want to display your tree. Insert the following imports:

<script type="text/javascript">
      var djConfig = { isDebug: true };
</script>
<script language="JavaScript" src="/testapp/js/dojo.js">/*_*/</script>
<script type="text/javascript">
dojo.require("dojo.widget.Button");
dojo.require("dojo.event.*");
dojo.require("dojo.io.*");
dojo.require("dojo.widget.Tree");
dojo.require("dojo.widget.TreeNode");
dojo.require("dojo.widget.TreeSelector");
dojo.require("dojo.widget.TreeLoadingController");
</script>

In your document body create the treecomponent:

<div dojoType="TreeLoadingController" RPCUrl="/testapp/booksServlet" widgetId="treeController" DNDController="create"></div>
<div dojoType="TreeSelector" widgetId="treeSelector"></div>
<div dojoType="Tree" DNDMode="between" selector="treeSelector" widgetId="algOrgEenhedenTree" controller="treeController">
<div dojoType="TreeNode" title="Books" widgetId="root" objectId="" isFolder="true"></div>

In the TreeLoadingController the RPCUrl is the location of the servlet (or struts action) which returns a JSON collection of tree elements for the current node. The servlet is called with a parameter ‘data’ from which you can extract information about the selected node. Next you have to write your servlet wich returns a list of elements you want to display in the tree, for example books.

The component expects the result in the JSON format. I created a simple servlet which extracts the objectId of the current node and queries for it’s children. These are returned in the JSON format. Here’s the code that formats the result

protected void doPost(HttpServletRequest request, HttpServletResponse response) {
// Get the data parameter sent by dojo
String data = request.getParameter("data");
// Gather the objectid from the data parameter string.
String OBJECTID = "\"objectId\":\"";
int start_idx = data.indexOf(OBJECTID) + OBJECTID.length();
int end_idx   = data.indexOf('\"',start_idx);
String objectId = data.substring(start_idx, end_idx);
StringBuffer json = new StringBuffer();

while (i.hasNext()) {
  // do stuff here to get your service objects
  List books = service.getBooks(objectId);

  for (Book book : books) {
    String isfolder = book.getchildren().size() > 0 ? "true" : "false";
    json.append("{title:\""+book.getTitle()+"\",isFolder:"+isfolder+",objectId:\""+book.getId()+"\"},");
  }

  // delete the last comma
  json.deleteCharAt(json.length() -1);
  json.append("]");

  // get the servlet response object here..
  response.setContentType("text/javascript");
  PrintWriter writer = response.getWriter();
  writer.println(json.toString());
  writer.close();
}

Note: There are also JSON libraries for java available which you can use to build a json string. However for this small example using a StringBuffer will do. For example the result could look like:

[{title:"Ajax Books",isFolder:true,objectId:"101"},
 {title:"JSP Books",isFolder:true,objectId:"110"},
 {title:"Java 5 edition",isFolder:false,objectId:"102"}
]

When a user selects the plus-sign the servlet is automatically called through the TreeLoadingController and the tree is updated with the results from the servlet.

Now you have your tree, but you also need to do something with it. I used the selected node to query the details records from the server with dojo and fill a form with record details. In the javascript section of the jsp include the following code:

function init() {
    var treeSelector = dojo.widget.manager.getWidgetById('treeSelector');
    dojo.event.connect(treeSelector,'select','treeSelectFired');
    <!-- Create a jsp form named detailform to populate, hide until details are selected -->
    var detailform = document.getElementById('detailform');
    detailform.style.visibility = 'hidden';
}

dojo.addOnLoad(init);

function treeSelectFired() {
    <!-- get a reference to the treeSelector and get the selected node -->
    var treeSelector = dojo.widget.manager.getWidgetById('treeSelector');
    var treeNode = treeSelector.selectedNode;
    var objectId = treeNode['objectId'];
    retrieveFormDetails(objectId);
    if (detailform.style.visibility == 'hidden') {
         detailform.style.visibility = 'visible';
    }
}

function retrieveFormDetails(objectId) {
    dojo.io.bind({
        url: "/testapp/bookDetailsServlet?objectId" + objectId,
        load: function(type, data, evt) { updateFormData(data); },
        error: function(type, data, evt) { displayError(type,data,evt); },
        mimetype: "text/plain"
    });
}

function updateFormData(data) {
  var jsonData = data;
  var jsonObject = eval('(' + jsonData + ')');
  document.getElementById("bookid").value = jsonObject.detailform.bookid;
  document.getElementById("bookname").value = jsonObject.detailform.bookname;
  document.getElementById("bookprice").value = jsonObject.detailform.price;
}

function displayError(type, data, evt) {
  alert('error callback!\ntype:'+type+'\ndata:'+data+'\nevt:'+evt);
}

The treeselectFired function is registered in the init function and called everytime a user click’s the plus-sign. The retrieveFormDetails functions is making a ajax call to the bookDetailsServlet and passed the objectId parameter. The javascript callback is handled in the updateFormData function which simply sets the form fields. This way our form is updated without refreshing the browser window. All what’s left is to write the bookDetailsServet. I ommitted this because it’s similair to the booksServlet.

This was one of my first attempts using ajax technology and I picked dojo from the list of available ajax toolkits and frameworks because I needed a treecomponent. Does anyone know a faster way to achieve the above? Note: It has to be struts/jsp and preferably portlet enabled.

Microsoft Silverlight

Even though this blog mainly focuses on Oracle related technologies, in the last few months I’ve also written about Adobe Flex. This is because i think rich graphical web user interfaces are going to become very important in the future.

Currently the Oracle world is mainly focussed on structured data, both entry and retrieval, using html. In this area JSF and ADF Faces are good solutions, but already Oracle is adding support for flash in ADF Faces to support graphs. Currently this is limited to graphs based on data.

Oracle also knows that the growth is in non structured data: sound, imaging, video, etc. A lot of effort is invested into making the Oracle database the best place to store all this data. For example, the secure files feature which is planned for 11G. This will allow you to put unstructured data in the database, without a performance penalty. Accessing a video in the database will be as fast as accessing a video on the file-system.

With all this unstructured data comes the requirement to create user interfaces which enable you to take benefit from all this data. And in this area JSF and ADF Faces are currently not strong contenders. Flex is one possible solution. At the Mix07 Microsoft has just announced another solution: Silverlight using a cross-platform mini-CLR. For Java developers it sounds like a copy of the Java applet technology: a CLR plugin for your browser, but with all the libraries to create rich media applications. The size of the mini CLR is about 4Mb, so i think it’s smaller than the JRE required to run Java applets. But more importantly, silverlight is supported by a lot of tooling and frameworks required to create graphically rich multimedia user interfaces. This video gives a nice impression of what can be achieved with this technology: Top Banana.

It is clear that there’s a requirement for this kind of technology, and in it’s current state JSF isn’t going to cut it. It’ll be interesting to see what happens, and what Oracle is going to do to provide you the tools to build rich multimedia user interfaces. As I’ve stated before: Flex might become the Java of the rich user interface. Adobe is already following Sun’s example by open sourcing parts of the technology, but i think they’ll also need to opensource the runtime to create acceptance among all the developers who choose not to use Microsoft. On the other hand, the flex runtime is already available in 95% of all browsers, it remains to be seen if Microsoft can achieve this with Silverlight.

More info on silverlight:
* TechCrunch- Silverlight: The Web Just Got Richer,
* TechCrunch – Why Silverlight Is Important,
* Tim Sneath – Introducing Microsoft Silverlight, Silverlight screencasts,
* Microsoft “rebooted the Web” yesterday,
* Mix 07 Ray Ozzie Keynote – Winforms apps are dead,
* What is Silverlight, really?,
* Miguel de Icaza – Mix 07, Silverlight, Dynamic Languages Runtime and OpenSource,
* Is Microsoft Silverlight THE Flash Killer?.

Technology
Ben jij slim genoeg voor IT-eye