Author: reebalazs
Date: Fri Dec 28 12:42:30 2007
New Revision: 50156
Modified:
kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed)
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js
Log:
Fix interfaces in a way that unregistered plugins are not finalized.
This allows the applicaton to assume that if it finds a
plugin, its config is returned.
Modified:
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js
==============================================================================
--- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js
(original)
+++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js
Fri Dec 28 12:42:30 2007
@@ -127,8 +127,14 @@
;;; kukit.logDebug(kukit.E);
// Finalize all methods.
this.forEachMethod(function(methodName, methodDescriptor) {
- // finalize the functions and store them on the singleton
- singleton[methodName] = methodDescriptor.finalize(loader);
+ // finalize the attributes and store them on the singleton
+ //
+ // Get the finalized value for this attribute
+ var value = methodDescriptor.finalize(loader);
+ if (typeof(value) != 'undefined') {
+ // Set the attribute on the singleton
+ singleton[methodName] = value;
+ };
});
// Store the singleton itself on interfaces
this.interfaces[this.name] = singleton;
@@ -282,10 +288,13 @@
this.iface = iface;
this.methodName = methodName;
- this.config = null;
+ // Set the config to undefined, this means that methods
+ // that were fetched but not registered during the configuration,
+ // will not be finalized.
+ this.config = undefined;
this.register = function(config) {
- if (this.config != null) {
+ if (typeof(this.config) != 'undefined') {
;;; kukit.E = 'Double registration of method [' + this.methodName;
;;; kukit.E += '] in plugin interface [' + this.iface.name + ']';
throw new Error(kukit.E);
@@ -295,6 +304,10 @@
this.finalize = function(loader) {
// Just return the registered value.
+ // If register was not called, we will return undefined,
+ // which means the method will not be finalized on the
+ // interface. This makes sure that if the registry is found,
+ // it will for sure have a value.
return this.config;
};
Modified:
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js
==============================================================================
---
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js
(original)
+++
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js
Fri Dec 28 12:42:30 2007
@@ -471,6 +471,20 @@
this.assertNotEquals(M.prototype.__className__,
MSub.prototype.__className__);
};
+ this.testOnlyRegisteredPluginsAreFinalized = function() {
+ // We assure that if a method descriptor is get but it is not
registered,
+ // it will not be finalized on the configuration.
+ // Let's create a TestDummy interface.
+ var events = this.interfaces.get('dummyevents',
kukit.interfaces.PluginMethodDescriptor);
+ // Just call up the method descriptor: this will create it with
config=null.
+ events.getMethodDescriptor('click');
+ // finalize
+ events.finalize({});
+ // Check that click is not defined at all. (in particular, it should
not be null or {}.)
+ // Since other code that uses it, depends that if it has a value, it
is the real config.
+ this.assertEquals(typeof(this.interfaces.dummyevents.click),
'undefined');
+ };
+
}; /* end PluginInterfacesTestCase */
kukit.PluginInterfacesTestCase.prototype = new kukit.InterfacesTestCaseBase();
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins