Building distributed Systems with Java and XML

Source: Internet
Author: User
Tags object model xml parser

Extensible Markup Language (XML) as a simple, neutral, readable representation of data has become increasingly popular, many software vendors announced "Support XML", meaning that their products will be able to generate or process XML data. XML is also seen as the best format for exchanging data between enterprises. It allows the enterprise to agree on the document type definition (DEFINITIONS,DTDS) or schema (schema) of the XML of the data being exchanged. These DTDs or schemas are independent of the database schema used by the enterprise.

This article will be used to study the construction of distributed systems for communication and processing of XML data between different computers, mainly for XML communication between Java applications running on different virtual machines.

XML communication

The World Wide Web Consortium (Wide) defines the syntax and semantics of XML in the XML specification in the Consortium. In order to process XML data, XML documents must be parsed. The consortium defines the Document Object Model (DOM), which is an interface for application programmers to process XML data. Dom already has implementations of many languages, including Java. Java applications can access XML data through the DOM API. The XML parser produces the DOM representation of the XML document.

Figure 1 illustrates a simple model of Java distributed applications that process XML documents. This model assumes that data can be obtained from a data source such as a relational database. The Java code processes the data and eventually produces a DOM representation, which is represented as a processor in the diagram.

The processor code passes the XML data represented by the DOM to the sender. The sender is the Java code that communicates with the recipient for XML data. The recipient Java code accepts the XML data, generates the data represented by the DOM, and transmits it to another processor. In short, the sender and receiver abstract The communication of the XML data represented by the DOM.

The sender and receiver are not executed on the same Java virtual machine. They are connected through the components of a distributed system. Both the receiver and the sender are both client and server, both of which transmit data in both directions.

Xbeans

As you will see, the three implementations of both the sender and receiver described in this article are implemented through Xbeans. Xbeans is a software component that accepts XML data as input, processes this input, and then outputs XML results to the next Xbeans. The input and output of Xbeans are XML DOM documents, that is, the strings that are passed to Xbeans are not parsed by the XML parser, but are parsed into document objects through the standard DOM API of the Consortium. Figure 2 illustrates a xbeans.

Xbeans is a javabeans that supports encapsulation, reuse, connectivity, and client-side Java code. With some of the appropriate Xbeans and JavaBeans design tools, we can build very useful distributed applications with very little coding. Xbeans from IBM's Java Development Toolkit for XML, a small number of modifications are made to make it more suitable for distributed applications. Xbeans can be obtained free of charge from www.Xbeans.org Open source projects.

Implementing Sender and Receiver

Here are three different ways to implement the sender and receiver in Java. Then make a simple analysis of each method.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.