|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.teamdev.xpcom.ProxyManager
public class ProxyManager
A proxy, in this context, is a stub object which enables a method of any class which is derived from nsISupports and has a typelib to be called on any in-process thread. The main reason for nsISupports Proxies is that java and UI are on a single thread. When one is busy, the other is blocked. A good example of this is the old install.js scripts that were used in XPInstall in older Mozilla versions. They from the majority of JavaScript code, which is small and can be quickly run. XPInstall installation scripts are sometimes very complex and can require long execution time due to unzipping or native file system actions. If XPInstall ran on the UI thread, the product would appear frozen until the script was complete. This is definitely bad. Because of this, XPInstall was moved to its own thread. Now XPInstall can do its installations while the product renders, but now XPInstall can not access UI elements such as a progress meter or a confirmation dialog. How can a separate non-UI thread act as if it was on the UI thread? Herein lays the utility of nsISupports Proxies.
Method Summary | ||
---|---|---|
|
createComponetProxy(java.lang.String coid,
java.lang.Class<T> proxyClass,
boolean threadSafe)
Creates proxied XPCOM object identified by XPCOM contract ID. |
|
static ProxyManager |
getInstance()
|
|
|
getProxiedService(java.lang.String contractID,
java.lang.Class<T> serviceClass)
Creates thread safe proxied instance of XPCOM service identified by XPCOM contract ID |
|
|
proxyForObject(org.mozilla.interfaces.nsISupports object,
java.lang.Class<T> proxyClass,
boolean threadSafe)
Returns proxied instance for an existed XPCOM object or service. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static ProxyManager getInstance()
public <T extends org.mozilla.interfaces.nsISupports> T proxyForObject(org.mozilla.interfaces.nsISupports object, java.lang.Class<T> proxyClass, boolean threadSafe)
T
- the Xpcom interface typeobject
- the instance of Xpcom object or serviceproxyClass
- the java class of Xpcom interface typethreadSafe
- whether proxied object should be executed in xpcom main
thread. In most cases should be true
public <T extends org.mozilla.interfaces.nsISupports> T getProxiedService(java.lang.String contractID, java.lang.Class<T> serviceClass)
T
- the Xpcom interface typecontractID
- the XPCOM service contract IDserviceClass
- the java class of Xpcom interface type
public <T extends org.mozilla.interfaces.nsISupports> T createComponetProxy(java.lang.String coid, java.lang.Class<T> proxyClass, boolean threadSafe)
T
- the XPCOM interface typecoid
- the XPCOM contract IDproxyClass
- the java class of Xpcom interface typethreadSafe
- whether proxied object should be executed in xpcom main
thread. In most cases should be true
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |