The DynAny interface provides the core of CORBA’s facility for the dynamic introspection of Any values for which the implementation class is not available. This facility has similar goals as Java’s built-in introspection facilities, but CORBA provides it as IDL interfaces so that it can be used no matter what implementation language is chosen. The CORBA facility allows services and objects to determine the type and contents of values passed into methods, without having access to their implementation interface. The service or object can wrap an incoming Any value with a DynAny in order to probe its properties and structure.

DynAny objects should not be exported outside of the processes where they are created. If you attempt to create a stringified reference to a DynAny object using the ORB.object_to_string() method, a MARSHAL exception will be thrown.

The DynAny interface provides a series of get_XXX() and insert_XXX() methods that can be used to access or modify the contents of the Any value if it is an IDL basic type. The TypeCode for the contents can also be accessed, using the type() method. If the Any value holds a complex data type, such as a struct, then the next(), seek(), rewind() and current_component() methods on the DynAny interface can be used to iterate through the data members of the contents.

There are various subtypes of DynAny which provide access to the components of specific IDL complex types, such as structs, enums, and unions. These and basic ...

Get Java Enterprise in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.