This class implements the IPofContext interface using information provided in a configuration file (or in a passed XML configuration).

Namespace: Tangosol.IO.Pof
Assembly: Coherence (in Coherence.dll) Version: 12.1.2.0 (12.1.2.0)

Syntax

C#
public class ConfigurablePofContext : IPofContext, 
	ISerializer, IXmlConfigurable

Remarks

For each user type supported by this POF context, it must be provided with:

  • A valid user type ID that is unique within this POF context.
  • A .NET type name that identifies a .NET type or interface that all values of the user type are type-assignable to (and that no values of other user types are type-assignable to); in other words, all values of the user type (and no values of other user types) are instances of the specified class, instances of a sub-class of the specified class, or (if it is an interface) instances of a class that implements the specified interface.
  • A .NET type name that identifies a non-abstract implementation of the IPofSerializer interface.

The format of the configuration XML is as follows:

             <pof-config>
               <user-type-list>
               ..
                 <user-type>
                   <type-id>53</type-id>
                   <class-name>My.Example.Data.Trade, MyAssembly</class-name>
                   <serializer>
                     <class-name>Tangosol.IO.Pof.PortableObjectSerializer, Coherence</class-name>
                     <init-params>
                       <init-param>
                         <param-type>System.Int32</param-type>
                         <param-value>{type-id}</param-value>
                       </init-param>
                     </init-params>
                   </serializer>
                 </user-type>
            
                 <user-type>
                   <type-id>54</type-id>
                   <class-name>My.Example.Data.Position, MyAssembly</class-name>
                 </user-type>
            
               ..
               <include>file:/my-pof-config.xml</include>
            
               ..
               </user-type-list>
            
               <allow-interfaces>false</allow-interfaces>
               <allow-subclasses>false</allow-subclasses>
            
               <default-serializer>
                 <class-name>Tangosol.IO.Pof.XmlPofSerializer, Coherence</class-name>
                 <init-params>
                   <init-param>
                     <param-type>System.Int32</param-type>
                     <param-value>{type-id}</param-value>
                   </init-param>
                 </init-params>
               </default-serializer>
             </pof-config>
             

For each user type, a user-type element must exist inside the user-type-list element. The user-type-list element contains up to three elements, in the following order:

  • The user-type element should contain a type-id element whose value specifies the unique integer type ID; if none of the user-type elements contains a type-id element, then the type IDs for the user types will be based on the order in which they appear in the configuration, with the first user type being assigned the type ID 0, the second user type being assigned the type ID 1, and so on. (It is strongly recommended that user types IDs always be specified, in order to support schema versioning and evolution.)
  • The class-name element is required, and specifies the fully qualified name of the .NET type or interface that all values of the user type are type-assignable to.
  • The serializer element is used to specify an implementation of IPofSerializer to use to serialize and deserialize user type values to and from a POF stream. Within the serializer element, the class-name element is required, and zero or more constructor parameters can be defined within an init-params block. If no serializer is specified, then the default-serializer is used if one is specified, otherwise the user type is assumed to implement the IPortableObject interface or have a PortableAttribute. If the former, a PortableObjectSerializer will be used. If the later, a PofAnnotationSerializer will be used.

The optional include element allows user-type elements defined in another configuration XML to be added to the user type list. The value of this element is a locator string (either a valid path or URL) that specifies the location of the target IPofContext configuration file. The user-type elements of the target file are imported verbatum; therefore, if the included elements contain explicit type identifiers, each identifier must be unique with respect to the the user type identifiers (either explicit or generated) defined within the including file. If the included user types do not contain explicit type identifiers, then the type identifiers will be based on the order in which the user types appear in the composite configuration file. Multiple include elements may be used within a single user-type-list element.

In order to be used by the ConfigurablePofContext, a IPofSerializer implementation must provide a public constructor that accepts the parameters detailed by the init-params element. The parameter values, as specified by the param-value element, can specify one of the following substitutable values:

  • {type-id} - replaced with the Type ID of the User Type
  • {class-name} - replaced with the name of the class for the User Type
  • {class} - replaced with the Type for the User Type

If the init-params element is not present, then the ConfigurablePofContext attempts to construct the IPofSerializer by searching for one of the following constructors in the same order as they appear here:

  • (int typeId, Type type)
  • (int typeId)
  • ()

Once constructed, if the IPofSerializer implements the IXmlConfigurable interface, the Config property is set to the passed XML information, transposed as described by TransformInitParams(IXmlElement, IXmlElement), and as described in the pof-config.xsd file.

Inheritance Hierarchy

System..::..Object
  Tangosol.IO.Pof..::..ConfigurablePofContext
    Tangosol.IO.Pof..::..SafeConfigurablePofContext

See Also