OOPortal OOPortal


Java Programming  «Prev  Next»
Lesson 8Using holders
ObjectiveUse 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 out or 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 inout parameter:

  1. Client creates the actual parameter value.
  2. Client creates the holder
  3. 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.
  5. 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).
  7. 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
  9. 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.
  11. Now the client can do what it wants with the new value


In the next lesson, we will finish the mappings for operation parameters.