@function initServices

initialize ImmutableCoreServices defined in the services directory

@param {object} config

@returns {Promise}
508454
function initServices (config) {
    // get services directory
    var dirs = getDir(config, 'services')
    // load services definitions from each directory
    _.each(dirs, dir => initServicesDir(config, dir))
    // create new service instances from definitions
    _.each(config.services, (service, name) => {
        config.services[name] = new ImmutableCoreService(service)
    })
    // initialize all services
    return ImmutableCoreService.initializeAll()
}
1052360
function ImmutableCoreComponentInstance (args) {
    // require args
    this.assert(typeof args === 'object' && args, 100)
    // get component
    var component = args.component
    // require component
    this.assert(typeof component === 'object' && component && component.ImmutableCoreComponent, 101)
    // set component
    this.component = component
    // initialize data to empty object
    this.data = {}
    // if id is passed then initialize existing instance
    if (defined(args.id)) {
        // set id from args
        this.id = args.id
    }
    // otherwise create new instance
    else {
        // set default id which may be overwritten by new
        this.id = this.component.name
        // run new method setting data and id from response
        // this.promise will be resolved by new
        this.initNew(args)
    }
}
1119036
function init(options){

    return Promise.resolve()
      .then(function() {

        if(!_.get(parameters,'process.source')){
          return;
        }

        return Promise.resolve()
          .then(function() {
            return updateAllKeys(options);
          })
          .then(function() {
            return createMissingFolders(options);
          })
          .then(function() {
            return deleteUnused(options);
          })
          .then(function() {
            return deleteEmptyFolders(options);
          });

      })
      .then(function() {

        if(!_.get(parameters,'process.search')){
          return;
        }

        return require('./search')(util,options);

      })
      .then(function() {
        util.log('Sync is complete');
      });

  }
219946
function initializeStore(config) {
		self.store = new Store(config.master, config);
		self.store.on('message', handleIncomingMessage);
		log.out('Store initialized.');
	}
688945
function init(configuration){
    var self = {
        config : configuration,
        adapters : [],
        getWhenCurrentWritesDone : getWhenCurrentWritesDone
    };

    _.each(self.config.adapters, function(adapter){
        var adapterInstance;

        try {
            adapterInstance = require('./adapters/' + adapter.type).init(adapter);
        } catch (e) {
            console.log(chalk.red('Initialization Error: '), e);
            throw e;
        }

        adapterInstance.writeQueue = BB.resolve();

        self.adapters.push(adapterInstance);
    });

    [
        'error',
        'info',
        'debug',
        'warn',
        'trace',
        'critical'
    ].forEach(function (type) {
        /**
         * Create a TYPE log entry
         * @param category Categorize your error with a user defined label
         * @param args Include your customized messages. This should be a comma separated list just like `console.log`
         */
        self[type] = function () {
            // If we are still logging and there are messages to write
            if(arguments.length > 0){
                var category = (arguments.length > 1 && _.isString(arguments[0])) ? arguments[0] : '',
                    startIdx = (arguments.length > 1) ? 1 : 0;

                _write.call(self, type, category, Array.prototype.slice.call(arguments, startIdx));
            }
        };
    });

    return self;
}
325056
function init(){
    try {
      self.db = new nodeCache();
      log(false, 'Node-cache client created with the following defaults:', {expiration: this.expiration, verbose: this.verbose, readOnly: this.readOnly});
    } catch (err) {
      log(true, 'Node-cache client not created:', err);
      self.db = false;
    }
    self.type = config.type || 'node-cache';
  }
886030
private function loadServices(Config $config, $serviceId, callable $recipe = null)
    {
        if (false === $this->runRecipe($config, $recipe)) {
            $directories = array_unique(array_merge(
                            BundleConfigDirectory::getDirectories(
                                    $this->application->getBaseRepository(),
                                    $this->application->getContext(),
                                    $this->application->getEnvironment(),
                                    str_replace('bundle.', '', $serviceId)
                            ), BundleConfigDirectory::getDirectories(
                                    $this->application->getBaseRepository(),
                                    $this->application->getContext(),
                                    $this->application->getEnvironment(),
                                    basename(dirname($config->getBaseDir()))
            )));
            array_unshift($directories, $this->getConfigDirByBundleBaseDir(dirname($config->getBaseDir())));

            foreach ($directories as $directory) {
                $filepath = $directory.DIRECTORY_SEPARATOR.'services.xml';
                if (is_file($filepath) && is_readable($filepath)) {
                    try {
                        ServiceLoader::loadServicesFromXmlFile($this->container, $directory);
                    } catch (\Exception $e) {
                        // nothing to do
                    }
                }

                $filepath = $directory.DIRECTORY_SEPARATOR.'services.yml';
                if (is_file($filepath) && is_readable($filepath)) {
                    try {
                        ServiceLoader::loadServicesFromYamlFile($this->container, $directory);
                    } catch (\Exception $e) {
                        // nothing to do
                    }
                }
            }
        }
    }
606584
function initConfig(obj) {
  Object.keys(obj).forEach(item => {
    if (!process.env[item]) {
      process.env[item] = obj[item];
    }
  });
}
1059948
function (config) {
  if (config) {
    this.config = config;

    if (!this.config.service || (this.config.service != 'sendgrid' && this.config.service != 'postmark')) {
      throw new Error('Please specify which service you want to use - sendgrid or postmark');
    }

    this.config.service = this.config.service.toLowerCase();

    // Default template type
    // Helps when using ejs or any other templates
    if (!this.config.tplType) this.config.tplType = 'pug';

    if (config.email && !config.tplPath && !fs.exists(config.tplPath)) {
      throw new Error('Please provide correct path to the templates.');
    }
  }
}
705681
function initRoutes (config, route) {
    // create express router for route
    route.router = express.Router({
        caseSensitive: true,
        strict: true,
    })
    // initialize routes depth first so that explicit nested paths come
    // before wildcard paths and are handled correctly by express router
    _.each(route.routes, (subRoute, path) => {
        // get router for sub route
        var router = initRoutes(config, subRoute)
        // bind route for path
        route.router.use('/'+path+'/', router)
    })
    // clear model if no properties are set
    if (_.keys(route.model).length === 0) {
        route.model = undefined
    }
    // clear controller if no properties are set
    if (_.keys(route.controller).length === 0) {
        route.controller = undefined
    }
    // instantiate ImmutableCoreModel
    if (defined(route.model)) {
        route.model = new ImmutableCoreModel(route.model)
        // add model to app register
        config.models[route.model.name] = route.model
    }
    // if model is not set use model for this node
    if (defined(route.controller) && !defined(route.controller.model)) {
        route.controller.model = route.model
    }
    // instantiate ImmutableCoreController - this will create default controllers
    // for model
    var controller = route.controller = new ImmutableCoreController(route.controller)
    // get all templates then remove those that have controllers
    var bareTemplates = _.cloneDeep(route.templates)
    // iterate over paths
    _.each(controller.paths, path => {
        // iterate over http methods for path
        _.each(path, methods => {
            // iterate over handlers for different roles
            _.each(methods, spec => {
                // role can be specific or default to all
                var role = spec.role || 'all'
                // template can be specified or take from method name
                var template = spec.template || spec.methodName
                // template name exists locally
                if (defined(route.templates[template])) {
                    // if there is a template for the controllers role then remove
                    // it from the list of unused templates
                    if (defined(bareTemplates[template].role[role])) {
                        delete bareTemplates[template].role[role]
                    }
                    // otherwise if there is a template for all roles then assign
                    // it to this controller so that another controller for the
                    // all role will not be created to serve the template
                    else if (defined(bareTemplates[template].role['all'])) {
                        delete bareTemplates[template].role['all']
                    }
                }
            })
        })
    })
    // set to true if any controllers addded
    var added = false
    // create paths for any templates without controllers
    _.each(bareTemplates, (template, templateName) => {
        // iterate over any templates for roles that have not been used
        _.each(template.role, (templatePath, role) => {
            // get path from template name with index becoming /
            var path = templateName === 'index' ? '/' : '/'+templateName
            // create entry for path in controller if not yet defined
            if (!controller.paths[path]) {
                controller.paths[path] = {}
            }
            // create entry for method if not yet defined
            if (!controller.paths[path]['get']) {
                controller.paths[path]['get'] = []
            }
            // add spec for template to controller
            controller.paths[path]['get'].push({
                role: role,
                template: templatePath,
            })
        })
    })
    // if controllers were added then need to reorder controllers
    if (added) {
        controller.orderControllers()
    }
    // get list of path names
    var pathNames = _.keys(controller.paths)
    // sort path names so that static names go above onces with placeholders
    var sortedPathNames = pathNames.sort(sortPlaceholdersLower)
    // create routes for controller paths
    _.each(sortedPathNames, path => {
        var methods = controller.paths[path]
        // add route for each method
        _.each(methods, (spec, method) => {
            // create ImmutableAppPresenter instance
            var presenter = new ImmutableAppPresenter({
                config: config,
                method: method,
                module: module,
                path: path,
                route: route,
                spec: spec,
            })
            // middleware for route
            var routeMiddleware = []
            // iterate over spec(s) for different roles
            _.each(spec, roleSpec => {
                // if spec has middleware add to router
                _.each(roleSpec.middleware, middleware => {
                    routeMiddleware.push(middleware)
                })
            })
            // add presenter as final middleware
            routeMiddleware.push(presenter)
            // add path to router with method
            route.router[method](path, routeMiddleware)
        })
    })
    // return router so it can be bound to parent
    return route.router
}
267794
function(next) {
            if (options.noDb || core.noDb) return next();
            db.initConfig(options, next);
        }
1331861
async function init () {
    // initialze logging
    initLogging(this.immutableApp)
    // initialize global dir config by merging module configs
    initDir(this.immutableApp)
    // initalize handlebars
    initHandlebars(this.immutableApp)
    // initalize express request handling - bodyParser, cookieParser, etc
    initExpress(this.immutableApp)
    // initialize app
    initApp(this.immutableApp)
    // add error handler after all other middleware and routers
    initErrorHandler(this.immutableApp)
    // initialize models
    await initModels(this.immutableApp)
    // intialize components after models since they may use models
    initComponents(this.immutableApp)
    // initialize services after models since they may use models
    await initServices(this.immutableApp)
    // set initialize flag to true
    this.immutableApp.initialized = true
    // debug
    debug('init', this.immutableApp)
}
939959
function initWithFile(configPath){
    var configString = fs.readFileSync(path.resolve(configPath));

    this.config = JSON.parse(configString);
    this.init(this.config);

    return this;
}
1168695
function _initializeServiceOrInstance($inService)
    {
        # Invoke Service Features:
        if ($inService instanceof iServiceFeatureDelegate)
            $inService->delegate($this);


        # initialize with all parent namespaces, from root parent to current last
        $container    = $this;
        $initializers = array();
        while($container->__nestLeft) {
            $container = $container->__nestLeft;
            array_push($initializers, $container->initializer());
        }

        array_push($initializers, $this->initializer());
        foreach($initializers as $initializer)
            $initializer->initialize($inService);

        return $inService;
    }
1220304
@Override
	public void setInitializationData(IConfigurationElement configElem, String propertyName,
			Object data) throws CoreException {

		final String sourceMethod = "setInitializationData"; //$NON-NLS-1$
		boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(sourceClass, sourceMethod, new Object[]{configElem, propertyName, data});
		}
		contributingBundle = Platform.getBundle(configElem.getNamespaceIdentifier());
		if (contributingBundle.getState() != Bundle.ACTIVE) {
			try {
				contributingBundle.start();
			} catch (BundleException e) {
				throw new CoreException(
						new Status(Status.ERROR, configElem.getNamespaceIdentifier(),
								e.getMessage(), e)
						);
			}
		}


		Map<String, String> configMap = new HashMap<String, String>();
		configMap = getConfigMap(configElem);
		initParams = getConfigInitParams(configElem);
		singletonExtensions = new HashMap<String, Object>();

		try {
			BundleContext bundleContext = Activator.getBundleContext();
			platformServices = new PlatformServicesImpl(contributingBundle);
			name = getAggregatorName(configMap);

			// Make sure there isn't already an instance of the aggregator registered for the current name
			if (getPlatformServices().getServiceReferences(
					IAggregator.class.getName(),
					"(name=" + getName() + ")") != null) { //$NON-NLS-1$ //$NON-NLS-2$
				throw new IllegalStateException("Name already registered - " + name); //$NON-NLS-1$
			}
			registerLayerListener();
			executorsServiceTracker = getExecutorsServiceTracker(bundleContext);
			variableResolverServiceTracker = getVariableResolverServiceTracker(bundleContext);
			initExtensions(configElem);
			initOptions(initParams);
			IConfig config = newConfig();
			initWorkingDirectory(configMap, config); // this must be after initOptions
			primeCache(config);
			super.initialize(config);

		} catch (Exception e) {
			throw new CoreException(
					new Status(Status.ERROR, configElem.getNamespaceIdentifier(),
							e.getMessage(), e)
					);
		}

		if (isTraceLogging) {
			log.exiting(sourceClass, sourceMethod);
		}
	}
1003850
function(config) {

        this.config = config;
        this.appContext = null;

        this.injectAppContext = this.config.injectAppContext === true ? true : false;

        //cache of loaded dependencies
        this.moduleMap = {};
    }
193519
public function init(
        array $initial_services     = array(),
        array $services_providers   = array(),
        array $services_protected   = array()
    ) {
        // object can only be initialized once
        if (!is_object($this->_services)) {
            $this->_services                = new Collection();
            $this->_services_protected      = new Collection();
            $this->_services_providers      = new Collection();
            if (!empty($initial_services)) {
                foreach ($initial_services as $_name=>$_service) {
                    $this->setService($_name, $_service);
                }
            }
            if (!empty($services_providers)) {
                foreach ($services_providers as $_name=>$_provider) {
                    $this->setProvider($_name, $_provider);
                }
            }
            if (!empty($services_protected)) {
                foreach ($services_protected as $_name) {
                    $this->setProtected($_name);
                }
            }
        }
        return $this;
    }