« Technorati at ETech | Main | Cocoon article in iX »
February 11, 2004
Mobile server applications with Cocoon
Now while you may have thought that the Mobitopians are somewhat gadget fixated, that's not the case. Some of us also build the "other side" using Open Source frameworks such as Apache Cocoon. This short article looks at the problems facing mobile operators and shows how the XML application platform is being used to solve them.
Mobile operators have two main things (well perhaps three) to worry about when designing and building their server-application:
- Integrating various data-sources (news, weather, ringtones, ..)
- Publishing out the data to a multitude of devices
- Doing it all as quickly as possible
Now that's the simple view. Of course they also need to integrate payment solutions, location based information, personalize what you see on your device and maintain some sort of statistic about who did what when and and and. But we'll keep to the simple stuff for the moment.
In the last few days there have been quite a few articles (such as here) on how more and more devices now support XHTML (or XHTML-MP) and how that format needs to be published out to new devices. But what you may forget is that there are still plenty of devices out there that also need to be supported - and they are all different in some way
As an example, in Germany, a mobile operator currently needs to support around 60 (sixty) different devices in total. (Anyone thinking mobile solutions are easy - go back and read that sentence again).
One way of doing that is to make sure your data flows through the application in a common format (say some XML variant) and is then be published out in the format the individual device needs.
So, if you have your data in say an XML markup, then it makes sense to use XSL Stylesheets to generate the output the device requires, based on a mapping on the server. Solutions built on Cocoon are able to recognize the device and choose the stylesheet accordingly. You do however still need to code the stylesheet yourself - but that can be done in hierarchial fashion so each specific device stylesheet really only contains the device stuff.

As shown in the above picture, Cocoon is a Java application (actually it is a servlet). Cocoon already comes with Jetty embedded in the distribution - or you can run it in any other servlet container.
Cocoon allows you to build your application functionality based on "component pipelines". Each component pipeline can be thought of as a function (i.e "get page weather") with the result of the pipeline being the actual format returned to the device (say an XHTML representation of the weather information). In order to build the pipeline you plug together available components and use an XSL stylesheet to format out your data. There are components already in Cocoon that will recognize the device for you and allow you to integrate data from external systems (such as news feeds etc.). This is especially easy if the external system returns some XML variant. Cocoon is an XML platform so all the data that "flows" through Cocoon has to be in XML. However there are also components in Cocoon that will allow you to plug in non-XML data storage (such as databases). If your system is not available, then you can develop and drop in your own component. New components can be added without having to recompile Cocoon, as all the pipeline and component definitions take place in an XML file, called the Sitemap.
Now all this pipeline and XSL stuff may make you think that Cocoon is slow, and indeed that's one of the first questions put to us when we suggest that Cocoon may be the right choice. However, performance is not a problem, due to the fact that Cocoon has an extensive caching system and indeed performance figures (actually done by a mobile operator) are quite impressive.
Cocoon offers more than just the basic publishing functionality. It includes a portal framework (that already supports JSR-168), server side flow control using scripting, a framework for forms input and validation and much more.
And best of all - it doesn't cost a penny and is available in source form. Now, the learning curve is steep at the beginning with lots of new stuff to learn. But anyone who has built and deployed a mobile application on Cocoon will tell you that it's worth it. Anyone interested in building mobile applications with it will find plenty of additional information on the website, in the mailing-lists and on the wiki.
In Europe several mobile operators are already using Cocoon for their mobile offerings and more and more operators and information providers are showing increasing interest in the XML platform. So chances are that if you're surfing the mobile portals in the region, there's Cocoon in there somewhere.
Posted by Matthew at February 11, 2004 09:34 AM