Previous | Table of Contents | Next |
Once a value type has been marked as custom, an implementation of the custom marshaling code must be provided. This is specified
by providing a concrete implementation of an abstract value type, CustomMarshal, as part of the implementation of the value
type. CustomMarshal encapsulates the application code that can marshal and unmarshal instances of the value type over a stream
using the CDR encoding.
The following IDL defines the interfaces that are used to support the definition and use of custom marshaling.
module CORBA {
abstract valuetype CustomMarshal { void marshal (in DataOutputStream os); void unmarshal (in DataInputStream is);
};};
CustomMarshal is an abstract value type that is meant to be used by the ORB, not the user. Semantically it is treated as a
custom valuetype’s implicit base class, although the custom valuetype does not actually inherit it in IDL. The implementor
of a custom value type provides an implementation of the CustomMarshal operations. The manner in which this is done is specified
for each language mapping. Each custom marshaled value type has its own implementation. The interface is exposed in the CORBA
module so that the implementor can use the skeletons generated by the IDL compiler as the basis for the implementation. Hence
there is no need for the application to acquire a reference to a Stream.
Note that while nothing prevents a user from writing IDL that inherits from CustomMarshal, doing so will not make the type
custom, nor will it cause the ORB to treat it as custom.
The implementation requirements of the streaming mechanism require that the implementations must be local since local memory
addresses (i.e., the marshal buffers) have to be manipulated.