Customizing the default base proxy class

Continuing the example from the previous topic, imagine that an application derives 100 subclasses from the "Foo" class. If the application wishes to cache the "Foo::attribute_long" attribute in the proxies for all remote Foo-based objects, the application could supply 100 user-supplied proxy classes, developed in the manner described above. However, this would become a very tedious and repetitive task!

Alternatively, it is possible to provide a customized base proxy class for use in the dynamic generation of DSOM proxy classes. This allows an application to provide a customized base proxy class, from which other dynamic DSOM proxy classes can be derived. This is particularly useful in situations where an application would like to enhance many or all dynamically generated proxy classes with a common feature.

As described in the previous topic, proxy classes are derived from the SOMDClientProxy class by default. It is the SOMDClientProxy class that overrides somDispatch in order to forward method calls to remote objects.

The SOMDClientProxy class can be customized by deriving a subclass in the usual way (being careful not to replace somDispatch or other methods that are fundamental to implementing the proxy's behavior). To extend the above example further, the application might define a base proxy class called "MyClientProxy" that defines a long attribute called "attribute_long," which will be inherited by Foo-based proxy classes.

The SOM IDL modifier baseproxyclass can be used to specify which base proxy class DSOM should use during dynamic proxy-class generation. To continue the example, if the class "MyClientProxy" were used to construct the proxy class for a class "XYZ," then the baseproxyclass modifier would be specified s follows:

// xyz.idl

#include <somdtype.idl>
#include <foo.idl>

interface XYZ : Foo
{
  ...
  implementation
  {
     ...
     baseproxyclass = MyClientProxy;
  };
};

It should be noted that:


[Back: Creating user-supplied proxies]
[Next: Sockets class]