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

Putting the Load on the Server

As instructional as our 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 we try to give examples of using XML-RPC in a production environment by increasing the usefulness of the handler and the usability of the server. These, while still not code you might want to immediately add to your current project, should at least begin to demonstrate to you how XML-RPC might be of use in your future projects, and how to build applications that can use XML-RPC but are not limited by it.

A Shared Handler

Our HelloHandler class was simple but useless in a practical application. Remember that we said 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 be executed and 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 we take a look at a very simple Scheduler class to illustrate these principles.

Our scheduler should allow clients to add ...

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