Minimal IT logo and link to home page
Research, training, consultancy and software to reduce IT costs
Home | About | Newsletter | Contact
Previous | Next Printer friendly
8 June 2010

XML-based programming 2: evolving a framework

By Andrew Clifford

An effective framework for XML-based programming is relatively easy to develop.

Last week I introduced my journey into XML-based programming. My initial idea was to use XML to pass data around the application in order to enforce good structure and to simplify programming, and not because I had a requirement to use XML to transfer data outside the application.

For lots of good reasons, I adopted Java as the core language for the application. There are excellent Java frameworks available, and I am very aware of the dangers of reinventing them (see stupidclever). However, I could not find a framework that achieved the XML-based separation that I wanted, so I developed my own.

The fundamental thing I wanted to achieve was for the code that manages the user interface to communicate with the business logic using XML documents. (All this XML is on the application server; it is not a web-services type interaction between a browser and the server.)

For complete flexibility, I wanted every aspect of the communication, including the specification of the function and any error conditions, to be within the XML documents. To achieve this, the framework uses a single application object to route requests to one of many service objects based on the name of the root element of the document. All function calls take the form:

    response =

The framework uses an XML configuration file to match the root element names with the classes that provide the corresponding service. The configuration document can also specify an initialisation document to be passed to each service, either on startup, or before the service is first used. This provides a point to initialise the resources required for each service.

To allow services to work together, the framework supports named global objects which the services can read and write. For example, this allows one service to read database connection information on initialisation, record this in an object, and share this with other services. In this way, the framework allows the development of tightly integrated applications from loosely coupled services which make no direct calls to each other.

Programming services is straightforward. There is a base Service class, from which specific service classes inherit. The base service class can be extended to provide common services, such as database connection management and security, greatly simplifying individual services. The framework includes helper classes for parsing requests and handling XML.

Using XML makes the application very flexible. The core framework supports:

  • In-memory calls using XML in character strings.
  • In-memory calls using parsed XML objects.
  • XML files on disk.
  • XML strings on the command line.
  • Simple batch-style scripts, by using a service which invokes other services on startup.

Of itself, the framework attempts no management of processes or threads of execution. However, it is well-behaved thread safe Java code, and can, for example, be used from within a Java-based web server such as Apache Tomcat.

The basic framework was relatively simple to develop. The core classes are around 350 lines of code. All additional functionality is provided as services that use these core classes.

Next week I will describe how this simple framework supports the requirements of complex applications very effectively, including web development, database handling, report production, and testing.

Next: XML-based programming 3: using the framework


To subscribe to the newlsetter, simply send an email to
Privacy policy

Subscribe to RSS feed

Latest newsletter:
Magical metadata

We use the term "metadata-driven" to describe IT solutions in which functionality is defined in data. Taking this to the extreme can provide unparalleled levels of speed, simplicity and versatility.
Read full newsletter

System governance

System governance helps you implement high-quality systems, manage existing systems proactively, and improve failing systems.

Try it for free!

Find out more