![]() |
|||
![]() ![]() |
![]() |
|
![]() |
A word about mapping Java objects to tabular data in tables is necessary. Java classes may or may not extend (inherit from) another class. We can simply map the data members of a class to corresponding fields of a table if the class is not extending another. In this case, each record of the table represents an instance of the class. We call them persistified objects. A design choice which is left to the developer is made when a class extends another class. Either an instance of this class is mapped to a row in two different tables (one table per class) or it is mapped to only one table. In the latter case, the tables rows contain all the fields of the base class plus those of the inherited class. This second approach can be more efficient because it does not require joining multiple tables when trying to access the persistified objects. Figure 8-3 shows how to map simple objects to a table.
Figure 8-3 illustrates the parts of a persistified object:
To summarize, persistification occurs in the middleware and provides a longer lifetime to application-essential objects. Now it is time to discover a few ways to have transparent access to persistified Java objects. Java Remote Method InvocationJava RMI is a Java-to-Java remote object technology similar to remote procedure calls (RPC). It allows you to create distributed applications in which the methods of Java objects may be invoked from programs running on other virtual machines, at other locations of the network. RMI may solve the issue of accessing middleware object instances from clients. It is light, reliable, and works over TCP/IP (Transmission Control Protocol/Internet Protocol) and the Internet. How can it be implemented in our three-tier architecture? Java clients must obtain a reference to the remote object that resides in the middleware. RMI provides a bootstrap naming service mechanism for that purpose, which is Uniform Resource Locator (URL)-based. Clients obtain references to registered remote objects and then invoke methods on these objects. Parameters pass as method arguments, as is usual with any method. Using Javasofts object serialization technique, the RMI protocol does the marshaling and unmarshaling to convert Java types to a stream of bytes and this stream of bytes back to Java types. The RMI wire protocol transmits this stream of bytes on networks. Simple, isnt it? An example of a Java application using RMI is found in Chapter 10. Other TechniquesOther techniques are usable as a reliable software bus between clients and middleware. CORBA (Common Object Request Broker Architecture), defined by the Object Management Group (OMG), is a complete architecture for distributing objects. It is the most serious, consistent, and robust approach to distributed computing available. Many vendors already have CORBA-compliant products ranging from mainframe-class to PC-class. Products that comply with the CORBA 2.0 standard are interoperable, which means that they may be used in mixed environments. They can use a large number of network transport protocols including TCP/IP, which is used on the Internet. (IIOP, which stands for Internet Inter-ORB Protocol, is an implementation of GIOP, the Generic Inter-ORB Protocol, and works with TCP/IP.) State-of-the-art administration, integration, and development tools are usually bundled with CORBA software, as is the case with SunSoft Solaris NEO. Joe Joe is Suns solution to enable Java applications and applets to connect to CORBA environments such as Solaris NEO. It includes a Java Object Request Broker (an ORB), which connects applets to remote NEO objects running on any machine across the Internet. Networked objects may then be used from applets and applications. OMGs Interface Definition Language (IDL) can generate Java class stubs. IDL files are standard CORBA object interface files and provide language independence. The distributed objects may be implemented in a variety of languages such as C and C++, but Java is used because the database access is through JDBC on the middle tier. SummaryThis chapter discussed an alternative to the two-tier model. Using the Java Remote Method Invocation, it is possible to distribute objects across software tiers while providing an ideal place for the application logic. The topics discussed were:
The next chapter discusses design issues for the Internet and intranet, as well as possible implementation choices.
|
![]() |
|