
Service industry hi-jinx aside, fulfilling orders and requests is, for the most part, a methodical process involving predictable parameters for input and output -- a task that's better suited to computers than human clerks. Once you've committed to going hi-tech, the question turns to software. Now, thanks to Jeeves, Java is one of your options.
In this column in our series on the Java API family, we introduce the Java Server API, also called, in somewhat quaintly British fashion, Jeeves. This API allows programmers to rapidly create connection-oriented server applications using a pre-defined architecture and providing the supporting object classes necessary.
The Server API is very much designed for the Web, although technically it can be used for any generic TCP/IP services. Jeeves itself is an HTTP or Web server that can be extended to include other protocols and applications. Each Web connection is processed by a servlet. This is similar in concept to a server application, but with minimal overhead and handling only the portions of the service workflow for which it is designed. Programmatically, the servlet is similar to an applet with the exception that there is no need for a graphical interface to the program. It is a piece of Java bytecode that can be downloaded from the network if necessary.
The Jeeves framework provides all the needs for handling multiple connections, managing a pool of servlets, keeping track of backlog, and dispatching service requests using a given set of classes.
Basically, it begins with the main server loading up, binding to a TCP/IP port, and starting a pool of servlets. The server resides on this port and accepts incoming connections, which are placed in a queue for processing by the servlets. Before passing this connection to an awaiting servlet, the server checks the servlet pool to see that enough servlets are available for future requests. The server can maintain a fixed pool of servlets or it can dynamically add and remove servlets from the pool to satisfy the requirements of the application.
The server will pass a request only to a servlet of the appropriate type for handling the request. There can be several pools of servlets, each a different type of request handler. For example, one servlet can handle HTML file requests, another can serve CGI requests, and still others can handle application-specific requests. Each servlet is designed to handle only its own area of service and thus does not need the huge overhead of traditional Web servers, where each server process needs to know how to handle everything. This makes for compact programs that can execute in a fast and efficient manner, supported by other programs that can handle other tasks more suited to them.