Friday, February 28, 2014

WSO2 ESB Performance Round 7.5

WSO2 has published latest performance round testing of the WSO2 ESB known as WSO2 ESB Performance Round 7.5

Following are some of the stats related to the test conducted with WSO2 ESB 4.8.1.

It indicates relative performance metrics with number of leading open source ESB's.

Numbers clearly indicate WSO2 ESB outperforms other open source ESB's listed.

Saturday, February 8, 2014

The history of Unix and Linux

In this post I thought of sharing the history of Unix and Linux in a bullet list for curious people who want to know what has been the history of Unix/Linux in a brief list rather than reading a huge chapter of a classic book.
  • The first UNIX implementation was developed in 1969 (the same year that Linus Torvalds was born) by Ken Thompson at Bell Laboratories, a division of the telephone corporation, AT&T. It was written in assembler for a Digital PDP-7 mini-computer

Ken Thomson

PDP-7 (Which is under reconstruction)

  • In 1970, UNIX was rewritten in assembly language for a newly acquired Digital PDP-11 minicomputer


  • A short time later, Dennis Ritchie, one of Thompson’s colleagues at Bell Laboratories and an early collaborator on UNIX, designed and implemented the C programming language (The language that almost all the modern languages are derived from). C followed an earlier interpreted language, B. B was initially implemented by Thompson and drew many of its ideas from an even earlier programming language named BCPL

Dennis Richie

  • First edition of Unix - By 1971, UNIX was running on the PDP-11 and already had a FORTRAN compiler and versions of many programs still used today, including ar, cat, chmod, chown, cp, dc, ed, find, ln, ls, mail, mkdir, mv, rm, sh, su, and who.
  • Second Edition, June 1972: By this time, UNIX was installed on ten machines within AT&T.
  • Unix implemented in C by Ken Thomson and Dennis Richie in 1973
  • Third Edition, February 1973: This edition included a C compiler and the first implementation of pipes.
  • Fourth Edition, November 1973: This was the first version to be almost totally written in C.
  • Fifth Edition, June 1974: By this time, UNIX was installed on more than 50 systems.
  • Sixth Edition, May 1975: This was the first edition to be widely used outside AT&T.
  • Then, the Unix OS is distributed to Universities with source code.
  • January 1979 saw the release of Seventh Edition of UNIX. This release also contained a number of new tools, including awk, make, sed, tar, uucp, the Bourne shell and a FORTRAN 77 compiler. The release of Seventh Edition is also significant because, from this point, UNIX diverged into two important variants: BSD and System V
  • Bjarne Stroustrup developed a language which is an extension of C language, originally name as "C with Classes"

Bjarne Stroustrup

  • Many new tools and features were developed at Berkeley, including the C shell, the vi editor, an improved file system (the Berkeley Fast File System), sendmail, a Pascal compiler, and virtual memory management on the new Digital VAX architecture.
  • Under the name Berkeley Software Distribution (BSD), this version of UNIX, including its source code, came to be widely distributed. The first full distribution was 3BSD in December 1979. (Earlier releases from Berkeley BSD and 2BSD were distributions of new tools produced at Berkeley, rather than complete UNIX distributions.
  • In 1982, breakup of monopoly between AT&T and the US government on telephone system. This led AT&T to market and sell Unix. This resulted in the release of System III (three) in 1981. System III was produced by AT&T’s UNIX Support Group (USG)
  • In 1983, "C with Classes" was renamed as C++
  • In 1983, the Computer Systems Research Group at the University of California at Berkeley released 4.2BSD. This release was significant because it contained a complete TCP/IP implementation, including the sockets application programming interface (API) and a variety of networking tools. 4.2BSD and its predecessor 4.1BSD became widely distributed within universities around the world. They also formed the basis for SunOS (first released in 1983), the UNIX variant sold by Sun. Other significant BSD releases were 4.3BSD, in 1986, and the final release, 4.4BSD, in 1993.
  • The first release of System V (five) followed in 1983, and a series of releases led to the definitive System V Release 4 (SVR4) in 1989, by which time System V had incorporated many features from BSD, including networking facilities. System V was licensed to a variety of commercial vendors, who used it as the basis of their UNIX implementations.
  • In addition to the various BSD distributions spreading through academia, by the late 1980s, UNIX was available in a range of commercial implementations on various hardware. These implementations included Sun’s SunOS and later Solaris, Digital’s Ultrix and OSF/1 (nowadays, after a series of renaming and acquisitions, HP Tru64 UNIX), IBM’s AIX, Hewlett-Packard’s (HP’s) HP-UX, NeXT’s NeXTStep, A/UX for the Apple Macintosh, and Microsoft and SCO’s XENIX for the Intel x86-32 architecture.
  • In 1985, Richard Stallman founded the Free Software Foundation (FSF), a nonprofit organization to support the GNU project as well as the development of free software in general.
Richard Stallman
  • In 1987, Andrew Tanenbaum, a university professor in Holland created a Unix-like operating system named Minix. This was merely for academic purpose.

Andrew S. Tanenbaum

  • Well-known programs were produced by the GNU project such as Emacs text editor, GCC (originally the GNU C compiler, but now renamed as the GNU compiler collection, comprising compilers for C, C++, and other languages),, the bash shell, and glibc (the GNU C library).
  • POSIX.1 (or more specifically POSIX 1003.1) became an IEEE standard in 1988
  • Release of GNU General Public License (GPL) in 1989
  • FIPS 151-1 was published (Federal Information Processing Standard). This standard required certain optional features of POSIX.1
  • In 1989 (XPG3) X/Open Portability Guide Issue 3 was released. This standard was also based on POSIX.
  • ANSI C standardization led to C89
  • FIPS 151-2 aligned with the 1990 ISO edition of POSIX.1 (FIPS was withdrawn in 2000)
  • By 1990, a complete Unix system was ready; except the most important kernel. But, The GNU project had started work on an ambitious kernel design, known as the GNU/HURD, based on the Mach microkernel. But it was far from complete.
  • POSIX adaptation for ISO standard in 1990 (ISO/IEC 9945-1:1990)
  • Version 2 of the license, released in 1991
  • In 1991, Linus Torvalds, creating the Linux kernel, which is inspired by Minix.

Linus Torvalds

  • XPG4 standard was released in 1992
  • XPG4 version 2 in 1994 - This incorporated some important parts of AT&T’s System V Interface Definition Issue 3
  • By March 1994, the developers were able to release version Linux 1.0. Linux 1.2 appeared in March 1995, Linux 2.0 in June 1996, Linux 2.2 in January 1999, and Linux 2.4 in January 2001. Work on the 2.5 development kernel began in November 2001, and led to the release of Linux 2.6 in December 2003.
  • In 1995 Single UNIX Specification (SUSv1) was formulated by combining XPG4 version 2, X/Open Curses Issue 4 version 2 specification, and the X/Open Networking Services (XNS) Issue 4 specification. This was also called UNIX 95 standard.
  • In 1996, an Organization name 'The Open Group" was formed by merging X/Open and the Open Software Foundation (OSF). Nearly all key companies in the Unix domain are members of this organization
  • SUSv2 in 1997 (This is also occasionally referred to as UNIX 98 and XPG5)
  • The first C++ standard was ratified in 1998 and is known as ISO/IEC 14882:1998
  • Second C language standard led to C99
  • In 2001, POSIX 1003.1-2001 (Also known as SUSv3) in 2001. This then became an ISO standard namely ISO/IEC 9945:2002
  • C++ standard was amended with a Technical Corrigendum in 2003 an is known as ISO/IEC 14882:2003
  • SUSv4 and POSIX.1-2008 in 2008
  • The third C standard was published in 2011. This standard is know as C11
  • The next C++ standard was ratified in 2011. This standard is known as C++11

Tuesday, February 4, 2014

Reading XML with Java DOM API

Let's learn how to read an XML file with Java DOM API. There are other API's which we can use to parse and manipulate XML files apart from Java DOM API, such as JAXP. But Java DOM API is very simple and in my opinion any Java developer needs to know DOM API regarless of why he/she need to choose any other API.

Ok.. Let's say we need to parse the following XML file.
<?xml version = "1.0"?>

    <contact type="sender">
        <name>  Jane Doe  </name>
        <address1>Box 12345</address1>
        <address2>15 Any Ave.</address2>
        <flag gender="F" age="23">
    <contact type="receiver">
        <name>John Doe</name>
        <address1>123 Main St.</address1>
        <flag gender="M">
    <salutation>Dear Sir:   </salutation>
    <paragraph>It is our privilege to inform you about our new databasemanaged with XML. This new system allows you to reduce theload on your inventory list server by having the client machineperform the work of sorting and filtering the data. </paragraph>
    <paragraph>Please visit our website for availability and pricing.   </paragraph>
    <closing>Sincerely, </closing>
    <signature>Ms. Jane Doe </signature>
Ok... Shall we start looking into Java code that will read content of this XML?
package xmlreading;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class XmlReading {
    public static void main(String[] args) {
        try {
            File xmlFile = new File("letter.xml");
            DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
            Document document = documentBuilder.parse(xmlFile);
            Element documentElement = document.getDocumentElement() ;
            NodeList rootLists = documentElement.getElementsByTagName("contact");
            if(rootLists != null && rootLists.getLength() > 0) {
                for(int k = 0 ; k < rootLists.getLength() ; k++) {
                    Node contactNode = rootLists.item(k);
                    if(contactNode != null && contactNode.getNodeType() == Node.ELEMENT_NODE) {
                        Element nodeElement = (Element) contactNode ;
                        System.out.println("Contact type : " + nodeElement.getAttribute("type"));
                        // This is one way of reading with exact tag name
                        // Following wil help read the node name and it's content programmatically
                        NodeList childNodes = contactNode.getChildNodes();
                        if(childNodes != null && childNodes.getLength() > 0) {
                            for(int j = 0 ; j < childNodes.getLength() ; j++) {
                                Node chileNode = childNodes.item(j);
                                if(chileNode != null && chileNode.getNodeType() == Node.ELEMENT_NODE) {
                                    Element contactChileElement = (Element) chileNode ;
                                    System.out.println("Contact child : " + chileNode.getNodeName() + "  "
                                            + chileNode.getTextContent());
        } catch (ParserConfigurationException | SAXException ex) {
            System.err.println("error occurred");
        } catch (IOException ex) {
            System.err.println("error occurred : " + ex);
The output of the code is as below.
Contact type : sender
  Jane Doe
Box 12345
15 Any Ave.
Contact child : name    Jane Doe
Contact child : address1  Box 12345
Contact child : address2  15 Any Ave.
Contact child : city  Othertown
Contact child : state  Otherstate
Contact child : zip  67890
Contact child : phone  555-4321
Contact child : flag
Contact type : receiver
John Doe
123 Main St.

Contact child : name  John Doe
Contact child : address1  123 Main St.
Contact child : address2
Contact child : city  Anytown
Contact child : state  Anystate
Contact child : zip  12345
Contact child : phone  555-1234
Contact child : flag
To give a short insight of the code, we first create a File instamce with the XML file we need to parse. Then we create a DocumentBuilderFactory instance and then a DocumentBuilder from the factory method newDocumentBuilder(). Then we invoke the parse() method on DocumentBuilder, which will parse the XML and returns a Document object. Line 25 is not really needed, though, it's highly recommended. We can then invoke methods on Element instance; documentElement, to read data out.


Return a NodeList (which is a list of nodes) of all the nodes having the node name "contact". Then we iterate through each such node. And we can take a Node instance from iterating through each element in NodeList. We can determine the node type by getNodeType() method of Node instance. If it's of type ELEMENT_NODE. Node instance is of type Element. Element is a sub type of Node. Therefore we can invoke all the Node methods from Element instance as well.

I recomment you look at Java API documentation for complete reference of the Java DOM API. Hope you find this post a quick start to read XML. Enjoy your day!!!