Creating an XML Configuration File

To try to put some of this knowledge into use, we look at using an XML-based configuration file for the XML-RPC classes we wrote in the last chapter. Certainly this is an excellent example of using XML for configuration information; we already have an XML parser available (used in the XML-RPC server), and it is possible that we could use this same configuration file for both clients and servers. Additionally, this configuration could be edited by XML IDEs instead of our having to create a proprietary interface for editing the file in a proprietary format. This can reduce the code that needs to be written for complex applications.

Before we start writing our configuration file, we need to define the information that will be in this file. The pieces of information we want to include are:

  • Port for the XML-RPC server to start on

  • Parser class for the server to use as a SAX driver

  • Handlers for the XML-RPC server

  • Class identifier

  • Class name

  • Hostname for the XML-RPC clients to connect to

  • Port for XML-RPC clients to connect to

  • Parser class for the server to use as a SAX driver

This provides all the information needed for both our clients and server to start without needing any user input other than the location of the XML configuration file itself. With these requirements in mind, let’s begin writing the XML configuration file.

Getting Started

Just as in the case of the EJB deployment descriptor, our file must include the standard XML prolog information. This is ...

Get Java and XML now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.