Providing a Custom Resolver

The plug-in framework has a default resolver that selects an appropriate implementation to suit the client requests. If the algorithm used by the custom resolver is inappropriate, an interface definition can provide its own custom resolver.

Custom resolvers are interface implementations that implement the CResolver interface. They are instantiated by the framework in response to the REComSession::CreateImplementationL() calls that specify to use a particular custom resolver. Custom resolvers must confirm to other aspects of interface implementations, including providing registration resource information, and publishing its UID and factory function in an implementation proxy table.

Note: Additionally, in order to be trusted by ECom, the plug-in must have the ProtServ capability set in the project file.

A custom resolver class must derive from CResolver . The derived class must implement the following inherited functions:


  1. Implement a factory function that takes an MPublicRegistry object as input. MPublicRegistry provides the resolver with the list of the implementations registered with the plug-in framework that meet the requirements of the specified interface.

  2. Implement the CResolver::IdentifyImplementationL() function that takes the UID of the interface for which an implementation is requested. The resolver uses the resolution parameters and returns the UID of the best-fit implementation. The best-fit algorithm is specific to each custom resolver. CResolver::IdentifyImplementationL() returns a list of all matching implementations.

  3. Implement the CResolver::ListAllL() function.

Custom resolver example

The following code depicts a sample customer resolver.

       
        
       
       class CExampleResolver : public CResolver
    {
public:
    // Factory function: 
    static CExampleResolver* NewL(MPublicRegistry& aRegistry);
    ~CExampleResolver();

    // Implement IdentifyImplementationL()
    TUid IdentifyImplementationL(TUid aInterfaceUid, 
    const TEComResolverParams& aParameters) const;

// Implement ListAllL

    RImplInfoArray* ListAllL(TUid aInterfaceUid, 
    const TEComResolverParams& aParameters) const;
      

The following code shows a sample standard registration resource required by a custom resolver.

       
        
       
       RESOURCE REGISTRY_INFO theInfo
    {
    dll_uid = 0x10009DB3;
    interfaces = 
        {
        INTERFACE_INFO
 // interface_uid value is always 0x10009D90. 
            {
            interface_uid = 0x10009D90;
            implementations = 
                {
                IMPLEMENTATION_INFO
                    {
// uid value is specific to individual resolvers
                    implementation_uid = 0x10009DB4;

                    version_no = 1;
// unused fields
                    display_name = "";
                    default_data = "";
                    opaque_data = "";
                    }
                };
            }
        };
    }