Building solutions   Table of contents   Indexes   Internet Electronic Data Interchange with XML and JAVA

 

Constructing distributed applications using Xbeans

Martin, Bruce
 
 Bruce  Martin
 Software Guru
  California 
 San Mateo 
 USA 
jGuru
jGuru,  2755 Campus Drive, Suite 130
San Mateo  California  94403 USA
Phone: (650) 577-8101 Fax: (650) 577-8102 email: martin@jguru.com web site: www.jguru.com
 Biography
 Bruce Martin - Bruce is one of the pioneers of distributed object computing. At Hewlett Packard Laboratories in the early 90s, he designed and implemented an interface definition language that became the basis for HP's original CORBA submission. At Sun Microsystems, he was one of Sun's CORBA architects and was the primary author of five of the OMG's CORBA Services specifications. At Inprise Corporation, Bruce was an architect and developer of Inprise's first CORBA-based Java Application Server. Bruce has extensive practical experience with Java, XML and the DOM.
 Bruce is now a software guru at jGuru. He is championing xbeans.org, an open-source project to create a repository of Java Beans that process XML and can be easily composed into distributed applications.
 Bruce has an excellent ability to convey both the conceptual basis of a technology and the practical nuts and bolts use of it. He has given talks around the world on distributed systems, advanced transaction models, object oriented programming, and distributed object technologies at both academic conferences and industrial events. Bruce has written many papers for conferences, journals, and books. He received Ph.D. and Masters degrees in Computer Science from the University of California at San Diego, and a Bachelors degree in Computer Science from the University of California at Berkeley.
 Abstract
 An Xbean is a software component that takes XML as input, processes it in some fashion and then passes XML on to the next Xbean. Xbeans are Java Beans. Java Bean technology supports the packaging, reuse, connection and customization of Java code. With the appropriate set of Xbeans and a Java Bean design tool, it is possible to build useful XML-based distributed applications with little or no programming.
 This paper describes how Xbeans can be easily composed into distributed applications, including data exchange, business to business, work flow and web channel applications. Xbeans.org is an open-source project to build a freely available repository of Xbeans.
 

Introduction

 The Extensible Markup Language , or XML, has emerged as the universal standard for exchanging and externalizing data. Software products of all kinds are being upgraded to "support XML." Typically this means they can import and export XML data.
 DTDs, Document Type Definitions 
 
At the same time, standards groups representing almost every human endeavor are agreeing upon XMLDTDs for exchanging data. One of many examples is the International Press Telecommunications Council" These vertical market standards will allow diverse applications to exchange data in unforeseen ways.
 But just defining standard representations for exchanging data is insufficient. The data need to be integrated with existing applications and databases and processed by programs written in some programming language.
 DOM, Document Object Model 
 
To the end of accessing XML data from different programming languages, the W3C has defined theDOM standard . The DOM is an application programmer's interface to XML data. It is available from many programming languages, including Java. Thus, Java programs can access XML data via the DOM API.
 Rather than structuring software that manipulates XML data as mammoth programs,software component technology allows developers to package smaller grained pieces of reusable functionality.Java Beans are software components that support the packaging, reuse, connection and customization of Java code. Design tools allow applications to be created by connecting and customizing existing Java Beans.
 

Xbeans

 Xbeans are Java Beans that manipulate XML data. With the appropriate set of Xbeans and a Java Bean design tool, it is possible to build useful distributed applications with little or no programming. (We will describe several applications later.)
 As illustrated in , an Xbean consumes XML as input, processes it in some fashion and then produces XML as output.
 
An Xbean consumes XML as input, processes it and then produces XML as output
 Xbeans consume and produce XML as DOM documents. That is, the data passed to Xbeans are not strings that need to be parsed by an XML parser, but an already parsed document object that is accessed via the w3c standard DOM API. As such, is not precise. shows the Xbean processing more precisely.
 
Xbeans consume and produce XML as DOM documents
 As shown in , Xbeans are connected to each other forming achannel . Data flow from one bean to another in a channel. This is very similar to a UNIX pipe ; typed XML data flow, rather than untyped bytes. Xbeans are also similar to CORBA event channels .
 
Xbeans are connected together into channels
 

Applications of Xbeans

 The Xbean paradigm is a very general data flow mechanism. XML describes structured data; Java provides the computation and control on the data. As described in detail later, Xbeans are functionally composable simply by supporting a couple of minimal interfaces.
 We now illustrate the power of the Xbean paradigm with a few distributed application examples:
 

Data exchange between enterprises

 Enterprises want to exchange data. Industry specific standards efforts are defining XML Data Type Definitions (DTDs). These DTDs represent the semantics and format of the data to be exchanged.
 Enterprises, however, have their data in their own databases defined by existing schema. That is, no two enterprises represent the same data in the same way. The idea is to access native data, translate it according to a standard DTD, transport it, translate it according to a native DTD and finally store it.
  illustrates a simple data exchange between enterprises using Xbeans. The blue boxes represent different Xbeans.
 
Data exchange between enterprises using Xbeans
 Each Xbean is configured appropriately. Theaccessor Xbean is configured to perform a particular SQL query and represent the result as an XML document. Thetranslator Xbean is configured to translate the incoming XML document into an XML document that conforms to the agreed upon DTD for exchanging data. Thesender andreceiver Xbeans are configured to cooperate to transport the data.
 At the enterprise that receives the data, a configuredtranslator translates the data from the agreed upon DTD to a DTD that more closely matches the native schema. Finally theaccessor is configured with an SQL query that stores the incoming data appropriately.
 

Purchase order

 An application of the data exchange given above is a purchase order. In this case the accessor Xbean is configured to perform an SQL query to obtain the data from various tables. The translator is configured to translate the data to conform to the standard DTD for a purchase order and so on.
 

Distributed work flow

 With a rich set of configured Xbeans that represent control flow and interact with users, Xbeans can be configured to create distributed work flow applications.
 

Web news channels

 Many web sites are now publishing news and other information as XML of various DTDs so that other web sites can “rebroadcast” it. Such distributed service could be implemented using the appropriate set of Xbeans.
 

Xbean interfaces

 To be an Xbean, at least one of twosimple Java interfaces must be supported. Any Java bean that implements at least one of these interfaces is an Xbean. The interfaces extend the Java event interfaces. The interfaces are slight variations of the interfaces defined by IBM in their AlphaWorks XML Productivity Kit for Java . The interfaces were changed to better support distributed applications.
 TheDOMListener interface, as given in , defines a single operation,documentReady (DOMEvent evt) , for passing the XML document to the Xbean.
 
TheDOMListener interface
public interface DOMListener
extends EventListener {
public void documentReady(
DOMEvent evt)
throws XbeansException;
}
 TheDOMSource interface, as given in , defines two operations,getDOMListener() and setDOMListener(DOMListener next) , for getting and setting the next Xbean, i.e. the Xbean that will receive the output of the Xbean. TheDOMSource interface does not directly support the addition of multiple listeners, most Xbeans only support the registration of a single listener to avoid hidden concurrency issues. The parallelizer Xbean supports multiple listeners, making the concurrency issues apparent at configuration time.
 
DOMSource interface
public interface DOMSource {
public void setDOMListener(
DOMListener DOMListener);
public DOMListener getDOMListener();
}
 

Source and sink Xbeans

 As illustrated in , an Xbean thatimplements theDOMSource interface anduses theDOMListener interface is called a "source Xbean", that is it is a source of XML data.
 
A "source Xbean" implements the DOMSource interface and uses the DOMListener interface
 An Xbean that implements theDOMListener interface is called a "sink Xbean", that is it receives XML data.
 
Any Java Bean that implements the DOMListener interface is a "sink Xbean"
 For maximum flexibility, most Xbeans are both sources and sinks of XML data. (See .)
 

Configuring Xbeans into distributed applications

 Source Xbeans have aDOMListener property, as specified in theDOMSource interface. Thus connecting Xbeans simply means setting the property to be the next Xbean. Source Xbeans invokedocumentReady on the next Xbean.
 Xbeans can be configured using the standard Java Bean mechanisms of property editors and customizers. Using a Java Bean design tool, such as IBM's Visual Age for Java , Inprise's JBuilder , Symantec's Visual Cafe , FreeBuilder or NetBeans , a developer can visually instantiate, customize and connect Xbeans. Complete distributed applications can be created, often without writing any code.
 Besides Java IDE design tools, more simplified tools that only allow the configuration and customization of Xbeans are desirable since they allow non-Java experts to configure and customize Xbeans into useful application channels.
 

Generic Xbeans

 Generic Xbeans process any kind of XML document using the DOM API. Many generic Xbeans are configured using the standard Java Bean mechanisms of property editors and customizers.
 

Document type specific Xbeans

 Xbeans can also be specific to a particular XML document type, that is it can be programmed to only work on XML documents whose type is known at compile time. While less general, they can still be part of a channel. Type specific Xbeans must check the type of the incoming XML document to ensure type integrity. Generic Xbeans can receive and process the output of a type specific Xbean.
 

Xbeans.org

 Xbeans.org is an open source project. The goal of Xbeans.org is to provide a rich repository of freely available Xbeans. The first version of Xbeans is available from the web site. Since Xbeans are clearly partitioned pieces of functionality with two well defined interfaces, independent and parallel development of Xbeans is greatly simplified. Unlike some open source projects, there is not a lot of coordination and project management required.
 Xbean.org is looking for contributors of the Xbeans outlined here as well asany useful Xbean imaginable.
 Bibliography
 
XML98 Extensible Markup Language (XML) 1.0 W3C Recommendation 10-February-1998. http://www.w3.org/TR/1998/REC-xml-19980210
 
NewsML NewsML - Markup for the third millennium, International Press Telecommunications Council web site: http://www.iptc.org
 
DOM98 Document Object Model (DOM) Level 1 Specification Version 1.0 W3C Recommendation 1 October, 1998. http://www.w3.org/TR/REC-DOM-Level-1
 
JBeans JavaBeans Specifications for Java 2, Sun Microsystems. http://java.sun.com/beans/glasgow
 
UNIX The UNIX Operating System. AT&T Bell Labs.
 
Mar96 Bruce Martin, Yeturu Aahlad, Mod Marathe and Chung Le. “Asynchronous Notifications Among Distributed Objects.” In Proceedings of the 2nd USENIX Conference on Object-Oriented Technologies and Systems, June 17, 1996, Toronto, Canada.
 
Alpha AlphaWorks XML Productivity Kit for Java.
 
VA IBM's Visual Age for Java Software Product, International Business Machines. http://www.ibm.com
 
IJB Inprise's Jbuilder 3.0 Software Product, Inprise Corporation. http://www.inprise.com/jbuilder
 
SVC Symantec's Visual Café Software Product, http://www.symantec.com
 
FBJ FreeBuilder Java IDE Software, http://www.freebuilder.org/index_org.html
 
NBDS NetBeans Developer Software Product. Sun Microsystems. http://www.netbeans.com
 
Mar00 Bruce Martin, “Build distributed applications with Java and XML” JavaWorld, February, 2000. http://www.javaworld.com/javaworld/jw-02-2000/jw-02-ssj-xml.html
 
Xbeans The Xbeans.org web site. http://www.xbeans.org

Building solutions   Table of contents   Indexes   Internet Electronic Data Interchange with XML and JAVA