Java Programming  «Prev  Next»
Lesson 10 Attributes
Objective Describe the mapping of IDL interface attributes in Java.

Mapping IDL Interface Attributes

Attributes in IDL are thought of as public instance variables of the remote object.
However, access to variables commonly differs from method calls in that accessing variables is accessing memory locations in the address space as directly as possible in the language. Because the remote object is, by definition, in a different address space, it cannot map to instance variables in Java. Accessors and mutators need to be created for each attribute so that the stub can turn around and call the server object remotely for the appropriate values.

  1. Accessor and Mutator: The object-oriented properties of encapsulation and information hiding imply that variables internal to an object should not be accessed directly. It is common practice to create a pair of methods, one to return the value of the variable (the accessor or getter method) and one to set the value of the variable (the mutator or setter).
  2. Getter and Setter: For each attribute, two overloaded methods in the stub and skeleton are created: one getter and one setter. In cases of read-only attributes, only the getter is generated. Both have the same name as the attribute name in the IDL. The Slide Show below illustrates how attributes work.



1) All elements defined in a module are in the same package
MyIDL.idl;
1) All elements defined in a module are in the same package

2) The interface definition results in a class for the interface containing all the elements defiend in the IDL interface.
MyIDL.idl;
2) The interface definition results in a class for the interface containing all the elements defiend in the IDL interface. The Java interface extends from the common object reference interface org.omg.CORBA.Object.

3) An attribute maps to two methods
MyIDL.idl;
3) An attribute maps to two methods

4) A readonly attribute maps to only the getter method.
MyIDL.idl;
4) A readonly attribute maps to only the getter method. The return value of the getter is the attribute type mapped according to the primitive mapping rules.

SEMrush Software

Package org.omg.CORBA Description

Provides the mapping of the OMG CORBA APIs to the JavaTM programming language, including the class ORB, which is implemented so that a programmer can use it as a fully-functional Object Request Broker (ORB).
The information in this section is information relevant to someone who compiles Interface Definition Language (IDL) files and uses the ORB to write clients and servers. The classes and interfaces described in this section can be put into four groups:
  1. ORB classes,
  2. Exceptions,
  3. Helper classes, and
  4. Holder classes.

The next lesson concludes this module.