From:  henson <jfsihenson@gmail.com>
Date:  10 Mar 2011 04:49:06 Hong Kong Time
Newsgroup:  news.mozilla.org/mozilla.dev.extensions.br
Subject:  

Integrating nsIExtensionManager in xulrunner-1.9.2 with JavaXPCOM

NNTP-Posting-Host:  189.33.49.144

Hi, all!
How to integrate and start the new version of interface
nsIExtensionManager for xulrunner-1.9.2 with JavaXPCOM?!
Someone would had the snippet code for that or some idea for that
implementation?
What changed between xulrunner-1.9.0 and xulrunner-1.9.2?
I executing the code:

nsIWindowWatcher winWatcher = XPCOMUtils.getService("@mozilla.org/
embedcomp/window-watcher;1", nsIWindowWatcher.class); //$NON-NLS-1$
                winWatcher.setWindowCreator(winCreator);

                nsIPrefBranch pref =
XPCOMUtils.getService("@mozilla.org/preferences-service;1",
nsIPrefBranch.class); //$NON-NLS-1$
                pref.setBoolPref("browser.download.useDownloadDir",
0); //$NON-NLS-1$

                //when page loading fails, display an error page,
                //similar as firefox does
                pref.setBoolPref("browser.xul.error_pages.enabled",
1); //$NON-NLS-1$

                //disable various security warning dialogs
                //such as when entering/leaving https site or
                //submitting form
                pref.setBoolPref("security.warn_entering_secure",
0); //$NON-NLS-1$
                pref.setBoolPref("security.warn_entering_weak", 0); //
$NON-NLS-1$
                pref.setBoolPref("security.warn_leaving_secure", 0); //
$NON-NLS-1$
                pref.setBoolPref("security.warn_submit_insecure",
0); //$NON-NLS-1$
                pref.setBoolPref("security.warn_viewing_mixed", 0); //
$NON-NLS-1$

                nsIExtensionManager em = getService("@mozilla.org/
extensions/manager;1", nsIExtensionManager.class); //$NON-NLS-1$

				/**
				* Returns XPCOM service with the given contract ID. This method
				* is an equivalent of the do_GetService() macro in
mozilla
				* source code. For example,
				* 
				*   getService("@mozilla.org/cookiemanager;1",
nsICookieManager.class)
				* 
* returns the nsICookieManager interface of the Mozilla's * cookie service. Similarly, *
				*   getService("@mozilla.org/cookiemanager;1",
nsICookieService.class)
				* 
* returns the nsICookieService interface of the cookie service. * * @param - an XPCOM interface (org.mozilla.interfaces) * @param contractID - identifier of the XPCOM service * @param c - interface of the XPCOM service to be returned * @return XPCOM service */ public static T getService(String contractID, Class c) { try { Mozilla moz = Mozilla.getInstance(); String iid = guessIID(c); nsIServiceManager serviceManager = moz.getServiceManager(); T t = (T) serviceManager.getServiceByContractID(contractID, iid); return t; } catch (Throwable e) { log.error("failed to create XPCOM service", e); //$NON-NLS-1$ return null; } } and getting error: GRAVE: failed to create XPCOM service org.mozilla.xpcom.XPCOMException: The function "getServiceByContractID" returned an error condition (0x80570016) at org.mozilla.xpcom.internal.XPCOMJavaProxy.callXPCOMMethod(Native Method) at org.mozilla.xpcom.internal.XPCOMJavaProxy.invoke(XPCOMJavaProxy.java: 143) at $Proxy0.getServiceByContractID(Unknown Source) Thanks, henson