O'Reilly logo

Java and XML by Brett McLaughlin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required