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.
At the same time, standards groups representing almost every human endeavor are agreeing upon XML Document Type Definitions (DTDs) for exchanging data. One of many examples is the International Press Telecommunications Council; it has defined an XML DTD allowing "news information to be transferred with markup and be easily transformed into an electronically publishable format." 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.
To the end of accessing XML data from different programming languages, the w3c has defined the Document Object Model (DOM) 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 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 Figure 1, an Xbean consumes XML as input, processes it in some fashion and then produces XML as output.
Figure 1. 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, figure 1 is not precise. Figure 2 shows the Xbean processing more precisely.
Figure 2: Xbeans consume and produce XML as DOM Documents.
As shown in Figure 3, Xbeans are connected to each other forming a channel. 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.
Figure 3. Xbeans are connected together into channels.
For now assume that only a single Xbean consumes the output of the previous; later we will describe an Xbean that acts as a parallelizer.
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.
Figure 4: Data exchange between enterprises using Xbeans.
Figure 4 illustrates a simple data exchange between enterprises using Xbeans. The blue boxes represents different Xbeans.
Each Xbean is configured appropriately. The accessor Xbean is configured to perform a particular SQL query and represent the result as an XML document. The translator Xbean is configured to translate the incoming XML document into an XML document that conforms to the agreed upon DTD for exchanging data. The sender and receiver Xbeans are configured to cooperate to transport the data.
At the enterprise that receives the data, a configured translator translates the data from the agreed upon DTD to a DTD that more closely matches the native schema. Finally the accessor is configured with an SQL query that stores the incoming data appropriately.
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.
To be an Xbean, at least one of two simple 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 DOMListener interface defines a single simple operation, documentReady(DOMEvent evt), for passing the XML document to the Xbean.
The DOMSource interfaces 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. While the DOMSource interface supports the addition of multiple listeners, most Xbeans only directly support the registration of a single listener. The parallelizer Xbean supports multiple listeners.
Source and Sink Xbeans
An Xbean that implements the DOMSource interface and uses the DOMListener interface is called a "source Xbean", that is it is a source of XML data.
Figure 5. A "source Xbean" implements the DOMSource interface and uses the DOMListener interface.
An Xbean that implements the DOMListener interface is called a "sink Xbean", that is it receives XML data.
Figure 6. 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 figure 2.)
Configuring Xbeans into Distributed Applications
Source Xbeans have a DOMListener property, as specified in the DOMSource interface. Thus connecting Xbeans simply means setting the property to be the next Xbean. Source Xbeans invoke documentReady on the next Xbean.
Xbeans are 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, Borland's JBuilder, FreeBuilder, NetBeans or some other configuration tool, a developer can visually instantiate, customize and connect Xbeans. Complete distributed applications can be created, often without writing any code.
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.
There are many useful generic Xbeans possible. Below are some generic Xbeans that are useful in many applications. The linked text describes each Xbean in more detail.
sender - receiver The sender and receiver Xbeans are configured to transport XML data over a network. Different implementations of the sender-receiver are possible, offering different qualities of service and using different transport mechanisms. The Xbeans Communication Pack includes sender-receiver implementations for HTTP, CORBA, Java Servlets, RMI, EJB and SOAP/Web Services. translator The translator Xbean translates an XML document into another XML document using XSLT. It includes a graphical Java Bean customizer for easily specifying the translation. sample The sample Xbean does nothing useful! It simiply passes the DOM document that it receives to the next Xbean in the channel. The source code for the sample Xbean serves as a starting point for developers of new Xbeans. Placing the sample Xbean in a channel has no effect. viewer The viewer Xbean displays the content of an XML document in a Swing tree. parser The parser Xbean converts an XML document in its textual format into a DOM document. The parser is customized with the name of the source of the document. serializer The serializer Xbean converts a DOM document and externalizes it into its XML textual format. The serializer is customized with the name of the target XML and formatting options. logger The logger Xbean logs every time an XML document passes through it. timer The timer Xbean records the time when it receives a DOM document and passes the document on to its listener. meter The meter Xbean records the size of a received DOM document and passes it on to its listener. parallelizer
The parallelizer Xbean receives a single DOM document and passes it to multiple listeners. For each listener, the parallelizer can be customized to specify whether the document is copied or shared among the listeners.
Note: the parallelizer is still being developed. It is not in the release of Xbeans Version 2.
The synchronizer Xbean receives multiple DOM documents and passes on another DOM document to its listener. The document can be one of the received documents or it can be the result of merging some or all of the received documents into a single document.
Note: the synchronizer is included in the release of Xbeans Version 2. It may be extended in the future to better support the parallelizer Xbean.
The accessor Xbean is configured to perform a particular SQL query and represent the result as an XML document. The accessor can also be configured to receive an XML document and store it according to an SQL query.
Note: the accessor Xbean still needs to be written. It is not part of the second release of Xbeans.
Document type specific Xbeans
Xbeans can 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 is an open source project. The goal of Xbeans.org is to provide a rich repository of freely available Xbeans. 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 as any useful Xbean imaginable.
Since Xbeans are Java Beans they can be configured into channels using any Java IDE with support for Java Beans. However, a simplified tool that only allows the configuration and customization of Xbeans is desirable since it will allow non-Java experts to configure and customize Xbeans into useful application channels.