Contents Using IOM Component Stubs Previous Next

Generic Object References

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 which contains a method called narrow. You can use the narrow method to convert 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 example demonstrates the proper usage of narrowing.

org.omg.CORBA.Object generic = sasWorkspace.GetApplication("MY_APP");
IMyApp myApp = IMyAppHelper.narrow(generic);
myApp.myMethod();

For the sake of clarity, exception handling statements have been removed from the preceding example.

Contents Using IOM Component Stubs Previous Next