2014-11-03 21:29:59 +00:00
|
|
|
/*global define,Promise*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Module defining FrameworkInitializer. Created by vwoeltje on 11/3/14.
|
|
|
|
*/
|
|
|
|
define(
|
|
|
|
[],
|
|
|
|
function () {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {BundleLoader} loader
|
2014-11-04 16:35:06 +00:00
|
|
|
* @param {BundleResolver} resolver
|
2014-11-03 21:29:59 +00:00
|
|
|
* @param {ExtensionRegistrar} registrar
|
|
|
|
* @param {ApplicationBootstrapper} bootstrapper
|
|
|
|
*/
|
|
|
|
function FrameworkInitializer(loader, resolver, registrar, bootstrapper) {
|
|
|
|
|
|
|
|
function registerExtensions(resolvedExtensions) {
|
|
|
|
Object.keys(resolvedExtensions).forEach(function (category) {
|
|
|
|
registrar.registerExtensions(
|
|
|
|
category,
|
|
|
|
resolvedExtensions[category]
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2014-11-04 16:35:06 +00:00
|
|
|
* @param {Bundle[]} bundles
|
2014-11-03 21:29:59 +00:00
|
|
|
* @returns {Object.<string, object[]>} an object mapping
|
|
|
|
*/
|
|
|
|
function resolveExtensions(bundles) {
|
2014-11-04 16:35:06 +00:00
|
|
|
return resolver.resolveBundles(bundles);
|
2014-11-03 21:29:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadBundles(bundleList) {
|
|
|
|
return loader.loadBundles(bundleList);
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
runApplication: function (bundleList) {
|
2014-11-04 16:35:06 +00:00
|
|
|
return loader.loadBundles(bundleList)
|
|
|
|
.then(resolver.resolveBundles)
|
|
|
|
.then(registrar.registerExtensions)
|
2014-11-04 21:00:12 +00:00
|
|
|
.then(bootstrapper.bootstrap);
|
2014-11-04 16:35:06 +00:00
|
|
|
|
2014-11-03 21:29:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return FrameworkInitializer;
|
|
|
|
}
|
|
|
|
);
|