Lesson 6 | Mapping of method signatures |
Objective | Describe mapping of operations in IDL interfaces |
Mapping of Method Signatures in Corba
To use an interface, you need to be able to use the operations defined in that interface. As stated previously, an IDL interface will map to a Java interface. Any operations in the interface will map to methods in the Java interface.
The return type and all parameters will map natively to Java types in accordance with the primitive type mappings.
By value
In CORBA the
in
parameters are all passed one way over the
wire[1], so they are all sent
by value[2].
In fact, because all communication is across the wire rather than in the same address space, all elements passed back and forth must be copied, and as such
pass by value[3].
In Java, all parameters are always by value, so this works well. All values are copied and push across to the server.
When the information about a parameter reaches the server process, it is reconstructed into a new object of the appropriate type, generated from the IDL in the language of choice. Any variable passed in as a parameter cannot have its local value changed during the processing of a remote method. Even if the parameter is an object reference (nonremote),
that object cannot be
side-effected[4] like in a normal local method call. The interface-method below illustrates the mapping of individual features of method signatures:
- All elements defined in a module are the same package
- The interface definition results in a class for the interface containing all the elements defined in the IDL interface.
- Each operation maps to a single method in the Java interface generated for the IDL interface.
- The return type of the operation maps to the return type of the method following the rules for primitive type mapping.
- The in parameters of the operation map, in order, to parameters of the sames names in the Java method signature.
- The type object in IDL is an object reference, and so maps to the object reference base type org.omg.CORBA.Object.
Simple Mapped Operations
Return value
The return value can be thought of as passed by value from the server instead of to the server. Any value the server passes back as a return value is copied and reconstructed in the local space of the client.
Any operation defined as oneway
maps to the Java interface exactly as if it was not declared oneway
.
The difference between a oneway
and a regular operation is how the stub handles the communication, not in the programming interface.
In the next lesson, you will learn how to describe the mapping of IDL operations with out
and inout
parameters.
Java Mapping - Quiz
Mapping Method Signatures - Exercise
[1]Wire: The communication socket between the servers where all communication is reduced to a byte stream.
[2]By value: The value of the parameter is copied, and so any changes to the value are made on the copy, not the original reference.
[3]Pass by value: The value of the parameter is copied, and so any changes to the value are made on the copy, not the original reference.
[4]Side-effected: In pass by value, the value of the parameter cannot change, but if it is an object reference, methods on that reference can still be called, even accessors and mutators. So the internal state of that object can be changed, even if the parameter cannot be made to reference a different object .