I want to include a factory template in my modules. I have a module ServiceFactory.jsthat looks like this:
exports.createService = function(serviceName, paramObj){
return require('Services/'+serviceName).Service.new(paramObj);
};
This module should use other modules (Services) by their names and create an instance. The general one is Service.jsas follows:
const Base = require('base').Base;
exports.Service = Base.extend({
getName: function(){
return this.name;
},
invoke: function(){
},
});
All other services extend the basic service. I collect all the services in the "Services" subfolder in "lib". When I now use createServicemy factory method , I get an error, for example: "Module: ServiceFactory ... does not have the right to load Service / ..."
Is there a way to grant ServiceFactorypermission to download my Services or is there another way to achieve my goal?
source