diff --git a/platform/framework/src/Main.js b/platform/framework/src/Main.js index f8765bd9cf..341a1c8b0d 100644 --- a/platform/framework/src/Main.js +++ b/platform/framework/src/Main.js @@ -1,4 +1,4 @@ -/*global define, requirejs*/ +/*global define, window, requirejs*/ requirejs.config({ "shim": { @@ -13,20 +13,67 @@ define( 'require', '../lib/es6-promise-2.0.0.min', '../lib/angular.min', - './BundleLoader' + './Constants', + './FrameworkInitializer', + './BundleLoader', + './ImplementationLoader', + './ExtensionResolver', + './BundleResolver', + './CustomRegistrars', + './ExtensionRegistrar', + './ApplicationBootstrapper' ], - function (require, es6promise, angular) { + function (require, + es6promise, + angular, + Constants, + FrameworkInitializer, + BundleLoader, + ImplementationLoader, + ExtensionResolver, + BundleResolver, + CustomRegistrars, + ExtensionRegistrar, + ApplicationBootstrapper + ) { "use strict"; + // Get a reference to Angular's injector, so we can get $http and $log + // services, which are useful to the framework layer. var injector = angular.injector(['ng']); // Polyfill Promise, in case browser does not natively provide Promise window.Promise = window.Promise || es6promise.Promise; - injector.invoke(['$http', function ($http) { - return $http.get('bundles.json').then(function (b) { - console.log(b); - }); - }]); + // Wire up framework layer components necessary to complete framework + // initialization phases. + function initializeApplication($http, $log) { + var app = angular.module(Constants.MODULE_NAME, []), + loader = new BundleLoader($http, $log), + resolver = new BundleResolver(new ExtensionResolver( + new ImplementationLoader(require), + $log + )), + registrar = new ExtensionRegistrar( + app, + new CustomRegistrars(app, $log), + $log + ), + bootstrapper = new ApplicationBootstrapper( + angular, + window.document + ), + initializer = new FrameworkInitializer( + loader, + resolver, + registrar, + bootstrapper + ); + + $log.info("Initializing application."); + initializer.runApplication(Constants.BUNDLE_LISTING_FILE); + } + + injector.invoke(['$http', '$log', initializeApplication]); } ); \ No newline at end of file