Beruflich Dokumente
Kultur Dokumente
SCOPE
6.1 Distributed Application Design 6.1.1 Distributed Programming on Internet and Intranets 6.1.2 Distributed Computing Environment (DCE) 6.1.3 Distributed Component Object Model (DCOM) 6.1.4 Common Object Request Broker Architecture (CORBA) 6.1.5 Remote Method Invocation (RMI) 6.2 Java Distributed Object Model 6.2.1 Advantages 6.2.2 Disadvantages
6.3 Servlets 6.3.1 History 6.3.2 Introduction to Java Servlets 6.3.3 Java Servlet API 6.3.4 Creating a Servlet 6.3.5 Handling HEAD requests 6.3.6 init() method 6.3.7 Some important Servlet Methods 6.3.8 Communication between Applets and Servlets
Fig. 6.1 The components of a distributed application with Information Processing Layer at the Client machine
Client Machine
Server Machine
Fig. 6.2 The components of a distributed application with Information Processing Layer at the Server machine
6.1.1
Internet is the most popular network today. Today almost all transactions happen on the net. This requires the applications over the net to be distributed as well. On the net a client program is executed on multiple host computers. The client interacts with the server with the help of TCP/IP protocol. The server listens for the incoming requests on a well-known port. The server uses gateway programs or back-end servers to process the requests. Most of the environments today are at least Intranet aware. Intranet is the Internet that is organization wide. In the case of Intranets, applets are used in a web browser to interact with the Web server. The Web Server in turn can use Database server or File server to process the client requests. The approach used in Intranets is the client/server approach, but this approach can be used with Internet applications also. 6.1.2 Distributed Computing Environment (DCE)
The OSFs (Open Software Foundation) DCE (Distributed Computing Environment) is an industry-standard, vendor-neutral set of distributed computing technologies. It provides security services to protect and control access to data, name services that make it easy to find distributed resources, and a highly scalable model for organizing widely scattered users, services, and data. DCE runs on all major computing platforms and is designed to support distributed applications in heterogeneous hardware and software environments. DCE is a key technology in three of today's most important areas of computing: security, the World Wide Web, and distributed objects. Distributed systems are organized into cells. A cell is nothing but a group of processing resources, services, and users, that support a common function and share a common set of DCE services. For example, cells can be organized according to the departments in a company so that there is a different cell for finance, marketing, and manufacturing departments.
DCE comprises of services that reside on top of the operating system, forming middleware that allows organizations to distribute processing components and data across the enterprise. Middleware such as DCE insulates developers from the complexities of the underlying network and its transport mechanisms, and provides an environment that allows key services (such as security and naming) to be integrated into distributed applications. The services and technologies used within a DCE cell consist of the following: Directory Service Stores the name of the resources. Cell Directory Service or CDS supports naming within a cell and Global Directory Service or GDS supports naming across all cells. Distributed File Service (DFS) This service is optional and it provides seamless file system that operates across all computers within a cell. Distributed Time Service (DTS) This service is used to synchronize time across all computers in a cell. Security Service This service is used for authentication purposes and for controlling access across all computers in a cell. Remote Procedure Calls (RPC) RPC is implemented as a layer built on the top of TCP/IP transport layer and transparently performs connection management. It replaces TCP sockets as the basic mechanism for client/server communication. DCE Threads DCE threads are similar to Java threads. Because DCE is independent of the operating system and network, it enables interaction between clients and servers in virtually any type of environment an organization may have in place. 6.1.3 Distributed Component Object Model (DCOM)
DCOM (Distributed Component Object Model) is a product by Microsoft and is used for developing distributed applications. DCOM has a long history attached to it. DCOM is essentially distributed COM. Therefore, to understand DCOM let us first see what is COM. It all started with OLE (Object Linking and Embedding) technology that was used to support compound documents. A compound document is one that is a product of multiple applications. COM was a solution to early problems in OLE. COM is different from DCE in its design approach. DCE is procedure-oriented whereas COM is object-oriented. Note that COM is not a language but a model on which applications can be built. Thus any programming language can be used with COM to create distributed applications. COM objects are instances of classes and are organized into interfaces. An interface is a collection of methods. The best thing about COM is that it abstracts the user away from the implementation details and presents a common interface to all objects, but the objects could be implemented in different ways. COM library is the key to implementing this common interface between objects. This library provides a directory of all classes that are available on the system. When one COM object invokes another COM object, it first invokes the functions in the COM library. These functions are used to either create a COM object from its class or get a pointer to its interfaces. COM runtime process helps the COM library in implementing its functions.
DCOM is nothing but distributed COM over multiple computers. It allows a COM object on one computer to access methods of another COM object on some other machine. DCOM makes this access mechanism transparent to the user. A remote object is accessed in exactly the same manner as the local object. The remote objects class must be registered in the local registry of the local system for a local object to access the methods of that remote object. The DCOM also works in the same way as the COM object with the only difference being that the remote object resides on some other machine. The local object invokes the methods of local COM library of the remote object it is trying to access. The COM library processes these function calls using local COM Runtime. The local COM Runtime gets in touch with COM Runtime of the remote machine and requests the creation of remote object or invocation of its method. If the request is acceptable to the remote system security, the request is processed by COM Runtime. Both of the COM Runtime communicate with each other using Object RPC mechanism. The most important feature of the DCOM is its support for application security. Its security is based on Windows NT security policy. Thus, one can permit what all methods of an object can be accessed by a user or by another object. Also there are a variety of encryption mechanisms that can be used to protect information when it is transferred from one machine to another. However, the biggest drawback of DCOM is that it gives good performance on Windows platform but mediocre performance on all the other platforms. 6.1.4 Common Object Request Broker Architecture (CORBA)
CORBA (Common Object Request Broker Architecture) is the most popular architecture for building distributed object-oriented applications. The factors that make it so popular are that it is an open standard, is not tied to a particular vendor, and thus, is most widely used. In CORBA, objects are accessible via Object Request Brokers (ORBs). This means that an object can access another objects methods via an ORB. The clients interface to ORB is written in IDL (Interface Definition Language), and is known as IDL stub. IDL provides a programming language-independent mechanism for describing the methods of an object. The server interface to ORB is known as IDL skeleton. The client object invokes the methods of the IDL stub corresponding to the remote object. The IDL stub passes these invocations to the ORB. The ORB in turn invokes the corresponding methods of the IDL skeleton. IDL skeleton invokes the methods of the server object implementation. The server object returns the result back to the IDL skeleton, which in turn passes them back to the IDL stub via ORB. The IDL stub then communicates the results back to the client object. This remote method invocation is depicted pictorially in fig. 6.3.
IDL Stub
IDL Skeleton
ORB
There are many factors in favour of CORBA that makes it the most widely used model for developing object-oriented distributed applications. The first and the most important thing is that it is an open standard and works on all platforms. Instead of having the earlier client/server approach where browsers were clients and web servers were servers, both clients and servers can be distributed in CORBA. CORBA implementation is language-independent. You just have to provide IDL interface to the object and the object can be written in any language. It is an international standard and is recognized by most of the software vendors. 6.1.5 Remote Method Invocation (RMI)
Now that you are familiar with various approaches that are used to develop distributed applications, you must be wondering why Java did not pick of any one of these services for method invocations. JavaSoft found that every approach had some or the other drawback in it and thus, there was a need of a mechanism that provides the capability to develop pure Java distributed applications. TCP sockets can be used for remote method invocations and Java supports them too. But developing these sockets is a big overhead. JavaSoft decided that the need was to design a low-overhead mechanism for distributed applications that would be something like CORBA. DCE is also used for designing distributed applications, but DCE is procedureoriented. Its RPC does not gel with Javas object-oriented distributed applications. DCOM is again a very popular product, but as mentioned in section 6.1.3, it does not give good performance on platforms other than Windows. Also, DCOM does not support Java objects fully. CORBA is an excellent approach and JavaSoft would have adopted it but for its IDL. A Java programmer will have to learn IDL to be able to develop distributed Java applications.