Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7837961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:55:50+00:00 2026-06-02T14:55:50+00:00

I want to include the factory pattern in my modules. I have a module

  • 0

I want to include the factory pattern in my modules. I have a module ServiceFactory.js that looks like this:

exports.createService = function(serviceName, paramObj){
  return require('Services/'+serviceName).Service.new(paramObj);
};

This module should require other modules (Services) by their names and create an instance. The general Service.js lookes like this:

const Base = require('base').Base;

exports.Service = Base.extend({
    getName: function(){
        return this.name;
    },
    invoke: function(){
        //do something
    },
});

All other Services extend the base Service. I collect all Services in a subfolder “Services” in “lib”. When I now use the createService method of my factory I get an error like: “Module: ServiceFactory … has no authority to load Service/…”

Is there a way to grant ServiceFactory the authority to load my Services or is there another way to achieve my goal?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T14:55:53+00:00Added an answer on June 2, 2026 at 2:55 pm

    The Add-on SDK resolves all requirements when the add-on is packaged, it doesn’t happen at run-time. I guess that this is done mostly for performance reasons (modules can be loaded from several locations, searching these location when the extension is running can be slow) but there is a security aspect as well – even if a module is compromised (unintentionally runs code that it got from a web page), it still cannot load any additional modules, in particular not the chrome module. But the end result is: you cannot decide dynamically which modules you want to use, you can only load the modules that you explicitly require in your source code.

    The work-around in your case would be adding a function that is never called but has all the necessary require() calls to make sure that the SDK resolves them:

    function dummy()
    {
      require("Services/ServiceFoo");
      require("Services/ServiceBar");
      ...
    }
    

    Having this function in ServiceFactor.js will make sure that the createService() function can require these modules.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have something like this: x = from f in first.Include(second) where f.id
I've been reading up on the Factory pattern, and have come across articles that
I want to include validates_confirmation_of :password in a module but i keep getting errors
I want to include a folder in a setup project so that when I
I want to include a header file only if a certain function body is
I want to include Core Location and I'm trying to follow this tutorial: http://www.mobileorchard.com/hello-there-a-corelocation-tutorial/
I have an ActiveRecord model class Foo that has_many Bar . I want to
I want to have one model & view that is served by multiple controllers
I have some code that grabs some rows from a table and I want
I have a very dynamic (social networking) site running smarty that I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.