зеркало из https://github.com/mozilla/gecko-dev.git
144 строки
5.3 KiB
HTML
144 строки
5.3 KiB
HTML
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; U; Linux 2.0.36 i686) [Netscape]">
|
|
</head>
|
|
<body>
|
|
|
|
<center>
|
|
<h2>
|
|
Component Loaders</h2></center>
|
|
|
|
<center>Brendan Eich <<a href="mailto:brendan@mozilla.org">brendan@mozilla.org</a>>
|
|
<br>John Bandauer <<a href="mailto:jband@netscape.com">jband@netscape.com</a>>
|
|
<br>Mike McCabe <<a href="mailto:mccabe@netscape.com">mccabe@netscape.com</a>>
|
|
<br>Mike Shaver <<a href="mailto:shaver@mozilla.org">shaver@mozilla.org</a>>
|
|
<br>Suresh Duddi <<a href="mailto:dp@netscape.com">dp@netscape.com</a>></center>
|
|
|
|
<h3>
|
|
Scope of document</h3>
|
|
|
|
<ul>
|
|
<li>
|
|
Component Developers</li>
|
|
|
|
<li>
|
|
Clients of XPCOM (for information only)</li>
|
|
</ul>
|
|
|
|
<h3>
|
|
Why Component Loaders</h3>
|
|
Currently XPCOM requires all component to be packaged in DLLs and uses
|
|
the dynamic loading mechanism available with each platform to accomplish
|
|
instantiation of component. This method doesn't blend well with say components
|
|
written in java or javascript and packaged different from a DLL. Hence
|
|
the proposal for Component Loaders.
|
|
<br>
|
|
<h3>
|
|
Component Loaders</h3>
|
|
XPCOM in its simplest form can be viewed as creating instances of objects
|
|
given a CONTRACTID or ClassID. How it does this instantiation is specific to
|
|
XPCOM and opaque to clients of XPCOM.
|
|
<p>Internally XPCOM maps the passed in CONTRACTID to a CID and then the CID
|
|
maps into a DLL name. XPCOM loads the DLL assuming the dynamic loading
|
|
mechanism to create a factory. Then, asks the factory to create a particular
|
|
instance. Here are roughly the steps involved:
|
|
<ol>
|
|
<li>
|
|
CreateInstance(..., CONTRACTID,...)</li>
|
|
|
|
<li>
|
|
Map CONTRACTID to CID</li>
|
|
|
|
<li>
|
|
Map CID to DLL</li>
|
|
|
|
<li>
|
|
factory = Dynamically Load DLL to create Factory</li>
|
|
|
|
<li>
|
|
Use Factory to create object instance</li>
|
|
</ol>
|
|
The proposal for Component Loaders is to get XPCOM to delegate the loading
|
|
to a component loader:
|
|
<ul>
|
|
<li>
|
|
CreateInstance(..., CONTRACTID,...)</li>
|
|
|
|
<li>
|
|
Map CONTRACTID to CID</li>
|
|
|
|
<li>
|
|
<font color="#990000">Map CID to ComponentType</font></li>
|
|
|
|
<li>
|
|
<font color="#990000">If ComponentType is DLL</font></li>
|
|
|
|
<ul>
|
|
<li>
|
|
factory = Dynamically Load DLL to create Factory</li>
|
|
</ul>
|
|
|
|
<li>
|
|
<font color="#990000">else</font></li>
|
|
|
|
<ul>
|
|
<li>
|
|
<font color="#990000">ComponentLoaderServiceCONTRACTID = "<i>@mozilla.org/xpcom/component-loader;1?type=</i>"
|
|
+ ComponentType <sup><a href="#* ContractID syntax might change">*</a></sup></font></li>
|
|
|
|
<li>
|
|
<font color="#990000">loaderInstance = GetService(..., ComponentLoaderServiceCONTRACTID,...)</font></li>
|
|
|
|
<li>
|
|
<font color="#990000">factory = loaderInstance->CreateFactory(..., componentLocation,...)</font></li>
|
|
</ul>
|
|
|
|
<li>
|
|
Use Factory to create object instance</li>
|
|
|
|
<h4>
|
|
Format of ComponentType</h4>
|
|
ComponentType is assumed to be mimetype.
|
|
<h4>
|
|
Component Registration</h4>
|
|
Registration of components in DLLs wont change. ComponentType of DLL is
|
|
assumed here. To facilitate registration of components with specifc component
|
|
types, the component manager will provide the following API:
|
|
<p><tt><font color="#990000">RegisterComponentWithType(const nsCID &aClass,</font></tt>
|
|
<br><tt><font color="#990000">
|
|
const char *aClassName,</font></tt>
|
|
<br><tt><font color="#990000">
|
|
const char *aContractID,</font></tt>
|
|
<br><tt><font color="#990000">
|
|
const char *aComponentType,</font></tt>
|
|
<br><tt><font color="#990000">
|
|
const char *aComponentLocation,</font></tt>
|
|
<br><tt><font color="#990000">
|
|
PRBool aReplace,</font></tt>
|
|
<br><tt><font color="#990000">
|
|
PRBool aPersist);</font></tt>
|
|
<br>
|
|
<br>
|
|
<h4>
|
|
Component Loader Service Registration</h4>
|
|
Since the loader is just another component with a special contractid, there
|
|
is no special registration of the component loader. Component Loaders
|
|
use either the RegisterComponent() api if they are a DLL (most common)
|
|
or use RegisterComponentWithType() api if they are themselves of a particular
|
|
type (very rare).</ul>
|
|
|
|
<h3>
|
|
Autoregistration of non DLL Components and Component Loaders</h3>
|
|
<Need to figure this out>
|
|
<br>
|
|
<p><a NAME="* ContractID syntax might change"></a><sup><a href="#* ContractID syntax might change">*</a></sup>
|
|
ContractID syntax might change
|
|
<br>
|
|
<hr WIDTH="100%">
|
|
<br><i><font size=-1>Last Modified: 1 Aug 1999 Suresh Duddi <<a href="mailto:dp@netscape.com">dp@netscape.com</a>></font></i>
|
|
<br>
|
|
</body>
|
|
</html>
|