|Use holder objects with method calls that have out and inout parameters
Using Holder Objects in Corba
Although the Java method can not change what object a parameter passed in references, it can change the internal state of the object passed in.
When a parameter calls for an
inout, the Java type in the method signature will end up as the corresponding holder type.
The client needs to create an instance of the holder object and pass this instance as the parameter. If it is an
inout parameter, then before calling the operation, the client needs to set the
value variable in the holder instance to the value being passed in.
On return of the remote call, the stub places the new object in the
value variable of the holder, so that when the method returns, the value has changed and the client can pick up the new value from the holder instance it passed in originally.
The following slide show shows what generally happens with an
- 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
In the next lesson, we will finish the mappings for operation parameters.