JavaXPCOM: new initialization methods

Javier Pedemonte <[email protected]>
Newsgroups gmane.comp.mozilla.devel.java
Message-ID <hoydna55catQrdzYnZ2dnUVZ_vednZ2d__24785.1983098828$1161900714$gmane$org@mozilla.org>
A few weeks ago, I checked in the patch for 
https://bugzilla.mozilla.org/show_bug.cgi?id=340960, which adds several 
new methods to the Mozilla class.

First, I added the |initialize()| method, which must be called before 
either |initEmbedding()| or |initXPCOM()| (or any of the other Mozilla 
class methods).  It takes as an argument the path returned by 
|getGREPathWithProperites()|.

Secondly, there are two profile related methods.  Use 
|lockProfileDirectory()| to lock the given directory so that another 
Mozilla process won't use the same profile.  Use |notifyProfile()| to 
notify the Mozilla process about the new profile location.

I added a Javadoc comment at the top of the Mozilla class with some 
sample code.  Here is the relevant bit which shows how to use these new 
methods:

  Mozilla mozilla = Mozilla.getInstance();
  GREVersionRange[] range = new GREVersionRange[1];
  range[0] = new GREVersionRange("1.8.0.*", false, "1.8.1.*", true);
  try {
     File grePath = Mozilla.getGREPathWithProperties(range, null);
     mozilla.initialize(grePath);
     profLock = mozilla.lockProfileDirectory(profileDir);
     // LocationProvider is a user class that implements IAppFileLocProvider
     LocationProvider locProvider = new LocationProvider(grePath, 
profileDir);
     mozilla.initEmbedding(grePath, grePath, locProvider);
     mozilla.notifyProfile();
  } catch (XPCOMInitializationException xie) {
     // handle exception
  } catch (XPCOMException xe) {
     // handle exception
  }


javier pedemonte
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.