Java Programming  «Prev 

Using Corba holders

boolean getJobInfo(in long number, out jobInfo info)

One of the things I have learned about Java and mapping inout and out parameters is the use of holder classes. Java cannot directly map these types and has to make use of holder classes.
To use a holder class you must do the following;

jobInfo jbInfo = new jobInfo();
jobInfoHolder jbInfoHolder = new jobInfoHolder(jbInfo);
jbSession.getJobInfo(jobNumber, jbInfoHolder);
System.out.println(jbInfo.number);

Each holder class has a value property that returns the value of the object that it is holding.
So for this example one should have:
jobInfo jbInfo = new jobInfo();  
jobInfoHolder jbInfoHolder = new jobInfoHolder(jbInfo);  
jbSession.getJobInfo(jobNumber, jbInfoHolder);  
jbInfo = jbInfoHolder.value
System.out.println(jbInfo.number); 

1) Client creates the actual parameter value.
Client creates the actual parameter value.

2) Client creates the holder
Client creates the holder

3) Client puts the value into the holder
Client puts the value into the holder .

4) Client calls the remote method on the stub with the holder it just created and filled as the parameter.
Client calls the remote method on the stub with the holder it just created and filled as the parameter.

5) The stub sends the value over the wire to the skeleton which calls the server Impl passing the value in a holder
The stub sends the value over the wire to the skeleton which calls the server Impl passing the value in a holder

6) The server object removes the value from the holder (and uses it).
The server object removes the value from the holder (and uses it).

7) The server object creates a value for the parameter ( it could resuse the old one).
The server object creates a value for the parameter ( it could resuse the old one).

8) The server object puts the new value into the holder passed to it from the skeleton
The server object puts the new value into the holder passed to it from the skeleton

9) On return the skeleton passes the new value in the holder to the stub which puts the value into the holder client
On return the skeleton passes the new value in the holder to the stub which puts the value into the holder client originally used.

10) The client removes the new value from the holder it created and passed as a parameter
The client removes the new value from the holder it created and passed as a parameter.

11) Now the client can do what it wants with the new value
Now the client can do what it wants with the new value