When you obtain a reference to a stub for an IOM object,
you usually call a method on another stub, and the stub takes care
of the details necessary to connect the new stub with the new IOM
object. However, sometimes a method is designed to produce a generic
stub, which is a stub with no specialized methods.
Whenever a method on
a stub has an output or return parameter of type
org.omg.CORBA.Object
, that parameter is considered a generic stub. Before you can do
anything useful with a generic stub, you need to narrow it to a more
specific stub.
Every stub is associated
with a
Helper
class that contains a method
called
narrow
. The
narrow
method converts a generic stub into a more useful one. If you attempt
to narrow a generic stub to a specific stub that the underlying object
cannot support, the
narrow
method returns
null
.
The following code fragment
demonstrates the proper usage of narrowing:
org.omg.CORBA.Object generic =
sasWorkspace.GetApplication(MY_APP);
IMyApp myApp = IMyAppHelper.narrow(generic);
myApp.myMethod();