|
Constructing distributed applications using Xbeans
|
 |
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
[XML98], 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.
At the same time, standards groups representing almost every human endeavor
are agreeing upon XML
DTDs
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.
To the end of accessing XML data from different programming languages,
the W3C has defined the
DOM
standard
[DOM98]. 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 [JBeans] 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
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
[UNIX]; typed XML data flow, rather than untyped bytes. Xbeans
are also similar to CORBA event channels
[Mar96].

Figure 3
. 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.
Figure 4 illustrates a simple data exchange between
enterprises using Xbeans. The blue boxes represent different Xbeans.

Figure 4
. Data exchange between enterprises using
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.
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 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 interfaces are slight variations of the interfaces defined by IBM in their
AlphaWorks XML Productivity Kit for Java
[Alpha]. The
interfaces were changed to better support distributed applications.
The DOMListener interface, as given
in
Figure 5, defines a single operation, documentReady (DOMEvent evt), for passing the XML
document to the Xbean.
public interface DOMListener
extends EventListener {
public void documentReady(
DOMEvent evt)
throws XbeansException;
}
Figure 5
. The DOMListener interface
The DOMSource interface, as given
in
Figure 6, 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.
The DOMSource 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.
public interface DOMSource {
public void setDOMListener(
DOMListener DOMListener);
public DOMListener getDOMListener();
}
Figure 6
. DOMSource interface
Source and sink Xbeans
As illustrated in
Figure 7, 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 7
. 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 8
. 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 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
[VA], Inprise's JBuilder
[IJB], Symantec's Visual Cafe
[SVC],
FreeBuilder
[FBJ] or NetBeans
[NBDS],
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
[Xbeans] 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 as any 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 |