O'Reilly logo

Java and XML, Second Edition 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

Putting the Load on the Server

As instructional as the “hello” example has been in demonstrating how to use XML-RPC with Java, it isn’t very realistic. In addition to being a trivial example, the server is not very flexible and the handler itself doesn’t give any indication of how a practical XML-RPC handler might operate. Here I’ll try to give an example of using XML-RPC in a production environment by increasing the usefulness of the handler and the usability of the server. While it’s not code you might add to your current project, this example begins to demonstrate how XML-RPC might be of use, and how to build applications that can use XML-RPC but are not limited by it.

A Shared Handler

The HelloHandler class was simple, but useless in a practical application. Most XML-RPC uses relate to letting events occur on a server that is more suited for complex tasks, while allowing a thin client to request procedures to be executed and then use the returned results. In addition, it is possible that part or even all of the computations needed to respond to a request can be done in advance; in other words, the handler class may be running tasks and ensuring that results are already available when a method call comes in. As a Java coder, threads and shared instance data should leap to your mind. Here I’ll take a look at a very simple Scheduler class to illustrate these principles.

The scheduler should allow clients to add and remove events. Clients can then query the scheduler for a ...

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