Comments
paul.nowak wrote: Matt, thanks for the comments. I made an error on the version of Plone. It's 2.5 Plone running on Zope 2.9x. In regards to the additional products, we have a skin installed and we have a product that we had custom developed for us that connects to a PostgreSQL database. We've looked at slow PostgreSQL queries causing problems and have not been able to find an issue. We've also tested for the case where the PostgreSQL server is down and have not been able to create an issue. We therefor...
Cloud Expo on Google News


2008 West
DIAMOND SPONSOR:
Data Direct
SOA, WOA and Cloud Computing: The New Frontier for Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
GOLD SPONSORS:
Appsense
User Environment Management – The Third Layer of the Desktop
Cordys
Cloud Computing for Business Agility
EMC
CMIS: A Multi-Vendor Proposal for a Service-Based Content Management Interoperability Standard
Freedom OSS
Practical SOA” Max Yankelevich
Intel
Architecting an Enterprise Service Router (ESR) – A Cost-Effective Way to Scale SOA Across the Enterprise
Sensedia
Return on Assests: Bringing Visibility to your SOA Strategy
Symantec
Managing Hybrid Endpoint Environments
VMWare
Game-Changing Technology for Enterprise Clouds and Applications
Click For 2008 West
Event Webcasts

2008 West
PLATINUM SPONSORS:
Appcelerator
Get ‘Rich’ Quick: Rapid Prototyping for RIA with ZERO Server Code
Keynote Systems
Designing for and Managing Performance in the New Frontier of Rich Internet Applications
GOLD SPONSORS:
ICEsoft
How Can AJAX Improve Homeland Security?
Isomorphic
Beyond Widgets: What a RIA Platform Should Offer
Oracle
REAs: Rich Enterprise Applications
Click For 2008 Event Webcasts
SYS-CON.TV
Top Links You Must Click On


Using Apache Tuscany SDO and JSF To Build Dynamic Web Forms
Assembling a very generic system

This was the challenge: Build a generic system that lets users compare data suppliers in different categories. The data to be compared is defined by XML Schemas, where new schemas will be frequently uploaded and existing schemas may be changed. Moreover, the schemas aren't specifically designed for this system, so system specific metadata can't be added as attributes.

Based on the schemas the data suppliers must be presented with standard HTML forms to enter in their own specific data. Alternatively the suppliers must be able to use a Web Service interface.

Overall the sum of the requirements demanded extreme flexibility and robustness of the system.

So basically we wanted something that could go from XSD/XML to HTML forms and back. We stumbled upon a few COTS products, but these weren't suitable. I know many of you will probably think XForms. XForms was what turned up most when searching for known ways to do such a thing. Not knowing XForms beforehand I just superficially skimmed the technology and concluded that it wasn't right for us for several different reasons - one of them being the flexibility the requirements demanded. This may be because we didn't examine it thoroughly enough.

Anyway, looking further we came upon EMF (Eclipse Modelling Framework) and started building a small prototype. EMF seemed rather complex and during a discussion in a newsgroup somebody recommended SDO and the Apache Tuscany SDO implementation, which is based on EMF.

It immediately caught our attention since it seemed to supply just what we needed through a much simpler API. Any issues we had were quickly resolved by the extremely friendly people behind Apache Tuscany via the user mailing list. And our proposals for new functionality were quickly implemented.

Now, let's get into some technical details. This article doesn't introduce SDO as such - for that I recommend the articles by Kelvin Goodson and Geoffrey Winn in earlier issues of JDJ (Volume 11, Issue 12).

SDO
With Apache Tuscany SDO you operate within certain helper contexts. You do your SDO work in a context and you can choose to use this one context for all your work and let it live throughout your application lifetime, or you can use as many contexts as you like. This can be useful when XML Schemas aren't static - even in the same namespace. Once an XML Schema has been defined the types are cached for easy access in your context. If an XML Schema changes (and still keeps the same namespace) you can just scratch the original context and create a new one. Of course it's never recommended to work with XML Schemas that way since it opens up millions of issues regarding schema instances (XML) and the version of the schema. It's recommended that you do your versioning using the namespace. Still it shows some of the flexibility of the Apache Tuscany SDO implementation.

Let's look at some examples of how to define an XML Schema as SDOs and how to load and save XML from them (see Listing 1). For simplicity's sake the examples are without enumerations or many-valued properties. All use Apache Tuscany SDO 1.0 Incubating (beta 1, but the final has just been released).

Okay, so following listing 1, we have got a hold of the SDO data object representing the type of the schema we're interested in. Before we continue let's just see how you can get to this point if you already have existing XML that you want loaded into the data object.

String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    + "<test:TestElementX xmlns:test=\"http://mytestnamespace\">"
    + " <test:SubElement1>1.0</test:SubElement1>"
    + " <test:SubElement2>Hello</test:SubElement2>"
    + "</test:TestElementX>";
XMLDocument xmlDoc = context.getXMLHelper().load(xml);
rootDataObject = xmlDoc.getRootObject();

At this point you can choose to extract XML from the data object. This will be more relevant once we've altered the data object, but this is how it can be done:

ByteArrayOutputStream baos = new ByteArrayOutputStream();
xmlDoc.setEncoding("UTF-8");
try {
    context.getXMLHelper().save(xmlDoc, baos, null);
} catch (IOException e) {
    e.printStackTrace();
    System.exit(-1);
}
System.out.println(baos.toString());

If you haven't already got hold of the XMLDocument, it can be created like this:

XMLDocument xmlDoc = context.getXMLHelper().createDocument(dataObject, namespace, "TestElementX");

Before we continue to work with the root data object, let's take a brief look at how we can make any of this useful in a browser.


About Christian Landbo Frederiksen
Christian Landbo Frederiksen is a senior consultant in Ementor Denmark and has worked with Java and J2EE since 2000. He holds an M.Sc. in IT from the IT University of Copenhagen and a B.Sc. in computer science from the University of Copenhagen. He is a SCJP, SCJD and SCWCD.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

is the source code for this article available?


Your Feedback
Christian Schuhegger wrote: is the source code for this article available?
Enterprise Open Source Magazine Latest Stories . . .
This is a deal that has been around for all of this year, and I know the NYC-based guy charged with pulling the technical pieces together. He has been looking at software platforms for months and separating contenders from pretenders based on the criteria he's established. To my knowle...
3Leaf Systems, the well-funded start-up, dropped its fig leaf Tuesday and took a running jump into the pools of memory, I/O and cache that it can construct and deconstruct at will based on the application, creating scale-up shared-memory SMP systems the likes of mainframes, proprietary...
Funambol, a provider of open source mobile cloud sync and push email for billions of phones, today announced it has acquired Zapatec, Inc., a leader of AJAX web 2.0 frameworks. The acquisition enables Funambol to uniquely address the industry pervasive device fragmentation challenge th...
Plone and Drupal are two leading open source Content Management Systems (CMS). Both were recognized in the 2009 Open Source CMS awards, run by Packt Publishing. Both also have large installed bases and large developer communities. This is made evident by some quick searching on Googl...
SOASTA, a provider cloud testing, today announced that performance engineers can now build web application tests in Apache JMeter, the most popular open source load testing tool, and run them in SOASTA's Global Test Cloud. Deploying JMeter tests to the Cloud has been a complex, time-co...
Yahoo! Inc. (Nasdaq:YHOO), a leading global Internet company, took its second major step in five months towards open-source cloud computing today, debuting an open source version of Traffic Server, a high performance application server for builders of cloud services. Traffic Server ena...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON Featured Whitepapers
ADS BY GOOGLE