From 5bbbdd4e5008f7acae67c84457a93deb52b8a984 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Thu, 7 Jan 2016 11:31:22 -0800 Subject: [PATCH] [API] Fix explicit implementation assignments --- platform/commonUI/browse/bundle.js | 11 +++++---- platform/framework/src/load/Extension.js | 24 +++++++++++++++++-- .../src/resolve/ExtensionResolver.js | 10 ++++---- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/platform/commonUI/browse/bundle.js b/platform/commonUI/browse/bundle.js index f5e2991dbb..b90dde2263 100644 --- a/platform/commonUI/browse/bundle.js +++ b/platform/commonUI/browse/bundle.js @@ -21,7 +21,10 @@ *****************************************************************************/ /*global define,Promise*/ -define(['legacyRegistry'], function (legacyRegistry) { +define([ + 'legacyRegistry', + './src/BrowseController' +], function (legacyRegistry, BrowseController) { "use strict"; legacyRegistry.register("platform/commonUI/browse", { @@ -41,7 +44,7 @@ define(['legacyRegistry'], function (legacyRegistry) { "controllers": [ { "key": "BrowseController", - "implementation": "BrowseController.js", + "implementation": BrowseController, "depends": [ "$scope", "$route", @@ -55,7 +58,7 @@ define(['legacyRegistry'], function (legacyRegistry) { "key": "PaneController", "implementation": "PaneController.js", "priority": "preferred", - "depends": [ "$scope", "agentService","$window" ] + "depends": [ "$scope", "agentService", "$window" ] }, { "key": "BrowseObjectController", @@ -209,4 +212,4 @@ define(['legacyRegistry'], function (legacyRegistry) { ] } }); -}); \ No newline at end of file +}); diff --git a/platform/framework/src/load/Extension.js b/platform/framework/src/load/Extension.js index d3b19f94fa..4339aeac27 100644 --- a/platform/framework/src/load/Extension.js +++ b/platform/framework/src/load/Extension.js @@ -134,8 +134,28 @@ define( */ Extension.prototype.getImplementationPath = function () { return this.definition.implementation ? - this.bundle.getSourcePath(this.definition.implementation) : - undefined; + this.bundle.getSourcePath(this.definition.implementation) : + undefined; + }; + + /** + * Check if an extension has an actual implementation value + * (and not just a path to an implementation) defined. + * @returns {function} the constructor for this extension instance + */ + Extension.prototype.getImplementationValue = function () { + return typeof this.definition.implementation === 'function' ? + this.definition.implementation : + undefined; + }; + + /** + * Check if an extension has an actual implementation value + * (and not just a path to an implementation) defined. + * @returns {boolean} true if a value is available + */ + Extension.prototype.hasImplementationValue = function () { + return typeof this.definition.implementation === 'function'; }; /** diff --git a/platform/framework/src/resolve/ExtensionResolver.js b/platform/framework/src/resolve/ExtensionResolver.js index 98e8443a03..d0e30124de 100644 --- a/platform/framework/src/resolve/ExtensionResolver.js +++ b/platform/framework/src/resolve/ExtensionResolver.js @@ -61,10 +61,10 @@ define( $log = this.$log; function loadImplementation(extension) { - var implValue = extension.getImplementationPath(), - implPromise = (typeof implValue === 'string') ? - loader.load(implValue) : - Promise.resolve(implValue), + var implPath = extension.getImplementationPath(), + implPromise = extension.hasImplementationValue() ? + Promise.resolve(extension.getImplementationValue()) : + loader.load(implPath), definition = extension.getDefinition(); // Wrap a constructor function (to avoid modifying the original) @@ -122,7 +122,7 @@ define( // Log that loading has begun $log.info([ "Loading implementation ", - implValue, + implPath, " for extension ", extension.getLogName() ].join(""));