Java Programming  «Prev  Next»
Lesson 7 Mapping methods with out and inout
Objective Describe the mapping of IDL operations with out and inout parameters.

Mapping Methods with out and inout in Corba

Not every operation you will want to declare will be satisfied by one return value or immutable parameters. The declarators
  1. in,
  2. out, and
  3. inout
refer to how the parameter is copied over the wire. Parameters marked as in are copied and reconstructed on the server. Parameters marked as out work just like return values, in that there is no information copied from the client, but a brand new object is copied from the server and reconstructed on the client.
Parameters marked as out work just like return values, in that there is no information copied from the client, but a brand new object is copied from the server and reconstructed on the client.
Parameters marked inout are just like having one in parameter and one out parameter. The in side parameter is copied and reconstructed on the server side. The server can do whatever it wants with the local copy or create a new one. It then sends the out side of the parameter back when the method returns. On the client side, a wholly new object is created, just like a return value, and the reference is replaced as the stub method returns.
In C++ or Pascal, where pass by reference or VAR parameters are allowed, the idea that the parameter reference is replaced with a new object reference or pointer is obvious. In Java, it requires a little work. The IDL-to-Java mapping creates, for each new class generated, a reference class so that objects can be passed by reference.

Mapped methods with holders

This holder class is simply a class named MyTypeHolder for every MyType created and has one public instance variable of type MyType named value.
The SlideShow below illustrates mapped methods with holders.

1) In and Out Parameters1 2) In and Out Parameters2 3) In and Out Parameters3 4) In and Out Parameters4 5) In and Out Parameters5 6) In and Out Parameters6 7) In and Out Parameters7
Mapped Methods with Holders
In the next lesson, you will learn how to use holder objects.