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); 

Client creates the actual parameter value.

Client creates the holder

Client puts the value into the holder .

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

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

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

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

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

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

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

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