"This book will be invaluable for those who are serious about building distributed applications." -Michael Cook, Executive Director, Telcordia Technologies
Join the thousands of Java developers who relied on the previous editions of this book for expert guidance on programming with distributed objects and find out what's new in the world of Java and CORBA. The authors cover everything you need to write powerful, Web-integrated enterprise applications using the latest generation of Java ORBs. You can use this book both as a tutorial and as a reference guide to the latest CORBA specifications. With the help of in-depth coding examples, this exciting, fully updated new edition will show you how to:
Program with the Portable Object Adaptor (POA) Make the most of CORBA Naming, Trading, Event, and Notification Services Understand the Persistent State Service (PSS) and the CORBA Component Model (CCM) Plan security for Java/CORBA applications using firewalls and CORBA Security Design your applications for performance and scalability
The Companion Web site includes: Complete source code for all the examples in the book
Links to Java ORB Web sites
CHAPTER 1 Benefits of Java Programming with CORBA
This book brings together two of the major object models used in distributed computing: the Common Object Request Broker Architecture (CORBA) and Java. Each represents a different approach to distributed computing. On one hand, CORBA defines an abstract, inherently distributed object model and provides an infrastructure that enables invocations of operations on these objects as if they were local to the application using them. The implementations of objects can be located anywhere on a network and implemented in any programming language and on any operating system for which implementations of the CORBA infrastructure exist. The heterogeneity between the caller of the operation and its implementation is hidden by the CORBA infrastructure.
Java, on the other hand, is a regular, non-distributed, object-oriented programming language. Its main contribution to distributed computing is the introduction of platform-independent, low-level code that can be dynamically loaded and linked. When it is integrated with World Wide Web protocols and browsers, it results in what are known as applets. In this approach, instead of invoking a method on a remote object, the code for the class providing the method is transferred across the network and run locally, and then the method is invoked on a local object instance. Java has been extended with its own version of remote invocations also to support invocation-based distributed computing. This extension is known as Java Remote Method Invocation (RMI).
In 1999, Java was split into three different editions: the Java 2 standard Edition (J2SE), the Java 2 Micro Edition (J2ME), and the Java 2 Enterprise Edition (J2EE). A subset of the CORBA standard, the basic IDL-based communications mechanism, is part of J2SE. Furthermore, the J2EE standard includes Enterprise JavaBeans (EJB). EJB is a component model for distributed Java programming. The EJB specification mandates RMI as the interface for communication between objects. The initial specification did not define a specific transfer protocol. For the 2.0 version of EJB, CORBA's Internet Inter-ORB Protocol (IIOP) has been selected as the protocol for ensuring interoperability. That makes EJB a component model on top of a Java/CORBA foundation.
Java and CORBA converge when a mapping is defined from CORBA's interface definition language, OMG IDL, to Java. When combined with a run-time system that supports this language mapping, the result is a Java Object Request Broker (Java ORB). For the remainder of this chapter we discuss this combination of the two paradigms. We explain the advantages of Java for CORBA users and the advantages of CORBA for Java users in sections 1.1 and 1.2. In section 1.3, we also explain the relationship between Java ORBs ands RMI.
1 .1 What Does Java offer CORBA Programmers?
The main reasons for using a Java language mapping OMG IDL can be broadly categorised into features unique to the Java programming language and features of Java as a development platform:
* Object-Oriented Language
* Portability across platforms
* Web Integration
* Component model
1.1.1 Object-Oriented Programming Language
Java ORBs provide the same functionality as any other ORB. The main language bindings offered by current ORB products are C++, C, COBOL, ADA and Smalltalk. In our experience, Java provides a cleaner approach programming than C++, with fewer memory management responsibilities, no pointers, a less confusing syntax, and simpler method resolution rules. Moreover, its language syntax and its object model blend well with IDL. In other words, the IDL language mapping defined by the OMG is conceptually straightforward, so Java programmers are faced with only a moderate set of extensions when compared to other languages.
Additionally, Java provides features not available in C or C-++, such as automatic garbage collection and integrated thread support. These features are generally desirable and particularly useful for distributed systems programming, as we shall see throughout this book.
1.1.2 Portability of Applications across Platforms
Java programs are highly portable due to the standardized byte-code representation generated by Java compilers. Wide industry support means that compilers and run-time systems for virtually any hardware platform and operating system are available, from smart cards to supercomputers. For improved support for this diversity of environments, Sun Microsystems provides three different editions of the Java 2 platform. The Micro Edition targets consumer devices such as pagers, PDAS, or even smart cards. The Standard Edition covers the traditional programming language features and JavaBeans, the Java component model. The Enterprise Edition provides a server-side component model and framework that together make up a Java Application Server.
The wide availability of the Java platform is a significant advantage over other programming languages because a single source code or compiled byte-code set will be usable on any platform without porting. This makes Java the ideal platform for component programming, as the deployment platform is not determined by hardware or operating systems; the Java platform is the deployment platform. Consequently, development and maintenance costs can be significantly reduced.
Java's portability also means that if your Java ORB is implemented entirely in Java, then it is automatically available on any system for which a Java platform exists. Many Java ORBs are indeed implemented entirely in Java. Another big plus of the Java platform is that it already contains a limited CORBA implementation: Java IDL is part of both the Standard and the Enterprise Edition of the Java 2 platform.
1.1.3 Web Integration
Java is often referred to as the programming language for the internet. What does this mean? Basically, it means Java integrates well with both web browsers and web servers and thus provides excellent support for the development of web based applications. For CORBA applications that need to be integrated with web infrastructure, Java is the natural choice.
The Java applet model allows execution of Java code embedded in a html page, directly from a web browser. Due to the varying support for Java in web browsers and the bandwidth limitation of modem connections, applets have had only limited success in Internet applications.