Home > Articles > Web Services > XML

Middleware: A History of Objects, Components, and the Web

  • Print
  • + Share This
Transactional Component Middleware (TCM) is the dominant technology today for transaction processing applications. This chapter will give the background on this technology and how it's used today in various functions.
This chapter is from the book

This is the second chapter in our historical survey of middleware technology.

All the technologies described in Chapter 2 have their roots in the 1980s. At the end of that decade, however, there was a resurgence of interest in object-oriented concepts, in particular object-oriented (OO) programming languages. This led to the development of a new kind of OO middleware, one in which the requestor calls a remote object. In other words, it does something like an RPC call on an object method and the object may exist in another machine. It should be pointed out at once that of the three kinds of middleware discussed in Chapter 2—RPC/transactional, message queuing, and remote database access—OO middleware is a replacement for only the first of these. (The interest in OO has continued unabated since the first edition of this book, leading to a wide understanding of OO concepts. We therefore do not feel it necessary to describe the basic ideas.)

A notable example of OO middleware is the Common Object Request Broker Architecture (CORBA). CORBA is a standard, not a product, and was developed by the Object Management Group (OMG), which is a consortium of almost all the important software vendors and some large users. In spite of its provenance, it is one of those standards (the ISO seven-layered model is another) that has been influential in the computer industry and in academia, but is seldom seen in implementations. (A possible exception to this is the lower-level network protocol Internet Inter-ORB Protocol (IIOP), which has been used in various embedded network devices.) One reason for the lack of CORBA implementation was its complexity. In addition, interoperability among vendor CORBA implementations and portability of applications from one implementation to another were never very good. But possibly the major reason that CORBA never took off was the rise of component technology.

The key characteristics of a component are:

  • It is a code file that can be either executed or interpreted.

  • The run-time code has its own private data and provides an interface.

  • It can be deployed many times and on many different machines.

In short, a component can be taken from one context and reused in another; one component can be in use in many different places. A component does not have to have an OO interface, but the component technology we describe in this book does. When executed or interpreted, an OO component creates one or more objects and then makes the interface of some or all of these objects available to the world outside the component.

One of the important component technologies of the 1990s was the Component Object Model (COM) from Microsoft. By the end of the 1990s huge amounts of the Microsoft software were implemented as COM components. COM components can be written in many languages (notably C++ and Visual Basic) and are run by the Windows operating system. Programs that wish to call a COM object don't have to know the file name of the relevant code file but can look it up in the operating system's registry. A middleware known as Distributed COM (DCOM) provides a mechanism to call COM objects in another Windows-operated machine across a network.

In the second half of the 1990s, another change was the emergence of Java as an important language. Java also has a component model, and its components are called JavaBeans. Instead of being deployed directly by the operating system, Java beans are deployed in a Java Virtual Machine (JVM), which runs the Java byte code. The JVM provides a complete environment for the application, which has the important benefit that any Java byte code that runs in one JVM will almost certainly run in another JVM. A middleware known as Remote Method Invocation (RMI) provides a mechanism to call Java objects in another JVM across a network.

Thus, the battle lines were drawn between Microsoft and the Java camp, and the battle continues today.

The first section in this chapter discusses the differences between using an object interface and using a procedure interface. Using object interfaces, in any technology, turns out to be surprisingly subtle and difficult. One reaction to the problems was the introduction of transactional component middleware. This term, coined in the first edition of this book, describes software that provides a container for components; the container has facilities for managing transactions, pooling resources, and other run-time functions to simplify the implementation of online transaction-processing applications. The first transactional component middleware was Microsoft Transaction Server, which evolved into COM+. The Java camp struck back with Enterprise JavaBeans (EJB). A more detailed discussion of transactional component middleware is in the second section.

One issue with all OO middleware is the management of sessions. Web applications changed the ground rules for sessions, and the final section of this chapter discusses this topic.

3.1 Using object middleware

Object middleware is built on the simple concept of calling an operation in an object that resides in another system. Instead of client and server, there are client and object.

To access an object in another machine, a program must have a reference pointing at the object. Programmers are used to writing code that accesses objects through pointers, where the pointer holds the memory address of the object. A reference is syntactically the same as a pointer; calling a local object through a pointer and calling a remote object through a reference are made to look identical. The complexities of using references instead of pointers and sending messages over the network are hidden from the programmer by the middleware.

Unlike in earlier forms of middleware, calling an operation on a remote object requires two steps: getting a reference to an object and calling an operation on the object. Once you have got a reference you can call the object any number of times.

We will illustrate the difference between simple RPC calls and object-oriented calls with an example. Suppose you wanted to write code to debit an account. Using RPCs, you might write something like this (We've used a pseudo language rather than C++ or Java because we hope it will be clearer.):

Call Debit(012345678, 100) ;    // where 012345678 is the account
                                // number and 100 is the amount

In an object-oriented system you might write:

Call AccountSet.GetAccount(012345678)    // get a reference to
    return AccountRef;                   // the account object
Call AccountRef.Debit(100);              // call debit

Here we are using an AccountSet object to get a reference to a particular account. (AccountSet is an object that represents the collection of all accounts.) We then call the debit operation on that account. On the face of it this looks like more work, but in practice there usually isn't much to it. What the client is more likely to do is:

Call AccountSet.GetAccount(X) return AccountRef;
Call AccountRef.GetNameAndBalance(....);
...display information to user
...get action to call – if it's a debit action then
Call AccountRef.Debit(Amt);

In other words, you get an object reference and then call many operations on the object before giving up the reference.

What this code segment does not explain is how we get a reference to the AccountSet object in the first place. In DCOM you might do this when you first connect to the component. In CORBA you may use a naming service that will take a name and look up an object reference for you. The subtleties in using objects across a network are discussed in more detail in the box entitled "Patterns for OO middleware."

Patterns for OO middleware

All middleware has an interface, and to use most middleware you must do two things: link to a resource (i.e., a service, a queue, a database), and call it by either passing it messages or call functions. OO middleware has the extra complexity of having to acquire a reference to an object before you can do anything. Three questions come to mind:

  1. How do you get an object reference?

  2. When are objects created and deleted?

  3. Is it a good idea for more than one client to share one object?

In general, there are three ways to get an object reference:

  1. A special object reference is returned to the client when it first attaches to the middleware. This technique is used by both COM and CORBA. The CORBA object returned is a system object, which you then interrogate to find additional services, and the COM object is an object provided by the COM application.

  2. The client calls a special "naming" service that takes a name provided by the client and looks it up in a directory. The directory returns the location of an object, and the naming service converts this to a reference to that object. CORBA has a naming service (which has its own object interface). COM has facilities for interrogating the register to find the COM component but no standard naming service within the component.

  3. An operation on one object returns a reference to another object. This is what the operation GetAccount in AccountSet did.

Broadly, the first two ways are about getting the first object to start the dialogue and the last mechanism is used within the dialogue.

Most server objects fall into one of the following categories:

  • Proxy objects

  • Agent objects

  • Entrypoint objects

  • Call-back objects

As an aside, there is a growing literature on what are called patterns, which seeks to describe common solutions to common problems. In a sense what we are describing here are somewhat like patterns, but our aims are more modest. We are concentrating only on the structural role of distributed objects, not on how several objects can be assembled into a solution.

A proxy object stands in for something else. The AccountRef object is an example since it stands in for the account object in the database and associated account processing. EJB entity beans implement proxy objects. Another example is objects that are there on behalf of a hardware resource such as a printer. Proxy objects are shared by different clients, or at least look as if they are shared to the client.

A proxy object can be a constructed thing, meaning that it is pretending that such and such object exists, but in fact the object is derived from other information. For instance, the account information can be dispersed over several database tables but the proxy object might gather all the information in one place. Another example might be a printer proxy object. The client thinks it's a printer but actually it is just an interface to an e-mail system.

Agent objects are there to make the client's life easier by providing an agent on the server that acts on the client's behalf. Agent objects aren't shared; when the client requests an agent object, the server creates a new object. An important subcategory of agent objects is iterator objects. Iterators are used to navigate around a database. An iterator represents a current position in a table or list, such as the output from a database query, and the iterator supports operations like MoveFirst (move to the first row in the output set) and MoveNext (move to the next output row). Similarly, iterator objects are required for serial files access. In fact, iterators or something similar are required for most large-scale data structures to avoid passing all the data over the network when you need only a small portion of it. Other examples of agent objects are objects that store security information and objects that hold temporary calculated results.

An Entrypoint Object is an object for finding other objects. In the example earlier, the AccountSet object could be an entrypoint object. (As an aside, in pattern terminology an entrypoint object is almost always a creational pattern, although it could be a façade.)

A special case of an entrypoint object is known as a singleton. You use them when you want OO middleware to look like RPC middleware. The server provides one singleton object used by all comers. Singleton objects are used if the object has no data.

Call-back objects implement a reverse interface, an interface from server to client. The purpose is for the server to send the client unsolicited data. Call-back mechanisms are widely used in COM. For instance, GUI Buttons, Lists, and Text input fields are all types of controls in Windows and controls fire events. Events are implemented by COM call-back objects.

Some objects (e.g., entrypoint objects and possibly proxy objects) are never deleted. In the case of proxy objects, if the number of things you want proxies for is very large (such as account records in the earlier example), you may want to create them on demand and delete them when no longer needed. A more sophisticated solution is to pool the unused objects. A problem for any object middleware is how to know when the client does not want to use the object. COM provides a reference counter mechanism so that objects can be automatically deleted when the counter returns to zero. This system generally works well, although it is possible to have circular linkages. Java has its garbage-collection mechanism that searches through the references looking for unreferenced objects. This solves the problem of circular linkage (since the garbage collector deletes groups of objects that reference themselves but no other objects), but at the cost of running the garbage collector. These mechanisms have to be extended to work across the network with the complication that the client can suddenly go offline and the network might be disconnected.

From an interface point of view, object interfaces are similar to RPCs. In CORBA and COM, the operations are declared in an Interface Definition Language (IDL) file, as illustrated in Figure 3-1.

03fig01.gifFigure 3-1 Object middleware compilation and interpretation

Like RPCs, the IDL generates a stub that converts operation calls into messages (this is marshalling again) and a skeleton that converts messages into operation calls. It's not quite like RPCs since each message must contain an object reference and may return an object reference. There needs to be a way of converting an object reference into a binary string, and this is different with every object middleware.

Unlike existing RPC middleware, the operations may also be called through an interpretive interface such as a macro language. There is no reason that RPCs shouldn't implement this feature; they just haven't. An interpretive interface requires some way of finding out about the operations at runtime and a way of building the parameter list. In CORBA, for instance, the information about an interface is stored in the interface repository (which looks like another object to the client program).

In object middleware, the concept of an interface is more explicit than in object-oriented languages like C++. Interfaces give enormous flexibility and strong encapsulation. With interfaces you really don't know the implementation because an interface is not the same as a class. One interface can be used in many classes. One interface can be implemented by many different programs. One object can support many interfaces.

In Java, the concept of an interface is made more explicit in the language, so it isn't necessary to have a separate IDL file.

So why would you think of using object middleware instead of, say, RPCs? There are two main reasons.

The first is simply that object middleware fits naturally with object-oriented languages. If you are writing a server in C++ or Visual Basic, almost all your data and logic will (or at least should) be in objects. If you are writing your server in Java, all your data and code must be in objects. To design good object-oriented programs you start by identifying your objects and then you figure out how they interact. Many good programmers now always think in objects. Exposing an object interface through middleware is more natural and simpler to them than exposing a nonobject interface.

The second reason is that object middleware is more flexible. The fact that the interface is delinked from the server program is a great tool for simplification. For instance, suppose there is a single interface for security checking. Any number of servers can use exactly the same interface even though the underlying implementation is completely different. If there is a change to the interface, this can be handled in an incremental fashion by adding an interface to an object rather than by changing the existing interface. Having both the old and new interfaces concurrently allows the clients to be moved gradually rather than all at once.

  • + Share This
  • 🔖 Save To Your Account