Resources | Resources |



Implementing a service class

To implement a service class, do the following:

  1. Define the interface(s) supported by the service class in the IDL file.

    Each interface must have a unique interface ID (AEEIID_XXXX). See Unique IDs (UID) for more information.

  2. Declare the service class in the CIF for the module.

    Each service class must have a unique class ID (i.e. AEECLSID_XXXX). A service class can also specify privileges (i.e. AEEPRIVID_XXXX) required by callers. For more information, see Unique IDs (UID) and Privileges.

    Note: In Brew MP 1.0, service classes can only instantiated in the kernel process (specified by serverid=0 in the Service primitive in the CIF).

  3. Implement the service class in C/C++.
  4. Build the service class, as follows:
    1. Compile the CIF and any CAR files to create the MIF and BAR files.
    2. Compile the IDL file, using the QIDL compiler, to generate the stub and skeleton code.
    3. Compile the C/C++ source code, using an arm compiler, to generate the module for the service class.

See the c_basicmod1ext example in the Brew MP Sample Code for examples of IDL, CIF, and source files for a service class. For more information IDL and CIF files, refer to the following documents in on the Brew MP website:

  • QIDL Reference
  • Resource File and Markup Reference

The Brew MP IDE plugin for Visual Studio or Eclipse provides wizards to facilitate the development of applet and in-process classes. However, service classes are not yet supported by the Brew MP IDE wizard.

Considerations for implementing a service class

Service classes can only be instantiated outside an application context, which means they cannot instantiate any class that has dependencies on the BREW Shell. Services cannot directly instantiate IShell, nor any class or Brew MP API that uses IShell. Because some Brew MP APIs still have IShell dependencies, they cannot be instantiated in a service class.

Service classes can only be implemented in MOD1/DLL1 modules because classes in MOD/DLL modules automatically have IShell access and hence Brew Shell dependencies. For more information, see the MOD v.s. MOD1 in Brew MP Technology Guide in on the Brew MP website.

When a service class implements pre-emptive multithreading, the priority of the service threads must not be set higher than the BREW thread to avoid compromising system operations.