IDL Constructed Types   «Prev  Next»
Lesson 10

Java Mapping and Constructed types Conclusion

This module discussed IDL-to-Java mappings for all the IDL constructed types and how to use the resulting Java. This concludes our discussion of mapping. As you proceed in the course, you will use your mapping knowledge to implement the mechanisms and techniques that will occupy you for the rest of the course.

Review of module objectives

In this module, you learned how to:
  1. Describe how IDL structs, sequences, and enums map to Java
  2. Use the Java generated for structs, sequences, and enums
  3. Describe how IDL exceptions map to Java
  4. Use the Java generated for exceptions
  5. Describe how IDL unions and arrays map to Java
  6. Use the Java generated for unions and arrays

Glossary

No new glossary terms were introduced in this module.
In the next module, you will learn how to locate CORBA objects in your distributed system.

Operations are defined to raise one or more user exceptions to indicate application-specific error conditions. An exception definition can contain multiple data members to convey specific information about the error, if desired. For example, you might include a graphic image in the exception data in order to display an error icon.

Exception design guidelines

When you define exceptions, be sure to follow these guidelines:
  1. Exceptions are thrown only for exceptional conditions. Do not throw exceptions for expected outcomes. For example, a database lookup operation should not throw an exception if a lookup does not locate anything; it is normal for clients to occasionally look for things that are not there. It is harder for the caller to deal with exceptions than return values, because exceptions break the normal flow of control. Do not force the caller to handle an exception when a return value is sufficient.
  2. Exceptions carry complete information. Ensure that exceptions carry all the data the caller requires to handle an error. If an exception carries insufficient information, the caller must make a second call to retrieve the missing information. However, if the first call fails, it is likely that subsequent calls will also fail.
  3. Exceptions only carry useful information. Do not add exception members that are irrelevant to the caller.
  4. Exceptions carry precise information Do not lump multiple error conditions into a single exception type. Instead, use a different exception for each semantic error condition; otherwise, the caller cannot distinguish between different causes for an error.

The CORBA Interface Definition Language (IDL)

The CORBA IDL is a purely declarative language designed for specifying programming languages to be independent and operational. The interfaces are intended for distributed applications. The OMG specifies a mapping from IDL to several different programming languages including C, C++, Java, ADA, and SmallTalk. For each statement in the IDL there is a mapping to a corresponding statement in the programming language. For instance, all the primitive types in Java are supported. There is also provision to define new types such as structures. One of the main features of the CORBA IDL is that it is intended to capture the design of the server. In other words, the IDL is a language-independent representation of the server and therefore promotes an important concept of design portability.
As a result it is possible to write the client in one language and the server in another (by using IDL compilers for both languages) and thus promote inter-operability as well.

Data-Driven Science and Engineering