-->The portability and scalability of Java and XML make them ideal for addressing this issue in order to flexibly meet the changing needs of Web applications and Web services. SAX (simple APIs for XML), DOM (Document Object Model), XSL (extensible Stylesheet Language), XSLT (XSL Transformations), S OAP (Simple Object Access Protocol), and BML (Bean Markup Language) is the relevant technology in the XML domain. This article brings together the lightweight and scalable Java and XML benefits, but does not require developers to understand the relevant technologies described above.
Use remote method Invocation (RMI) In a Java distributed application instead of directly using the underlying socket or other network link code. EJB technology also frees developers from the underlying mechanisms of transaction,recovery, activation, and so on. Similarly, using the Javabean-xml mapping component of this article, developers do not have to deal directly with XML-related APIs.
-->
Compilation of components
The Beanxmlmapping component implements the conversion from JavaBean to XML files. With the JavaBean introspection mechanism, XML Parser and Dom APIs, you can write a ToXml () method to implement transformations from JavaBean to XML files, and the FromXml () method to implement transformations from XML files to JavaBean.
Listing 1 shows a possible implementation of the beanxmlmapping component. The Jox (Java Objects in XML) class library is used in the program. Of course, you can also use other APIs to implement the Beanxmlmapping component, where Jox is chosen because it is simpler and reusable.
List 1 beanxmlmapping components
Import com.wutka.jox.*;
Import Java.io.ByteArrayInputStream;
Import Java.io.ByteArrayOutputStream;
Import java.io.IOException;
public class Beanxmlmapping {
/**
* Retrieves a Bean object for the
* Received XML and matching Bean class
*/
public static Object FromXml (String XML, Class className) {
Bytearrayinputstream xmlData = new Bytearrayinputstream (Xml.getbytes ());
Joxbeaninputstream joxin = new Joxbeaninputstream (xmlData);
try {
Return (Object