nsIComponentRegistrar

This interface provides methods to access and modify the XPCOM component registry.
Inherits from: nsISupports Last changed in Gecko 1.0

Method overview

void autoRegister(in nsIFile aSpec);
void autoUnregister(in nsIFile aSpec);
string CIDToContractID(in nsCIDRef aClass);
nsCIDPtr contractIDToCID(in string aContractID);
nsISimpleEnumerator enumerateCIDs();
nsISimpleEnumerator enumerateContractIDs();
boolean isCIDRegistered(in nsCIDRef aClass);
boolean isContractIDRegistered(in string aContractID);
void registerFactory(in nsCIDRef aClass, in string aClassName, in string aContractID, in nsIFactory aFactory);
void registerFactoryLocation(in nsCIDRef aClass, in string aClassName, in string aContractID, in nsIFile aFile, in string aLoaderStr, in string aType);
void unregisterFactory(in nsCIDRef aClass, in nsIFactory aFactory);
void unregisterFactoryLocation(in nsCIDRef aClass, in nsIFile aFile);

Methods

autoRegister()

Register a component (.manifest) file or all component files in a directory. Registration lasts for this run only, and is not cached.

Note: Formerly this method would register component files directly. This is no longer supported.

Component files must have an associated loader and export the required symbols which this loader defines. For example, if the given file is a native library, it must export the symbol NSGetModule. Other loaders may have different semantics.

This method may only be called from the main thread.

void autoRegister(
  in nsIFile aSpec
);
Parameters
aSpec

This parameter indicates either a component file to be registered or a directory containing component files to be registered.

XPCOM <= 1.8: If <var>aSpec</var> is null, then the application component's directory as defined by NS_XPCOM_COMPONENT_DIR will be registered. See nsDirectoryService.

XPCOM >= 1.9: If <var>aSpec</var> is null, static components, GRE components, and the the application's component directories will be registered. See NS_GRE_DIR, NS_XPCOM_COMPONENT_DIR, and NS_XPCOM_COMPONENT_DIR_LIST in nsDirectoryService.

autoUnregister()

Unregister a component file or all component files in a directory.

This method may only be called from the main thread.

void autoUnregister(
  in nsIFile aSpec
);
Parameters
aSpec
This parameter indicates either a component file to be unregistered or a directory containing component files to be unregistered. If <var>aSpec</var> is null, then the application component's directory as defined by NS_XPCOM_COMPONENT_DIR will be unregistered. See nsDirectoryService.

CIDToContractID()

This method returns the ContractID corresponding to a given ClassID.

string CIDToContractID(
  in nsCIDRef aClass
);
Parameters
aClass
The ClassID to be queried.
Return value

The ContractID corresponding to aClassID if one exists and is registered.

contractIDToCID()

Returns the ClassID for a given ContractID, if one exists and is registered.

nsCIDPtr contractIDToCID(
  in string aContractID
);
Parameters
aContractID
The ContractID to be queried.
Return value

The ClassID corresponding to aContractID if one exists and is registered.

enumerateCIDs()

This method returns an enumerator over the list of registered ClassIDs.

Elements of the enumeration can be QueryInterfaced for the nsISupportsID interface. From the nsISupportsID, you can obtain the actual ClassID.

nsISimpleEnumerator enumerateCIDs();
Parameters

None.

Return value

An nsISimpleEnumerator over the list of registered classes. Elements of the enumerator implement nsISupportsID.

enumerateContractIDs()

This method returns an enumerator over the list of registered ContractIDs.

Elements of the enumeration can be QueryInterfaced for the nsISupportsCString interface. From the nsISupportsCString interface, you can obtain the actual ContractID string.

nsISimpleEnumerator enumerateContractIDs();
Parameters

None.

Return value

An nsISimpleEnumerator over the list of registered classes. Elements of the enumerator implement nsISupportsCString.

isCIDRegistered()

This method is used to test for the existence of a specific ClassID.

boolean isCIDRegistered(
  in nsCIDRef aClass
);
Parameters
aClass
The ClassID to be queried.
Return value

true if a factory is registered for the ClassID, false otherwise.

isContractIDRegistered()

This method is used to test for the existence of a class implementing a specific ContractID.

boolean isContractIDRegistered(
  in string aContractID
);
Parameters
aContractID
The ContractID to be queried.
Return value

true if a factory is registered for the ContractID, false otherwise.

registerFactory()

Registers a factory to be used to instantiate a particular class identified by ClassID, and creates an association of class name and ContractID with the class.

void registerFactory(
  in nsCIDRef aClass,
  in string aClassName,
  in string aContractID,
  in nsIFactory aFactory
);
Parameters
aClass
The ClassID of the class being registered.
aClassName
The name of the class being registered. This value is intended as a human-readable name for the class and need not be globally unique. (unused)
aContractID
The ContractID of the class being registered. May be null if no ContractID is needed.
aFactory
The nsIFactory instance of the class being registered. If aFactory is null, the contract will be associated with a previously registered ClassID.

registerFactoryLocation()

Registers a factory to be used to instantiate a particular class identified by ClassID, and creates an association of class name and ContractID with the class. However, unlike registerFactory(), the location of the component containing the factory implementation is specified instead of the factory instance.

void registerFactoryLocation(
  in nsCIDRef aClass,
  in string aClassName,
  in string aContractID,
  in nsIFile aFile,
  in string aLoaderStr,
  in string aType
);
Parameters
aClass
The ClassID of the class being registered.
aClassName
The name of the class being registered. This value is intended as a human-readable name for the class and need not be globally unique.
aContractID
The ContractID of the class being registered.
aFile
A component file. This file must have an associated loader and export the required symbols, which the loader specifies.
aLoaderStr
Opaque loader specific string. This value is passed into the nsIModule.registerSelf() callback and must be forwarded unmodified when registering factories via their location.
aType
Component Type of aClass. This value is passed into thensIModule.registerSelf() callback and must be forwarded unmodified when registering factories via their location.

unregisterFactory()

Unregister a factory associated with a particular class identified by ClassID.

void unregisterFactory(
  in nsCIDRef aClass,
  in nsIFactory aFactory
);
Parameters
aClass
The ClassID of the class being unregistered.
aFactory
The nsIFactory instance of the class being unregistered.

unregisterFactoryLocation()

Unregisters the factory associated with a given ClassID and component file location.

void unregisterFactoryLocation(
  in nsCIDRef aClass,
  in nsIFile aFile
);
Parameters
aClass
The ClassID that was previously registered.
aFile
The component file that was previously registered.

Remarks

This interface was finalized (frozen) for Gecko 1.0. See bug 115853 for details. From Gecko 2.0 interfaces are no longer frozen.

Document Tags and Contributors

 Contributors to this page: Sheppy, trevorh, Ted_Mielczarek, DarinFisher, Nickolay, Dria
 Last updated by: Sheppy,