function anExample()
{
  // this function is a constructor for your object. it needs to implement the interface defined by some idl file
  // don't forget to change the QI implementation to indicate which interfaces you support
  this.QueryInterface = function QueryInterface(aIID)
  {
    if (!aIID.equals(Components.interfaces.nsIFooBar) &&    
        !aIID.equals(Components.interfaces.nsISupports))
      throw Components.results.NS_ERROR_NO_INTERFACE;
    return this;
  };
}

function NSGetModule()
{
  // add one of these objects to this array for each component in this module
  var components = [
    {
      name: "human readable name for your component",
      classID: Components.ID("{11111111-1111-1111-1111-111111111111}"),
      contractID: "@example.com/your/contract-id",
      factory: makeFactory(anExample)
    },
  ];

  function makeFactory(obj)
  {
    return {
      createInstance: function createInstance(outer, iid)
      {
        if (outer != null)
          throw Components.results.NS_ERROR_NO_AGGREGATION;

        return (new obj).QueryInterface(iid);
      }
    };
  }

  return {
    registerSelf: function(compMgr, fileSpec, location, type)
    {
      compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);

      for each (component in components)
        compMgr.registerFactoryLocation(component.classID,
                                        component.name,
                                        component.contractID,
                                        fileSpec,
                                        location,
                                        type);
    },

    unregisterSelf: function(compMgr, location, type)
    {
      compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);

      for each (component in components)
        compMgr.unregisterFactoryLocation(component.classID, location);
    },

    getClassObject: function(compMgr, cid, iid)
    {
      if (!iid.equals(Components.interfaces.nsIFactory))
        throw Components.results.NS_ERROR_NOT_IMPLEMENTED;

      for each (component in components)
        if (cid.equals(component.classID))
          return component.factory;

      throw Components.results.NS_ERROR_NO_INTERFACE;
    },

    canUnload: function(compMgr)
    {
      return true;
    }
  }
}

