nsIServiceManager
From MDC
Contents |
[edit] Summary
The nsIServiceManager manager interface provides a means to obtain global services in an application.
#include "nsIServiceManager.h"
[scriptable, uuid=(8bb35ed9-e332-462d-9155-4a002ab5c958)]
interface nsIServiceManager : nsISupports { ... };
[edit] Methods
-
getService - This method returns a reference to a particular XPCOM service given the ClassID of the service.
-
getServiceByContractID - This method returns a reference to a particular XPCOM service given the ContractID of the service.
-
isServiceInstantiated - This method tests whether or not a XPCOM service, identified by ClassID, has been instantiated.
isServiceInstantiatedByContractID- This method tests whether or not a XPCOM service, identified by ContractID, has been instantiated.
[edit] Remarks
The service manager depends on the repository to find and instantiate factories to obtain services.
Because services are instantiated lazily, methods are provided to test whether or not a service has already been instantiated.
Users of the service manager must first obtain a pointer to the global service manager by calling NS_GetServiceManager. After that, they can request specific services by calling getService. When they are finished they should call nsISupports::Release on the service as they would with any interface pointer. In some language bindings, such as JavaScript, this step is unnecessary. And, moreover such languages typically offer more convenient mechanisms to acquire references to XPCOM services and components.
A user of a service may keep references to services until application shutdown.
[edit] History
This interface was frozen for Mozilla 1.0. See bug 99147 for details.