gecko-dev/xpcom/doc/xpcom-component-loaders.html

144 строки
5.3 KiB
HTML
Исходник Обычный вид История

1999-07-29 00:22:49 +04:00
<!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>
1999-08-04 10:24:33 +04:00
<center>Brendan Eich &lt;<a href="mailto:brendan@mozilla.org">brendan@mozilla.org</a>>
1999-07-29 00:22:49 +04:00
<br>John Bandauer &lt;<a href="mailto:jband@netscape.com">jband@netscape.com</a>>
<br>Mike McCabe &lt;<a href="mailto:mccabe@netscape.com">mccabe@netscape.com</a>>
1999-08-04 10:24:33 +04:00
<br>Mike Shaver &lt;<a href="mailto:shaver@mozilla.org">shaver@mozilla.org</a>>
1999-07-29 00:22:49 +04:00
<br>Suresh Duddi &lt;<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>
1999-08-04 11:07:37 +04:00
Currently XPCOM requires all component to be packaged in DLLs and uses
1999-07-29 00:22:49 +04:00
the dynamic loading mechanism available with each platform to accomplish
instantiation of component. This method doesn't blend well with say components
1999-08-04 11:07:37 +04:00
written in java or javascript and packaged different from a DLL. Hence
1999-07-29 00:22:49 +04:00
the proposal for Component Loaders.
<br>&nbsp;
<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
1999-07-29 00:22:49 +04:00
XPCOM and opaque to clients of XPCOM.
<p>Internally XPCOM maps the passed in CONTRACTID to a CID and then the CID
1999-08-04 11:07:37 +04:00
maps into a DLL name. XPCOM loads the DLL assuming the dynamic loading
1999-07-29 00:22:49 +04:00
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>
1999-07-29 00:22:49 +04:00
<li>
Map CONTRACTID to CID</li>
1999-07-29 00:22:49 +04:00
<li>
1999-08-04 11:07:37 +04:00
Map CID to DLL</li>
1999-07-29 00:22:49 +04:00
<li>
1999-08-04 11:07:37 +04:00
factory = Dynamically Load DLL to create Factory</li>
1999-07-29 00:22:49 +04:00
<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>
1999-07-29 00:22:49 +04:00
<li>
Map CONTRACTID to CID</li>
1999-07-29 00:22:49 +04:00
<li>
<font color="#990000">Map CID to ComponentType</font></li>
<li>
1999-08-04 11:07:37 +04:00
<font color="#990000">If ComponentType is DLL</font></li>
1999-07-29 00:22:49 +04:00
<ul>
<li>
1999-08-04 11:07:37 +04:00
factory = Dynamically Load DLL to create Factory</li>
1999-07-29 00:22:49 +04:00
</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>
1999-07-29 00:22:49 +04:00
<li>
<font color="#990000">loaderInstance = GetService(..., ComponentLoaderServiceCONTRACTID,...)</font></li>
1999-07-29 00:22:49 +04:00
<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>
1999-08-04 11:07:37 +04:00
Registration of components in DLLs wont change. ComponentType of DLL is
1999-07-29 00:22:49 +04:00
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 &amp;aClass,</font></tt>
<br><tt><font color="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
const char *aClassName,</font></tt>
<br><tt><font color="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
const char *aContractID,</font></tt>
1999-07-29 00:22:49 +04:00
<br><tt><font color="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1999-08-04 11:07:37 +04:00
const char *aComponentType,</font></tt>
1999-07-29 00:22:49 +04:00
<br><tt><font color="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1999-08-04 11:07:37 +04:00
const char *aComponentLocation,</font></tt>
1999-07-29 00:22:49 +04:00
<br><tt><font color="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
PRBool aReplace,</font></tt>
<br><tt><font color="#990000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
PRBool aPersist);</font></tt>
<br>&nbsp;
<br>&nbsp;
<h4>
Component Loader Service Registration</h4>
Since the loader is just another component with a special contractid, there
1999-07-29 00:22:49 +04:00
is no special registration of the component loader.&nbsp; Component Loaders
1999-08-04 11:07:37 +04:00
use either the RegisterComponent() api if they are a DLL (most common)
1999-07-29 00:22:49 +04:00
or use RegisterComponentWithType() api if they are themselves of a particular
type (very rare).</ul>
<h3>
1999-08-04 11:07:37 +04:00
Autoregistration of non DLL Components and Component Loaders</h3>
&lt;Need to figure this out>
<br>&nbsp;
<p><a NAME="* ContractID syntax might change"></a><sup><a href="#* ContractID syntax might change">*</a></sup>
ContractID&nbsp;syntax might change
1999-07-29 00:22:49 +04:00
<br>
<hr WIDTH="100%">
1999-08-04 11:07:37 +04:00
<br><i><font size=-1>Last Modified: 1 Aug 1999&nbsp; Suresh Duddi &lt;<a href="mailto:dp@netscape.com">dp@netscape.com</a>></font></i>
<br>&nbsp;
1999-07-29 00:22:49 +04:00
</body>
</html>