From gotcha at codespeak.net Sun Oct 12 19:00:25 2008 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 12 Oct 2008 19:00:25 +0200 (CEST) Subject: [KSS-checkins] r59042 - kukit/kss.buildout/branch/service-layer Message-ID: <20081012170025.EF9A116A257@codespeak.net> Author: gotcha Date: Sun Oct 12 19:00:25 2008 New Revision: 59042 Added: kukit/kss.buildout/branch/service-layer/ - copied from r59041, kukit/kss.buildout/branch/jscoverage/ Log: prepare for review From gotcha at codespeak.net Sun Oct 12 19:07:05 2008 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 12 Oct 2008 19:07:05 +0200 (CEST) Subject: [KSS-checkins] r59044 - kukit/kss.buildout/branch/service-layer/src Message-ID: <20081012170705.38F3416A29F@codespeak.net> Author: gotcha Date: Sun Oct 12 19:07:04 2008 New Revision: 59044 Modified: kukit/kss.buildout/branch/service-layer/src/ (props changed) kukit/kss.buildout/branch/service-layer/src/EXTERNALS.txt Log: right dependencies Modified: kukit/kss.buildout/branch/service-layer/src/EXTERNALS.txt ============================================================================== --- kukit/kss.buildout/branch/service-layer/src/EXTERNALS.txt (original) +++ kukit/kss.buildout/branch/service-layer/src/EXTERNALS.txt Sun Oct 12 19:07:04 2008 @@ -6,6 +6,6 @@ # # svn propset svn:externals -F EXTERNALS.txt . # -kss.core https://codespeak.net/svn/kukit/kss.core/branch/jscoverage -kss.demo https://codespeak.net/svn/kukit/kss.demo/branch/jscoverage +kss.core https://codespeak.net/svn/kukit/kss.core/branch/ree-service-layer-and-refactoring +kss.demo https://codespeak.net/svn/kukit/kss.demo/trunk From kukit-checkins at codespeak.net Fri Oct 24 07:22:52 2008 From: kukit-checkins at codespeak.net (kukit-checkins at codespeak.net) Date: Fri, 24 Oct 2008 07:22:52 +0200 (CEST) Subject: VIAGRA ® Official Site Message-ID: <20081024182223.70796.qmail@cc35x2.sels.ru> An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/kukit-checkins/attachments/20081024/da554538/attachment.htm From gotcha at codespeak.net Sun Oct 26 12:03:37 2008 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 26 Oct 2008 12:03:37 +0100 (CET) Subject: [KSS-checkins] r59412 - kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit Message-ID: <20081026110337.12CEA169FDC@codespeak.net> Author: gotcha Date: Sun Oct 26 12:03:36 2008 New Revision: 59412 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Log: change wording : interface to registry 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 Sun Oct 26 12:03:36 2008 @@ -15,7 +15,7 @@ * that results from these calls. * * In case of an action plugin, this is just storing registry info - * keyed by the action name. However in case of a service interface, + * keyed by the action name. However in case of a service registry, * different components may provide the requested item, and the final * value of the method is decided at finalization and all this logic * is handled by the Factory. In case of service @@ -46,9 +46,9 @@ * javascript file does the initialization for itself, (or otherwise * can assume that it cas been called by preceding code like in the * case of the plugins), then the order of these javascripts is - * arbitrary for interfaces to work. + * arbitrary for registries to work. * - * In the initialization the interface name and the item factory + * In the initialization the registry name and the item factory * need to be supplied as parameters. * * registries.initializeRegistry('myregistry', MyFactory); @@ -242,7 +242,7 @@ // it's a conflict. if (registrar.Factory != Factory) { ;;; kukit.E = 'Registries.initializeRegistry() is called for registry ['; -;;; kukit.E += interfaceName + '] with a different Factory than earlier.'; +;;; kukit.E += registryName + '] with a different Factory than earlier.'; throw new Error(kukit.E); } } @@ -308,7 +308,7 @@ ;;; kukit.E = 'Double registration by [' + config.sourceName + ']['; ;;; kukit.E += providerVersion; ;;; kukit.E += '] of method [' + this.name; -;;; kukit.E += '] in interface [' + this.registrar.registryName + ']'; +;;; kukit.E += '] in registry [' + this.registrar.registryName + ']'; throw new Error(kukit.E); } // Store the config @@ -459,7 +459,7 @@ this._register = function(config) { if (this.config != null) { ;;; kukit.E = 'Double registration of item [' + this.name; -;;; kukit.E += '] in plugin interface [' + this.registrar.registryName + ']'; +;;; kukit.E += '] in plugin registry [' + this.registrar.registryName + ']'; throw new Error(kukit.E); } // Do some diagnostics // check the iterator. @@ -507,7 +507,7 @@ * the only support needed is for tests to establish a clean room. * For this, we provide simple save and restore methods. These can * be called from setUp and tearDown of tests that want to provide their - * own interfaces setup. + * own registries setup. * */ @@ -573,7 +573,7 @@ /* * Plugin registration method * - * To allow an easy way to register plugin interfaces, a + * To allow an easy way to register plugin registries, a * simple method is provided. * * This appends a batch of information into the plugin @@ -588,9 +588,9 @@ */ this.registerPlugins = function(items, registries) { - // interfaces is optional, and mainly used for tests + // registries is optional, and mainly used for tests if (typeof(registries) == 'undefined') { - // use global interfaces + // use global registries registries = kukit.pluginregistry; } // From gotcha at codespeak.net Sun Oct 26 12:15:24 2008 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 26 Oct 2008 12:15:24 +0100 (CET) Subject: [KSS-checkins] r59413 - kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit Message-ID: <20081026111524.0708E169ED8@codespeak.net> Author: gotcha Date: Sun Oct 26 12:15:23 2008 New Revision: 59413 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Log: remove unneeded function 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 Sun Oct 26 12:15:23 2008 @@ -486,19 +486,6 @@ }; /* end BindSequenceFactory */ - - -/* - * Instantiation - */ - -this._createGlobalRegistries = function() { - // create registries - kukit.pluginregistry = new this.NamedRegistries(); - kukit.service = new this.NamedRegistries(); -}; - - /* * Global handling of registries in kukit * @@ -514,9 +501,6 @@ this.cleanRoomSetUp = function(suite) { this._saved_pluginregistry = kukit.pluginregistry; this._saved_service = kukit.service; - // now create registries - this._createGlobalRegistries(); - // and initialize them this.initializeGlobalRegistries(); }; @@ -542,6 +526,9 @@ // Initialize global registries this.initializeGlobalRegistries = function() { + // instantiate registries + kukit.pluginregistry = new this.NamedRegistries(); + kukit.service = new this.NamedRegistries(); var r = kukit.pluginregistry; r.initializeRegistry('events', this.PluginFactory); r.initializeRegistry('bindsequences', this.BindSequenceFactory); @@ -562,12 +549,10 @@ schema.core.bindItems({}); }; -// Now, create the global registries -this._createGlobalRegistries(); // At this point we initialize the registries used by kukit, that means // any code can use them from top level, without initialization. this.initializeGlobalRegistries(); -// The finalization of these registries will be done from bootstrap. +// The finalization of these registries is done from bootstrap. /* From gotcha at codespeak.net Sun Oct 26 12:22:29 2008 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 26 Oct 2008 12:22:29 +0100 (CET) Subject: [KSS-checkins] r59414 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: kukit tests Message-ID: <20081026112229.50F9B169ED8@codespeak.net> Author: gotcha Date: Sun Oct 26 12:22:28 2008 New Revision: 59414 Added: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js (contents, props changed) - copied, changed from r59413, kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_registries.js (contents, props changed) - copied, changed from r59044, kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js Removed: 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 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runner.html kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.sh Log: rename files : from interfaces to registries Deleted: /kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js ============================================================================== --- /kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js Sun Oct 26 12:22:28 2008 +++ (empty file) @@ -1,621 +0,0 @@ - -kukit.ifa = new function() { /* BEGIN CLOSURE kukit.ifa */ - -/* - * Kukit registry - * - * We want a way to initialize a set of registration items. An item can - * be the descriptor of an event, action, etc., or method of a service - * API. The initialization of these items depends only on - * what javascript code is present and how it is defining these - * items. - * - * The items have a factory that provides various - * methods that can be called on it, as well as a state - * that results from these calls. - * - * In case of an action plugin, this is just storing registry info - * keyed by the action name. However in case of a service registry, - * different components may provide the requested item, and the final - * value of the method is decided at finalization and all this logic - * is handled by the Factory. In case of service - * registries, this allows that "define service" and "provide service" - * sections can be in different javascript files (plugins), and the - * final outcome is independent of the order of their execution. - * - * The order in which they are loaded is irrelevant, provided they - * load after interfaces.js. - * - * Managing the schema - * ------------------- - * - * When various javascript code is loaded, it can set up the - * schema for the registry it handles. For example, during the - * loading of javascript, plugin code set up its registry, other code - * sets up core services it provides or depends on. - * - * The registries are managed by name in a collection of registries. - * Before accessing the schema of any registry, it needs to - * be initialized at one of the names registries object. - * This may be happen several times, but at - * least once it has been done before the schema is looked up from - * code. - * - * This is the only dependency what we have for the order of the code. - * Ewerywhere else, order is independent. This means that if all - * javascript file does the initialization for itself, (or otherwise - * can assume that it cas been called by preceding code like in the - * case of the plugins), then the order of these javascripts is - * arbitrary for registries to work. - * - * In the initialization the registry name and the item factory - * need to be supplied as parameters. - * - * registries.initializeRegistry('myregistry', MyFactory); - * - * After this the registrar object can be looked up with: - * - * var registrar = registries.schema.myregistry; - * - * Or the schema of an attribute can be looked up, and various methods - * can be called on it. This depends on what the attribute class - * actually implements. - * - * var factory = registries.schema.myregistry.getItemFactory('mykey'); - * factory.doWhateverTheFactoryImplements(blah); - * - * This concludes everything we can do, before binding the registry. - * Binding freezes the factorization of items in the registrar and - * allows its direct use, without the schema. For the binding, a - * singleton registry object has to be provided. The items are - * bound on this registry. - * - * registrar.bindItems(registry); - * - * In most cases, the registry can simply be a normal object. So - * the usual setup what we have a registry for plugins is: - * - * registrar.bindItems({}); - * - * However a registry could have attributes inherited with - * a prototype, and if we want to have this, we could bind the items - * on an object with a different prototype. - * - * After being bound, the registry set up, - * will appear directly accessable from registries. - * - * registries.myregistry == registry - * - * This will be identical to the registry object we bound to. - * The registry contains our items directly. (not the factory, - * but already the actual item values as returned be the factory's - * getItem method.) - * - * registries.myregistry.mykey == item - * - * After being bound, all named registries can be accessed from - * the registries object, e.g. in the following way: - * - * registries.events.click - is an event's registry - * registries.actions.setAttr - is an action's registry - * registries.core.cssQuery - is a core service method - * registries.core.forEach - is a core service method - * - * Kukit sets up the following registries for its own use. The - * binding of these registries is done by kukit at the beginning - * of bootstrap. - * - * Created on the global registries "kukit.pluginregistry": - * - * name purpose attribute class - * ---- ------- --------------- - * events kss event name registry kukit.ifa.PluginFactory - * bindsequences kss event binding reg. kukit.ifa.BindSequenceFactory - * actions kss action registry kukit.ifa.PluginFactory - * valueproviders value provider registry kukit.ifa.PluginFactory - * - * Created on the global registries "kukit.service": - * - * name purpose attribute class - * ---- ------- --------------- - * core core services kukit.ifa.ServiceFactory - * - * - * For more information, see ../tests/test_interfaces.js . - * - */ - -var Registrar = function() { - - this.initialize = function(namedRegistries, registryName, Factory) { - this.namedRegistries = namedRegistries; - this.registryName = registryName; - this.bound = false; - this.factories = {}; - this.Factory = Factory; - }; - - this.getItemFactory = function(name) { - // create the attribute on demand - var factory = this.factories[name]; - if (typeof(factory) == 'undefined') { - // Use the registry in the instance, to look up the MethodDescriptor class - // for this method name - // - // instantiate the factory - factory = this.factories[name] = new this.Factory(this, name); - } - return factory; - }; - - /* Iterate a function on each factory of this registrar */ - - this.forEachFactory = function(f, a1, a2, a3, a4, a5) { - // Apply f for each factory. - // f will receive attributeName, attribute, and the rest - // of the parameters passed to forEachFactory. - // methodName and MethodDescriptor will be passed to f as parameters. - // Extra arguments will be passed in addition. - for (var name in this.factories) { - var factory = this.factories[name]; - // Provide the necessary parameters and call f - f(name, factory, a1, a2, a3, a4, a5); - } - }; - - this.bindItems = function(registry, loader) { - // singleton: the singleton we want to finalize on. - // loader (optional): use it for all operations - // (this means we never get errors but the loader - // will be set up to load missing resources) - // - // Check if we are finalized. - if (this.bound) { -;;; kukit.E = 'Attempt to bind already bound registry ['; -;;; kukit.E += this.registryName + ']'; - throw new Error(kukit.E); - } -;;; kukit.E = 'Binding registry [' + this.registryName + ']'; -;;; kukit.logDebug(kukit.E); - // Finalize all methods. - this.forEachFactory(function(name, factory) { - // finalize the attributes and store them on the registry - // - - // Get the finalized item from this factory - var item = factory.produceItem(loader); - if (typeof(item) != 'undefined') { - // Set the item on the registry - registry[name] = item; - }; - }); - // Store the registry itself on the registries - // this means that it can be accessed as registries.registryname - this.namedRegistries[this.registryName] = registry; - // Set bound state. - // We are bound if the loader has no items to load. - // If there is no loader, we are always bound at this point. - this.bound = ! loader || loader.empty(); -;;; if (! this.bound) { -;;; kukit.E = 'Postpone binding of registry [' + this.registryName + '],'; -;;; kukit.E = ' and request sources [', loader.getSources() + ']'; -;;; kukit.logDebug(kukit.E); -;;; } - }; - - this.initialize.apply(this, arguments); - -}; /* end Registrar */ - -this.NamedRegistries = function() { - - this.schema = {}; - - this.initializeRegistry = function(registryName, Factory) { - // This sets up the registry given by name with the - // specified Factory class, or checks it. - // This method needs to be called preceding the calls - // to getItemFactory on the given registrar. - // It can be called more times for the same registry. - // -;;; // Check for missing parameter; this will cause an error later anyway. -;;; if (! Factory) { -;;; kukit.E = 'Registries.initializeRegistry() is called for registry ['; -;;; kukit.E += registryName + '] without a Factory parameter.'; -;;; throw new Error(kukit.E); -;;; } - // Check prohibited names - if (registryName == 'schema' || registryName == 'initializeRegistry') { -;;; kukit.E = 'Registries.initializeRegistry() cannot be called '; -;;; kukit.E += 'with a reserved name ['; -;;; kukit.E += registryName + '].'; - throw new Error(kukit.E); - } - // see if we already have this registrar - var registrar = this.schema[registryName]; - // create the registrar on demand - if (typeof(registrar) == 'undefined') { - // create the registrar and store it on myself - this.schema[registryName] = new Registrar(this, registryName, Factory); - } else { - // check that the same Factory was provided. If not, - // it's a conflict. - if (registrar.Factory != Factory) { -;;; kukit.E = 'Registries.initializeRegistry() is called for registry ['; -;;; kukit.E += registryName + '] with a different Factory than earlier.'; - throw new Error(kukit.E); - } - } - }; - -}; /* end NamedRegistries */ - -/* - * KSS service layer resource - */ - -this.ServiceFactory = function() { - - this.initialize = function(registrar, name) { - this.registrar = registrar; - this.name = name; - this.sources = {}; - this.preferredSources = null; - }; - -;;; this._makeError = function(componentName, name) { -;;; kukit.E = 'In a call to ' + componentName + ', '; -;;; kukit.E += name + ' must be provided for method ['; -;;; kukit.E += this.name + '] on registry ['; -;;; kukit.E += this.registrar.registryName + ']'; -;;; return new Error(kukit.E); -;;; }; - - this.require = function(config) { -;;; // Diagnose if parameters are all right. -;;; if (! config.preferredSources) { -;;; throw this._makeError('ServiceFactory.require', 'config.getter'); -;;; }; - if (this.preferredSources) { -;;; kukit.E = 'ServiceFactory.require is called twice on ['; -;;; kukit.E += this.name + '] on registry ['; -;;; kukit.E += this.registrar.registryName + ']'; - throw new Error(kukit.E); - }; - this.preferredSources = config.preferredSources; - this.checker = config.checker; - this.fallbackProvider = config.fallbackProvider; - }; - - this.provide = function(config) { -;;; // Diagnose if parameters are all right. -;;; var componentName = 'ServiceFactory.provide'; -;;; if (! config.getter) { -;;; throw this._makeError(componentName, 'config.getter'); -;;; } -;;; if (! config.sourceName) { -;;; throw this._makeError(componentName, 'config.sourceName'); -;;; } -;;; if (! config.sourceVersion) { -;;; throw this._makeError(componentName, 'config.sourceVersion'); -;;; } - if (this.registrar.bound) { -;;; kukit.E = 'Attempt to provide implementation to method ['; -;;; kukit.E += this.methodName + '] on already finalized registry ['; -;;; kukit.E += this.registrar.registryName + ']'; - throw new Error(kukit.E); - } else if (typeof(this.sources[config.sourceName]) != 'undefined') { -;;; kukit.E = 'Double registration by [' + config.sourceName + ']['; -;;; kukit.E += providerVersion; -;;; kukit.E += '] of method [' + this.name; -;;; kukit.E += '] in registry [' + this.registrar.registryName + ']'; - throw new Error(kukit.E); - } - // Store the config - config.methodName = this.name; - this.sources[config.sourceName] = config; - }; - - this.produceItem = function(loader) { - var func; - if (! this.preferredSources) { -;;; kukit.E = 'Undefined method ['; -;;; kukit.E += this.name + '] on registry ['; -;;; kukit.E += this.registrar.registryName + '], '; -;;; kukit.E += 'but the following were provided:'; -;;; kukit.E += this.sources + ']'; - throw new Error(kukit.E); - } - // loop through all preferred providers - for (var i = 0; i < this.preferredSources.length; i++) { - var item = this.sources[this.preferredSources[i]]; - // Did we have an item? - if (typeof(item) == 'undefined') { - continue; - } - // Execute the item's getter - func = item.getter(); - // Did it return the function? - if (func) { - // found it - break; - } - // if not, we continue with the next best choice. - } - if (! func) { - if (typeof(loader) != 'undefined') { - // We have a loading method. Let's add our needs. - loader.add(this.fallbackProvider); - // ... and simply go on. - return; - } else { - // We raise an error. -;;; kukit.E = 'Could not bind item ['; -;;; kukit.E += this.name + '] on registry ['; -;;; kukit.E += this.registrar.registryName; -;;; kukit.E += '], because no provider found '; -;;; kukit.E += 'of the following preferences: ['; -;;; kukit.E += this.preferredSources + ']'; - throw new Error(kukit.E); - } - } else { - // We found the func that we can finalze now. -;;; kukit.E = 'Using method ['; -;;; kukit.E += this.name + '] from source ['; -;;; kukit.E += item.sourceName + '] version ['; -;;; kukit.E += item.sourceVersion + '].'; -;;; kukit.log(kukit.E); - // Return the func, optionally prefixed with a checker. - if (this.checker) { - // if there is a checker, merge them together - var self = this; - return function() { - self.checker.apply(null, arguments); - return func.apply(null, arguments); - }; - } else { - // else, just store the function - return func; - } - } - }; - - this.initialize.apply(this, arguments); - -}; /* end ServiceFactory */ - - -/* - * KSS plugin registry - */ - -this.PluginFactory = function() { - - this.initialize = function(registrar, name) { - this.registrar = registrar; - this.name = name; - // Set the config to undefined, this means that the items - // that were produced but not registered during the configuration, - // will not be bound. - this.config = undefined; - }; - - this.register = function(config) { - if (typeof(this.config) != 'undefined') { -;;; kukit.E = 'Double registration of plugin [' + this.name; -;;; kukit.E += '] in registry [' + this.registrar.registryName + ']'; - throw new Error(kukit.E); - } - this.config = config; - }; - - this.produceItem = function(loader) { - // Just return the registered item. - // If register was not called, we will return undefined, - // which means the method will not be bound on the - // registry. This makes sure that if the item is found, - // it will for sure have a value. - return this.config; - }; - - this.initialize.apply(this, arguments); - -}; /* end PluginFactory */ - -/* - * BindSequenceFactory - * - * We need this factory because we need to - * register the binding of events. This is done by a binding - * class and a set of events that bind together on this - * class, and a binding strategy that defines how binding will - * be called. - * - * The event names arrive in a namespace format (dash-separated), - * formerly we only accepted to register an event set with events - * of the same namespace. This restriction is dropped now. Since it - * may make sense, it can be put back in form of asserts on the - * event names. - */ -this.BindSequenceFactory = function() { - - this.initialize = function(registrar, name) { - this.registrar = registrar; - this.name = name; - this.config = null; - }; - - this.register = function(config) { - // This is called on any method descriptors, - // i.e. this is a "class method". - // Register config to all event names individually. - // Take names from the config. - for (var i = 0; i < config.eventNames.length; i++) { - var name = config.eventNames[i]; - this.registrar.getItemFactory(name)._register(config); - } - }; - - this._register = function(config) { - if (this.config != null) { -;;; kukit.E = 'Double registration of item [' + this.name; -;;; kukit.E += '] in plugin registry [' + this.registrar.registryName + ']'; - throw new Error(kukit.E); - } - // Do some diagnostics // check the iterator. -;;; if (! kukit.er.getBindIterator(config.iterName)) { -;;; kukit.E = 'In BindSequenceFactory.register: unknown bind strategy ['; -;;; kukit.E += config.iterName + '].'; -;;; throw new Error(kukit.E); -;;; } - - // Decorate binder class. - kukit.er.decorateEventBinderClass(config.binderClass); - - // store the config - this.config = config; - - }; - - this.produceItem = function(loader) { - // Just return the registered value. - return this.config; - }; - - this.initialize.apply(this, arguments); - -}; /* end BindSequenceFactory */ - -/* - * Global handling of registries in kukit - * - * If we want to use registries in a more placeful way, we can provide - * cloning ang merging to them. Since we don't really use them this way, - * the only support needed is for tests to establish a clean room. - * For this, we provide simple save and restore methods. These can - * be called from setUp and tearDown of tests that want to provide their - * own registries setup. - * - */ - -this.cleanRoomSetUp = function(suite) { - this._saved_pluginregistry = kukit.pluginregistry; - this._saved_service = kukit.service; - this.initializeGlobalRegistries(); -}; - -this.cleanRoomFinalize = function(suite) { - // Need to finalize (bind) these registries - this.finalizeGlobalRegistries(); -}; - -this.cleanRoomTearDown = function(suite) { - // Revert the saved state - kukit.pluginregistry = this._saved_pluginregistry; - kukit.service = this._saved_service; -}; - -/* These methods handle the specific registries - * used by kukit itself. They are two of then, - * stored globally: - * - * kukit.pluginregistry Plugin registration - * kukit.service Service layer - * - */ - -// Initialize global registries -this.initializeGlobalRegistries = function() { - // instantiate registries - kukit.pluginregistry = new this.NamedRegistries(); - kukit.service = new this.NamedRegistries(); - var r = kukit.pluginregistry; - r.initializeRegistry('events', this.PluginFactory); - r.initializeRegistry('bindsequences', this.BindSequenceFactory); - r.initializeRegistry('actions', this.PluginFactory); - r.initializeRegistry('valueproviders', this.PluginFactory); - r = kukit.service; - r.initializeRegistry('core', this.ServiceFactory); -}; - -// Finalize global registries -this.finalizeGlobalRegistries = function() { - var schema = kukit.pluginregistry.schema; - schema.events.bindItems({}); - schema.bindsequences.bindItems({}); - schema.actions.bindItems({}); - schema.valueproviders.bindItems({}); - schema = kukit.service.schema; - schema.core.bindItems({}); -}; - -// At this point we initialize the registries used by kukit, that means -// any code can use them from top level, without initialization. -this.initializeGlobalRegistries(); -// The finalization of these registries is done from bootstrap. - - -/* - * Plugin registration method - * - * To allow an easy way to register plugin registries, a - * simple method is provided. - * - * This appends a batch of information into the plugin - * registry. - * - * It is intended to be the new method for registering - * plugins. It also fulfills the need that we will - * be able to parse the actual information from the - * javascript files, and access the complete plugin - * registry, from the server side. - * - */ - -this.registerPlugins = function(items, registries) { - // registries is optional, and mainly used for tests - if (typeof(registries) == 'undefined') { - // use global registries - registries = kukit.pluginregistry; - } - // - for (var i=0; i - @@ -115,7 +115,7 @@ - + Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.sh ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.sh (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.sh Sun Oct 26 12:22:28 2008 @@ -8,7 +8,7 @@ -f ../3rd_party/johnnydebris.net/dommer/dommer.js \ -f ../kukit/kukit.js \ -f ../kukit/utils.js \ - -f ../kukit/interfaces.js \ + -f ../kukit/registries.js \ -f ../kukit/errors.js \ -f ../kukit/oper.js \ -f ../kukit/tokenizer.js \ @@ -31,6 +31,6 @@ -f test_requestmanager.js \ -f test_tokenizer.js \ -f test_kssparser.js \ - -f test_interfaces.js \ + -f test_registries.js \ -f test_errors.js \ runtests.js Deleted: /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 Sun Oct 26 12:22:28 2008 +++ (empty file) @@ -1,683 +0,0 @@ -/* -* Copyright (c) 2005-2007 -* Authors: KSS Project Contributors (see doc/CREDITS.txt) -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 as published -* by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -* 02111-1307, USA. -*/ - -if (typeof(kukit) == "undefined") { - var kukit = {}; -} - -kukit.InterfacesTestCaseBase = function() { - this.setUp = function() { - // work with our own object, not interfering - //interfaces.js - this.registries = new kukit.ifa.NamedRegistries(); - }; -}; /* end InterfacesTestCase */ -kukit.InterfacesTestCaseBase.prototype = new kukit.UtilsTestCaseBase(); - -kukit.InterfacesTestCase = function() { - this.name = 'kukit.InterfacesTestCase'; - /* - * Plugin registries - */ - - var called = []; - - var TestFactory = function(registrar, name) { - this.registrar = registrar; - this.name = name; - this.doThis = function() { - called.push("doThis"); - } - this.doThat = function() { - called.push("doThat"); - } - this.produceItem = function(loader) { - var signature = "FUNC " + this.name; - called.push(signature); - return signature; - } - }; - - this.testInterfaces = function() { - // We can create a simple method descriptor for an interface we want. - // The method descriptor is managing the method's registration state - called = []; - // Let's create a registry that uses TestFactory. - // We need to initialize it - this.registries.initializeRegistry('dummytest', TestFactory); - // Now we can access the schema. - var registrar = this.registries.schema.dummytest; - this.assert(typeof(registrar), 'object'); - // Let's get two items - registrar.getItemFactory('fooItem').doThis() - registrar.getItemFactory('barItem').doThat() - // Check - this.assertListEquals(called, ['doThis', 'doThat']); - called = []; - // Ok. Now get the descriptors again... - registrar.getItemFactory('fooItem').doThis() - registrar.getItemFactory('barItem').doThat() - // Check - this.assertListEquals(called, ['doThis', 'doThat']); - called = []; - // - // Now let's iterate on all factories: - registrar.forEachFactory(function(name, factory) { - factory.doThis(); - }); - // Check - this.assertListEquals(called, ['doThis', 'doThis']); - called = []; - }; - - this.testReservedInterfaceNames = function() { - // Reserved registry names are prohibited. - // (thex would conflict with the NamedRegistries class) - var self = this; - this.assertThrows(function() { - this.registries.initializeRegistry('initializeRegistry', TestFactory); - }, - Error); - this.assertThrows(function() { - this.registries.initializeRegistry('schema', TestFactory); - }, - Error); - }; - - this.testFinalizeInterfaces = function() { - // We have a singleton, called s. - var s = {}; - // We eill create a simple item for a selected registry. - // The factory is managing the item's registration state - called = []; - // Let's initialize a dummytest registry. - this.registries.initializeRegistry('dummytest', TestFactory); - var registrar = this.registries.schema.dummytest; - // Let's get two factories - registrar.getItemFactory('fooItem').doThis() - registrar.getItemFactory('barItem').doThat() - // Check - this.assertListEquals(called, ['doThis', 'doThat']); - called = []; - // - // At this point we are also ready to bind the items the registrar. - registrar.bindItems(s); - // This binds all the items. - this.assertListEquals(called, ['FUNC fooItem', 'FUNC barItem']); - called = []; - // At the same time it also set up these on the class prototype. - this.assertEquals(this.registries.dummytest.fooItem, 'FUNC fooItem'); - this.assertEquals(this.registries.dummytest.barItem, 'FUNC barItem'); - }; - - this.testInitializationIsRepeatable = function() { - // Let's have a second factory - var TestFactory2 = function(registrar, name) { - this.registrar = registrar; - this.name = name; - this.bindItems = function(loader) { - var signature = "REG2 " + this.name; - return signature; - } - }; - // Let's initialize a dummytest registry. - this.registries.initializeRegistry('dummytest', TestFactory); - // We can get the same registry again... - this.registries.initializeRegistry('dummytest', TestFactory); - // however not with a different Factory! - var self = this; - this.assertThrows(function() { - this.registries.initializeRegistry('dummytest', TestFactory2); - }, - Error); - // - // On the other hand setting up with a second registry, is no problem. - this.registries.initializeRegistry('dummytest2', TestFactory2); - }; - -}; /* end InterfacesTestCase */ -kukit.InterfacesTestCase.prototype = new kukit.InterfacesTestCaseBase(); - - -kukit.ServiceInterfacesTestCase = function() { - this.name = 'kukit.ServiceInterfacesTestCase'; - /* - * Service registries - */ - this.setUp = function() { - // work with our own registries, not interfering - // kukit.service or kukit.pluginregistry. - this.registries = new kukit.ifa.NamedRegistries(); - // Let's initialize a dummyservice registry. - this.registries.initializeRegistry('dummyservice', kukit.ifa.ServiceFactory); - }; - - this.testServiceInterfaces = function() { - // We have a singleton, called s. - var s = {}; - var registrar = this.registries.schema.dummyservice; - // Requires four methods, thie defines their necessity and preferred providers - registrar.getItemFactory('first').require({ - preferredSources: ['corelib', 'extralib']}); - registrar.getItemFactory('second').require({ - preferredSources: ['extralib', 'corelib']}); - registrar.getItemFactory('third').require({ - preferredSources: ['corelib']}); - registrar.getItemFactory('fourth').require({ - preferredSources: ['extralib']}); - // - // somewhere else, source "corelib" provides the methods: - registrar.getItemFactory('first').provide({ - sourceName: 'corelib', - sourceVersion: '1.1', - getter: function() {return function() {return 'first/core';}}}); - registrar.getItemFactory('second').provide({ - sourceName: 'corelib', - sourceVersion: '1.1', - getter: function() {return function() {return 'second/core';}}}); - registrar.getItemFactory('third').provide({ - sourceName: 'corelib', - sourceVersion: '1.1', - getter: function() {return function() {return 'third/core';}}}); - // - // somewhere else, source "extras" provides the methods: - registrar.getItemFactory('first').provide({ - sourceName: 'extralib', - sourceVersion: '12.4', - getter: function() {return function() {return 'first/extra';}}}); - registrar.getItemFactory('second').provide({ - sourceName: 'extralib', - sourceVersion: '12.4', - getter: function() {return function() {return 'second/extra';}}}); - registrar.getItemFactory('fourth').provide({ - sourceName: 'extralib', - sourceVersion: '12.4', - getter: function() {return function() {return 'fourth/extra';}}}); - // - // Now bind the items. - registrar.bindItems(s); - // We can call the methods on it, - this.assertEquals(this.registries.dummyservice.first(), 'first/core'); - this.assertEquals(this.registries.dummyservice.second(), 'second/extra'); - this.assertEquals(this.registries.dummyservice.third(), 'third/core'); - this.assertEquals(this.registries.dummyservice.fourth(), 'fourth/extra'); - }; - - this.testChecker = function() { - // Test with a checker function. - // We have a singleton, called s. - var s = {}; - var registrar = this.registries.schema.dummyservice; - // and a counter for the checker - var checker_counter = 0; - // Define three methods - registrar.getItemFactory('first').require({ - preferredSources: ['corelib', 'extralib'], - checker: function() {checker_counter++;}}); - // - // somewhere else, core provides the methods: - registrar.getItemFactory('first').provide({ - sourceName: 'corelib', - sourceVersion: '1.1', - getter: function() {return function() {return 'first/core';}}}); - // - // somewhere else, extras provides the methods: - registrar.getItemFactory('first').provide({ - sourceName: 'extralib', - sourceVersion: '12.4', - getter: function() {return function() {return 'first/extra';}}}); - // - // Now bind the items. - registrar.bindItems(s); - // call it - this.assertEquals(this.registries.dummyservice.first(), 'first/core'); - // Check that the checker has been called. - this.assertEquals(checker_counter, 1); - }; - - this.testReverseOrder = function() { - // Method creation also works in reverse order: - // a plugin first provides a method that another plugin later requires. - // We have a singleton, called s. - var s = {}; - var registrar = this.registries.schema.dummyservice; - // Provide the method first - registrar.getItemFactory('first').provide({ - sourceName: 'corelib', - sourceVersion: '1.1', - getter: function() {return function() {return 'first/core';}}}); - // Define the method later - registrar.getItemFactory('first').require({ - preferredSources: ['corelib', 'extralib']}); - // Now bind the items. - registrar.bindItems(s); - // We can call the methods on it, - this.assertEquals(this.registries.dummyservice.first(), 'first/core'); - }; - - this.testFinalizeTwice = function() { - // A registrar can only be bound once. - var s = {}; - var registrar = this.registries.schema.dummyservice; - // Provide the method first - registrar.getItemFactory('first').provide({ - sourceName: 'corelib', - sourceVersion: '1.1', - getter: function() {return function() {return 'first/core';}}}); - // Define the method later - registrar.getItemFactory('first').require({ - preferredSources: ['corelib', 'extralib']}); - // Now bind all items. - registrar.bindItems(s); - // Bind it again. - this.assertThrows(function() { - registrar.bindItems(s); - }, - Error); - }; - - this.testNotDefined = function() { - // A method is provided but not required. - var s = {}; - var registrar = this.registries.schema.dummyservice; - // Provide the method first - registrar.getItemFactory('first').provide({ - sourceName: 'corelib', - sourceVersion: '1.1', - getter: function() {return function() {return 'first/core';}}}); - // Now bind all items. - this.assertThrows(function() { - registrar.bindItems(s); - }, - Error) - }; - - this.testDoubleProvided = function() { - // A method cannot be provided twice by the same source. - // Let's initialize a dimmytest interface. - var registrar = this.registries.schema.dummyservice; - // Provide the method first - registrar.getItemFactory('first').provide({ - sourceName: 'corelib', - sourceVersion: '1.1', - getter: function() {return function() {return 'first/core';}}}); - // Now provide it for the second time. - this.assertThrows(function() { - registrar.getItemFactory('first').provide({ - sourceName: 'corelib', - sourceVersion: '1.1', - getter: function() {return function() {return 'first/core';}}}); - }, - Error); - }; - - this.testDoubleDefined = function() { - // A method can only be required once. - var registrar = this.registries.schema.dummyservice; - // Define the method first - registrar.getItemFactory('first').require({ - preferredSources: ['corelib', 'extralib']}); - // require it again. - this.assertThrows(function() { - registrar.getItemFactory('first').require({ - preferredSources: ['corelib', 'extralib']})}, - Error); - }; - - this.testNotProvided = function() { - // No preferred provider can be found for a method. - var s = {}; - var registrar = this.registries.schema.dummyservice; - // Define the method first - registrar.getItemFactory('first').require({ - preferredSources: ['corelib', 'extralib']}); - // Someone provides the method, but it's not good. - registrar.getItemFactory('first').provide({ - sourceName: 'craplib', - sourceVersion: '1.1', - getter: function() {return function() {return 'first/crap';}}}); - // Now bind all items. - this.assertThrows(function() { - registrar.bindItems(s); - }, - Error); - }; - - this.testWithLoader = function() { - // If no preferred providers are found, loaders will - // call up. - // Make a simple loader - var loader = new function() { - this.loaded = []; - this.add = function(src) { - this.loaded.push(src); - }; - this.empty = function(src) { - return ! this.loaded; - }; - this.getSources = function(src) { - return this.loaded; - }; - }(); - // Now, for the interface part - var s = {}; - var registrar = this.registries.schema.dummyservice; - // Define the method with loader and fallback script - registrar.getItemFactory('first').require({ - preferredSources: ['corelib', 'extralib'], - fallbackProvider: '++resource++one'}); - registrar.getItemFactory('second').require({ - preferredSources: ['corelib', 'extralib'], - fallbackProvider: '++resource++two'}); - registrar.getItemFactory('third').require({ - preferredSources: ['corelib', 'extralib'], - fallbackProvider: '++resource++three'}); - // Someone provides the method, but it's not good. - registrar.getItemFactory('first').provide({ - sourceName: 'craplib', - sourceVersion: '1.1', - getter: function() {return function() {return 'first/crap';}}}); - // Third will be satisfied. - registrar.getItemFactory('third').provide({ - sourceName: 'extralib', - sourceVersion: '12.4', - getter: function() {return function() {return 'third/extra';}}}); - // Now bind all items. It goes without error. - registrar.bindItems(s, loader); - // We see the contents of the loader. Third is not in there. - this.assertListEquals(loader.loaded, ['++resource++one', '++resource++two'], 'Loaded contents differs.'); - // Third is actually working. - this.assertEquals(this.registries.dummyservice.third(), 'third/extra'); - // First and second are undefined. - this.assertEquals(typeof(this.registries.dummyservice.first), 'undefined'); - this.assertEquals(typeof(this.registries.dummyservice.second), 'undefined'); - // Now the loader can go to load the needed files... - // then it is supposed to re-bind with and without a loader. Check if this is possible: - registrar.bindItems(s, loader); - // If we re-bound without a loader, and the sources are still not loaded, - // we get an error: - this.assertThrows(function() { - registrar.bindItems(s); - }, - Error); - }; - -}; /* end ServiceInterfacesTestCase */ -kukit.ServiceInterfacesTestCase.prototype = new kukit.InterfacesTestCaseBase(); - - -kukit.PluginInterfacesTestCase = function() { - this.name = 'kukit.PluginInterfacesTestCase'; - /* - * Plugin registries - */ - - this.setUp = function() { - // work with our own object, not interfering - // kukit.pluginregistry - this.registries = new kukit.ifa.NamedRegistries(); - // Let's initialize an events and binditeration registry. - this.registries.initializeRegistry('dummyevents', kukit.ifa.PluginFactory); - this.registries.initializeRegistry('dummybindsequences', kukit.ifa.BindSequenceFactory); - }; - - var M = function() { - this.bind = function(oper) {}; - }; - this.testPluginInterfaces = function() { - var events = this.registries.schema.dummyevents; - var bindsequences = this.registries.schema.dummybindsequences; - // somewhere else, core registers the items: - events.getItemFactory('click').register({ - name: 'click', - defaultActionMethodName: null, - parmtypes: [ - ['preventDefault', 'bool', true], - ['allowBubbling', 'bool', false]]}); - events.getItemFactory('keydown').register({ - name: 'keydown', - defaultActionMethodName: null, - parmtypes: [ - ['preventDefault', 'bool', true], - ['allowBubbling', 'bool', false]]}); - bindsequences.getItemFactory('').register({ - eventNames: ['click', 'keydown'], - iterName: 'Each', - binderClass: M, - bindMethodName: 'bind'}); - //*/ - // - // somewhere else, extras registers the items: - events.getItemFactory('timeout').register({ - name: 'timeout', - defaultActionMethodName: null, - parmtypes: [ - ['millis', 'int'], - ['renew', 'bool', false]]}); - // It needs a bind iterator even though it is a single - // sequence. - bindsequences.getItemFactory('').register({ - eventNames: ['timeout'], - iterName: 'Each', - binderClass: M, - bindMethodName: 'bind'}); - // - // Now bind all items. - events.bindItems({}); - bindsequences.bindItems({}); - // We can call the methods on it, - this.assertEquals(this.registries.dummyevents.click.defaultActionMethodName, null); - this.assertEquals(this.registries.dummyevents.keydown.defaultActionMethodName, null); - this.assertEquals(this.registries.dummyevents.timeout.defaultActionMethodName, null); - this.assertEquals(this.registries.dummybindsequences.timeout.iterName, 'Each'); - }; - - this.testPluginNoDoubleReg = function() { - // No double registration for test plugins. - var events = this.registries.schema.dummyevents; - var bindsequences = this.registries.schema.dummybindsequences; - // somewhere a plugin registers an item: - events.getItemFactory('click').register({ - name: 'click', - defaultActionMethodName: null, - parmtypes: [ - ['preventDefault', 'bool', true], - ['allowBubbling', 'bool', false]]}); - // But another registration attempt is harshly punished by an Error. - this.assertThrows(function() { - events.getItemFactory('click').register({ - name: 'click', - defaultActionMethodName: null, - parmtypes: [ - ['preventDefault', 'bool', true], - ['allowBubbling', 'bool', false]]}); - }, - Error); - }; - - this.testBindIterationNoDoubleReg = function() { - // No double registration for test plugins. - var events = this.registries.schema.dummyevents; - var bindsequences = this.registries.schema.dummybindsequences; - // somewhere else, core registers the items. - // XXX registry name '' is used to call interface level methods - bindsequences.getItemFactory('').register({ - eventNames: ['click', 'timeout'], - iterName: 'Each', - binderClass: M, - bindMethodName: 'bind'}); - // Suppose we have now a binder class that is a - // subclass of the previous one. In this case, - // it is essential to check that they got a different - // className. - var MSub = function() { - this.bind2 = function(oper) {}; - }; - MSub.prototype = new M(); - bindsequences.getItemFactory('').register({ - eventNames: ['keydown', 'keypress'], - iterName: 'Each', - binderClass: MSub, - bindMethodName: 'bind'}); - // bind - bindsequences.bindItems({}); - // Check that our classes are set as expected. - this.assertEquals(this.registries.dummybindsequences.click.binderClass, M); - this.assertEquals(this.registries.dummybindsequences.timeout.binderClass, M); - this.assertEquals(this.registries.dummybindsequences.keydown.binderClass, MSub); - this.assertEquals(this.registries.dummybindsequences.keypress.binderClass, MSub); - // Check that both classes have a class name. - this.assert(M.prototype.__className__); - this.assert(MSub.prototype.__className__); - // Check the two classes have distinct class names - this.assertNotEquals(M.prototype.__className__, MSub.prototype.__className__); - }; - - this.testOnlyRegisteredPluginsCanBeBound = function() { - // We assure that if an item is produced but it is not registered, - // it will not be bound on the configuration. - var events = this.registries.schema.dummyevents; - var bindsequences = this.registries.schema.dummybindsequences; - // Just call up the factoryr: this will create it with config=null. - events.getItemFactory('click'); - // bind - events.bindItems({}); - // 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.registries.dummyevents.click), 'undefined'); - }; - - this.testRegisterPlugins = function() { - // Test registerPlugins method. - // - kukit.ifa.registerPlugins( - [ - ['dummyevents', 'click', { - name: 'click', - defaultActionMethodName: null, - parmtypes: [ - ['preventDefault', 'bool', true], - ['allowBubbling', 'bool', false]]}], - - - ['dummyevents', 'keydown', { - name: 'keydown', - defaultActionMethodName: null, - parmtypes: [ - ['preventDefault', 'bool', true], - ['allowBubbling', 'bool', false]]}], - - ['dummybindsequences', '', { - eventNames: ['click', 'keydown'], - iterName: 'Each', - binderClass: M, - bindMethodName: 'bind'}], - // XXX putting a null in the end eliminates - // the problem of the closing comma - null] - - // XXX the registries is needed for the test, but not in normal usage - , this.registries - ); - }; - - this.testRegisterPluginsWrongNumberOfItems = function() { - // In registerPlugins, list items must have 3 members - // (interfaceName, attributeName, config) - // - this.assertThrows(function() { - kukit.ifa.registerPlugins( - [ - ['dummyevents', 'click', 'blah blah', { - name: 'click', - defaultActionMethodName: null, - parmtypes: [ - ['preventDefault', 'bool', true], - ['allowBubbling', 'bool', false]]}], - - // XXX putting a null in the end eliminates - // the problem of the closing comma - null] - - // XXX the registries is needed for the test, but not in normal usage - , this.registries - ); - }, Error); - }; - - this.testRegisterPluginsWrongInterface = function() { - // In registerPlugins, list items must have 3 members - // (interfaceName, attributeName, config) - // - this.assertThrows(function() { - kukit.ifa.registerPlugins( - [ - ['nosuchinterface', 'click', { - name: 'click', - defaultActionMethodName: null, - parmtypes: [ - ['preventDefault', 'bool', true], - ['allowBubbling', 'bool', false]]}], - - // XXX putting a null in the end eliminates - // the problem of the closing comma - null] - - // XXX the registries is needed for the test, but not in normal usage - , this.registries - ); - }, Error); - }; - - this.testRegisterPluginsServiceInterfaceProhibites = function() { - // The registerPlugins methods cannot be used to fill up - // registries that are initialized with a ServiceFactory. - // This means only factories that have 'register' - // method, can be used (PluginFactory, BindSequenceFactory). - // - // We register "dummyservice" so it does not fail because - // it's missing - kukit.pluginregistry.initializeRegistry('dummyservice', kukit.ifa.ServiceFactory); - // - this.assertThrows(function() { - kukit.ifa.registerPlugins( - [ - ['dummyservice', 'blah', {}], - - // XXX putting a null in the end eliminates - // the problem of the closing comma - null] - - // XXX the registries is needed for the test, but not in normal usage - , this.registries - ); - }, Error); - }; - - - - -}; /* end PluginInterfacesTestCase */ -kukit.PluginInterfacesTestCase.prototype = new kukit.InterfacesTestCaseBase(); - -if (typeof(testcase_registry) != 'undefined') { - testcase_registry.registerTestCase(kukit.InterfacesTestCase, 'kukit.InterfacesTestCase'); - testcase_registry.registerTestCase(kukit.ServiceInterfacesTestCase, 'kukit.ServiceInterfacesTestCase'); - testcase_registry.registerTestCase(kukit.PluginInterfacesTestCase, 'kukit.PluginInterfacesTestCase'); -} Copied: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_registries.js (from r59044, 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_registries.js Sun Oct 26 12:22:28 2008 @@ -24,7 +24,7 @@ kukit.InterfacesTestCaseBase = function() { this.setUp = function() { // work with our own object, not interfering - //interfaces.js + // with global object setup in registries.js this.registries = new kukit.ifa.NamedRegistries(); }; }; /* end InterfacesTestCase */ From gotcha at codespeak.net Sun Oct 26 12:22:40 2008 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 26 Oct 2008 12:22:40 +0100 (CET) Subject: [KSS-checkins] r59415 - kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core Message-ID: <20081026112240.888C5169ED8@codespeak.net> Author: gotcha Date: Sun Oct 26 12:22:40 2008 New Revision: 59415 Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/concatresource.zcml Log: rename files : from interfaces to registries Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/concatresource.zcml ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/concatresource.zcml (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/concatresource.zcml Sun Oct 26 12:22:40 2008 @@ -27,7 +27,7 @@ files=" kukit/kukit/kukit.js kukit/kukit/utils.js - kukit/kukit/interfaces.js + kukit/kukit/registries.js kukit/kukit/errors.js kukit/kukit/oper.js kukit/kukit/tokenizer.js @@ -57,7 +57,7 @@ files=" kukit/kukit/kukit.js kukit/kukit/utils.js - kukit/kukit/interfaces.js + kukit/kukit/registries.js kukit/kukit/errors.js kukit/kukit/oper.js kukit/kukit/tokenizer.js @@ -86,7 +86,7 @@ Author: gotcha Date: Sun Oct 26 12:31:45 2008 New Revision: 59417 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js Log: rename function Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js Sun Oct 26 12:31:45 2008 @@ -501,7 +501,7 @@ this.cleanRoomSetUp = function(suite) { this._saved_pluginregistry = kukit.pluginregistry; this._saved_service = kukit.service; - this.initializeGlobalRegistries(); + this.setupGlobalRegistries(); }; this.cleanRoomFinalize = function(suite) { @@ -525,7 +525,7 @@ */ // Initialize global registries -this.initializeGlobalRegistries = function() { +this.setupGlobalRegistries = function() { // instantiate registries kukit.pluginregistry = new this.NamedRegistries(); kukit.service = new this.NamedRegistries(); @@ -549,9 +549,11 @@ schema.core.bindItems({}); }; -// At this point we initialize the registries used by kukit, that means -// any code can use them from top level, without initialization. -this.initializeGlobalRegistries(); +// At this point we setup the registries used by kukit, +// that implies that any code can access them in the kukit namespace +// kukit.pluginregistry +// kukit.service +this.setupGlobalRegistries(); // The finalization of these registries is done from bootstrap. From gotcha at codespeak.net Sun Oct 26 12:58:55 2008 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 26 Oct 2008 12:58:55 +0100 (CET) Subject: [KSS-checkins] r59418 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: doc kukit tests Message-ID: <20081026115855.823B5169E03@codespeak.net> Author: gotcha Date: Sun Oct 26 12:58:53 2008 New Revision: 59418 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/doc/HISTORY.txt kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/actionreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/oper.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/plugin.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/resourcedata.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/runtests.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_registries.js Log: * rename kukit.pluginregistry to kukit.plugins * remove all mention of 'interface' Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/doc/HISTORY.txt ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/doc/HISTORY.txt (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/doc/HISTORY.txt Sun Oct 26 12:58:53 2008 @@ -6,14 +6,14 @@ - ... - - Add a general registry for interfaces. + - Add global registries. Add service layers. Refactor event binding and registries. Move event, action, command, selector, valueprovider - plugin registries into the interfaces registry, + plugin registries into the global registries, Refactor processBindingEvents to make it iterate on the binding sequence in a more efficient way. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/actionreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/actionreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/actionreg.js Sun Oct 26 12:58:53 2008 @@ -36,12 +36,12 @@ ;;; kukit.e += ' [ActionRegistry.register].'; ;;; throw new Error(kukit.E); ;;; } - var actions = kukit.pluginregistry.schema.actions; + var actions = kukit.plugins.schema.actions; actions.getItemFactory(name).register({actionFunc: func}); }; this.get = function(name) { - var reg = kukit.pluginregistry.actions[name]; + var reg = kukit.plugins.actions[name]; if (! reg || ! reg.actionFunc) { // not found ;;; kukit.E = 'Error : undefined client action [' + name + '].'; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js Sun Oct 26 12:58:53 2008 @@ -33,7 +33,7 @@ this.registerFromAction = function(srcname, factory, name) { - var actions = kukit.pluginregistry.schema.actions; + var actions = kukit.plugins.schema.actions; // // register a given action as a command, using the given vactor var action_factory = actions.getItemFactory(srcname); @@ -62,7 +62,7 @@ }; this.register = function(name, commandClass) { - var actions = kukit.pluginregistry.schema.actions; + var actions = kukit.plugins.schema.actions; var attrib = actions.getItemFactory(name); this._register(name, commandClass, attrib); }; @@ -81,7 +81,7 @@ }; this.get = function(name) { - var action = kukit.pluginregistry.actions[name]; + var action = kukit.plugins.actions[name]; var klass = action.commandClass; if (! klass) { ;;; kukit.E = 'undefined command [' + name + ']'; @@ -147,7 +147,7 @@ // we use the default type. var selectorType = this.selectorType || kukit.selectorTypesGlobalRegistry.defaultSelectorType; - var info = kukit.pluginregistry.valueproviders[selectorType]; + var info = kukit.plugins.valueproviders[selectorType]; // Check if the selector name really exists. if (! info || ! info.returnType == 'selection' || ! info.selectorFunc) { ;;; kukit.E = 'Undefined selector type [' + selectorType + '], '; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/eventreg.js Sun Oct 26 12:58:53 2008 @@ -43,7 +43,7 @@ */ var _EventRegistry = function () { // XXX There is no actual registry here any more, just - // emulating the old methods with the interfaces registry. + // emulating the old methods with the plugins registry. /* there are the actual registration methods, to be called from plugins */ @@ -78,7 +78,7 @@ } namespacedEventNames.push(eventName); // register the event informataion - var events = kukit.pluginregistry.schema.events; + var events = kukit.plugins.schema.events; events.getItemFactory(eventName).register({ defaultActionMethodName: defaultActionMethodName, parmTypes: null // missing from this api. @@ -87,7 +87,7 @@ // Register the bind iteration // This will specify the set of events that will be bound together, // with the specified iterator - var bindsequences = kukit.pluginregistry.schema.bindsequences; + var bindsequences = kukit.plugins.schema.bindsequences; bindsequences.getItemFactory('').register({ eventNames: namespacedEventNames, iterName: iterName, @@ -853,7 +853,7 @@ this.processBindingEvents = function (binder) { - var interfaces = kukit.pluginregistry; + var plugins = kukit.plugins; // Let's see all our events in a cycle. processed = {}; // We iterate through the event names in this binder instance only. @@ -869,9 +869,9 @@ } // One iteration consists of more events. Process all these. // (One of these is eventName itself, but we need not care.) - var iteration = interfaces.bindsequences[eventName]; + var iteration = plugins.bindsequences[eventName]; // Let's exit if this element does not exist - // (the interface registry finalizes invalid methods to undefined) + // (the plugin registry finalizes invalid methods to undefined) if (! iteration) { continue; } Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js Sun Oct 26 12:58:53 2008 @@ -249,7 +249,7 @@ ;;; allowedReturnTypes = {string: true}; ;;; kukit.E = 'event parameter [' + key + ']'; // global registry is used - var registry = kukit.pluginregistry; + var registry = kukit.plugins; var valuesByReturnType = kukit.va.createAndCheckRuleValues(values, allowedReturnTypes, registry, false, kukit.E, this); var value = valuesByReturnType.string; @@ -303,7 +303,7 @@ ;;; kukit.E = 'action definition [' + key + ']'; // check the rule values // global registry is used - var registry = kukit.pluginregistry; + var registry = kukit.plugins; var valuesByReturnType = kukit.va.createAndCheckRuleValues(values, allowedReturnTypes, registry, false, kukit.E, this); var value = valuesByReturnType.string; @@ -347,7 +347,7 @@ ;;; allowedReturnTypes = {string: true}; ;;; kukit.E = 'Wrong value in action error parameter [' + key + ']'; // global registry is used - var registry = kukit.pluginregistry; + var registry = kukit.plugins; var valuesByReturnType = kukit.va.createAndCheckRuleValues(values, allowedReturnTypes, registry, false, kukit.E, this); var value = valuesByReturnType.string; @@ -376,7 +376,7 @@ // (from check). // // global registry is used - var registry = kukit.pluginregistry; + var registry = kukit.plugins; var value; var allowedReturnTypes; var noStringRequired = false; @@ -1034,7 +1034,7 @@ css = singleword; } // global registry is used - var registry = kukit.pluginregistry; + var registry = kukit.plugins; // create the selector. var id = null; var ppid = null; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js Sun Oct 26 12:58:53 2008 @@ -237,8 +237,8 @@ ;;; // If we have firebug, log the registries to ;;; // be introspected from the console. ;;; if (kukit.hasFirebug) { -;;; kukit.logDebug('Next line shows kukit.pluginregistry:'); -;;; kukit.logDebug(kukit.pluginregistry); +;;; kukit.logDebug('Next line shows kukit.plugins:'); +;;; kukit.logDebug(kukit.plugins); ;;; kukit.logDebug('Next line shows kukit.service:'); ;;; kukit.logDebug(kukit.service); ;;; } Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/oper.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/oper.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/oper.js Sun Oct 26 12:58:53 2008 @@ -177,8 +177,8 @@ ;;; throw new Error(kukit.E); ;;; } // - var interface = kukit.pluginregistry; - var eventInfo = interface.events[name]; + var plugins = kukit.plugins; + var eventInfo = plugins.events[name]; var methodName = eventInfo && eventInfo.defaultActionMethodName; var success = false; @@ -261,8 +261,8 @@ // valid, even if it received no parms in the eventRule, // in which case it is not present as an action. // - var interface = kukit.pluginregistry; - var methodName = interface.events[this.getEventName()].defaultActionMethodName; + var plugins = kukit.plugins; + var methodName = plugins.events[this.getEventName()].defaultActionMethodName; return (typeof methodName != 'undefined'); } else return false; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/plugin.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/plugin.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/plugin.js Sun Oct 26 12:58:53 2008 @@ -289,7 +289,7 @@ }; -/* XXX Example for using the interfaces registry +/* XXX Example for using the plugins registry * * The markup selects the part that should be parsed by the server. * Some info, that contains class names, should be outside this. @@ -298,7 +298,7 @@ */ /* -kukit.interfaces.registerPlugins([ +kukit.plugins.registerPlugins([ // START KSS REGISTRY ['events', click, { defaultActionMethodName: null}], Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/providerreg.js Sun Oct 26 12:58:53 2008 @@ -42,8 +42,8 @@ // Default return type is string returnType = 'string'; } - // Always use the global interfaces to get the descriptor. - var registry = kukit.pluginregistry.schema[this.name]; + // Always use the global plugins to get the descriptor. + var registry = kukit.plugins.schema[this.name]; registry.getItemFactory(name).register({providerClass: func, returnType: returnType}); }; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js Sun Oct 26 12:58:53 2008 @@ -105,7 +105,7 @@ * binding of these registries is done by kukit at the beginning * of bootstrap. * - * Created on the global registries "kukit.pluginregistry": + * Created on the global registries "kukit.plugins": * * name purpose attribute class * ---- ------- --------------- @@ -499,7 +499,7 @@ */ this.cleanRoomSetUp = function(suite) { - this._saved_pluginregistry = kukit.pluginregistry; + this._saved_plugins = kukit.plugins; this._saved_service = kukit.service; this.setupGlobalRegistries(); }; @@ -511,7 +511,7 @@ this.cleanRoomTearDown = function(suite) { // Revert the saved state - kukit.pluginregistry = this._saved_pluginregistry; + kukit.plugins = this._saved_plugins; kukit.service = this._saved_service; }; @@ -519,7 +519,7 @@ * used by kukit itself. They are two of then, * stored globally: * - * kukit.pluginregistry Plugin registration + * kukit.plugins Plugin registration * kukit.service Service layer * */ @@ -527,9 +527,9 @@ // Initialize global registries this.setupGlobalRegistries = function() { // instantiate registries - kukit.pluginregistry = new this.NamedRegistries(); + kukit.plugins = new this.NamedRegistries(); kukit.service = new this.NamedRegistries(); - var r = kukit.pluginregistry; + var r = kukit.plugins; r.initializeRegistry('events', this.PluginFactory); r.initializeRegistry('bindsequences', this.BindSequenceFactory); r.initializeRegistry('actions', this.PluginFactory); @@ -540,7 +540,7 @@ // Finalize global registries this.finalizeGlobalRegistries = function() { - var schema = kukit.pluginregistry.schema; + var schema = kukit.plugins.schema; schema.events.bindItems({}); schema.bindsequences.bindItems({}); schema.actions.bindItems({}); @@ -551,7 +551,7 @@ // At this point we setup the registries used by kukit, // that implies that any code can access them in the kukit namespace -// kukit.pluginregistry +// kukit.plugins // kukit.service this.setupGlobalRegistries(); // The finalization of these registries is done from bootstrap. @@ -578,7 +578,7 @@ // registries is optional, and mainly used for tests if (typeof(registries) == 'undefined') { // use global registries - registries = kukit.pluginregistry; + registries = kukit.plugins; } // for (var i=0; i Author: gotcha Date: Sun Oct 26 12:59:50 2008 New Revision: 59419 Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/selenium_tests/0_ecmaunit_tests.html Log: remove all mentions of 'interface' Modified: kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/selenium_tests/0_ecmaunit_tests.html ============================================================================== --- kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/selenium_tests/0_ecmaunit_tests.html (original) +++ kukit/kss.core/branch/ree-service-layer-and-refactoring/kss/core/plugins/core/demo/selenium_tests/0_ecmaunit_tests.html Sun Oct 26 12:59:50 2008 @@ -65,17 +65,17 @@ assertText - //div[@id='kukit.InterfacesTestCase']/div + //div[@id='kukit.RegistriesTestCase']/div OK! assertText - //div[@id='kukit.ServiceInterfacesTestCase']/div + //div[@id='kukit.ServiceRegistryTestCase']/div OK! assertText - //div[@id='kukit.PluginInterfacesTestCase']/div + //div[@id='kukit.PluginRegistriesTestCase']/div OK! From gotcha at codespeak.net Sun Oct 26 13:05:11 2008 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 26 Oct 2008 13:05:11 +0100 (CET) Subject: [KSS-checkins] r59420 - kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit Message-ID: <20081026120511.4392C169F78@codespeak.net> Author: gotcha Date: Sun Oct 26 13:05:10 2008 New Revision: 59420 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/dom.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js Log: rename kukit.service to kukit.services Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/dom.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/dom.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/dom.js Sun Oct 26 13:05:10 2008 @@ -77,7 +77,7 @@ ;;; kukit.E = 'Selection error in kukit.dom.cssQuery'; throw new Error(kukit.E); } - return kukit.service.core.cssQuery(selector, inNodes); + return kukit.services.core.cssQuery(selector, inNodes); }; /* Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js Sun Oct 26 13:05:10 2008 @@ -239,8 +239,8 @@ ;;; if (kukit.hasFirebug) { ;;; kukit.logDebug('Next line shows kukit.plugins:'); ;;; kukit.logDebug(kukit.plugins); -;;; kukit.logDebug('Next line shows kukit.service:'); -;;; kukit.logDebug(kukit.service); +;;; kukit.logDebug('Next line shows kukit.services:'); +;;; kukit.logDebug(kukit.services); ;;; } // ;;; kukit.log('Initializing kinetic stylesheets.'); Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js Sun Oct 26 13:05:10 2008 @@ -500,7 +500,7 @@ this.cleanRoomSetUp = function(suite) { this._saved_plugins = kukit.plugins; - this._saved_service = kukit.service; + this._saved_services = kukit.services; this.setupGlobalRegistries(); }; @@ -512,7 +512,7 @@ this.cleanRoomTearDown = function(suite) { // Revert the saved state kukit.plugins = this._saved_plugins; - kukit.service = this._saved_service; + kukit.services = this._saved_services; }; /* These methods handle the specific registries @@ -520,7 +520,7 @@ * stored globally: * * kukit.plugins Plugin registration - * kukit.service Service layer + * kukit.services Service layer * */ @@ -528,13 +528,13 @@ this.setupGlobalRegistries = function() { // instantiate registries kukit.plugins = new this.NamedRegistries(); - kukit.service = new this.NamedRegistries(); + kukit.services = new this.NamedRegistries(); var r = kukit.plugins; r.initializeRegistry('events', this.PluginFactory); r.initializeRegistry('bindsequences', this.BindSequenceFactory); r.initializeRegistry('actions', this.PluginFactory); r.initializeRegistry('valueproviders', this.PluginFactory); - r = kukit.service; + r = kukit.services; r.initializeRegistry('core', this.ServiceFactory); }; @@ -545,14 +545,14 @@ schema.bindsequences.bindItems({}); schema.actions.bindItems({}); schema.valueproviders.bindItems({}); - schema = kukit.service.schema; + schema = kukit.services.schema; schema.core.bindItems({}); }; // At this point we setup the registries used by kukit, // that implies that any code can access them in the kukit namespace // kukit.plugins -// kukit.service +// kukit.services this.setupGlobalRegistries(); // The finalization of these registries is done from bootstrap. Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/service.js Sun Oct 26 13:05:10 2008 @@ -2,7 +2,7 @@ new function() { // BEGIN CLOSURE service -var core = kukit.service.schema.core; +var core = kukit.services.schema.core; // Requirements towards core services. It contains From gotcha at codespeak.net Sun Oct 26 13:41:13 2008 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 26 Oct 2008 13:41:13 +0100 (CET) Subject: [KSS-checkins] r59421 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: kukit tests Message-ID: <20081026124113.BE78D169F84@codespeak.net> Author: gotcha Date: Sun Oct 26 13:41:08 2008 New Revision: 59421 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_registries.js Log: remove too complex forEachFactory Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js Sun Oct 26 13:41:08 2008 @@ -148,21 +148,6 @@ return factory; }; - /* Iterate a function on each factory of this registrar */ - - this.forEachFactory = function(f, a1, a2, a3, a4, a5) { - // Apply f for each factory. - // f will receive attributeName, attribute, and the rest - // of the parameters passed to forEachFactory. - // methodName and MethodDescriptor will be passed to f as parameters. - // Extra arguments will be passed in addition. - for (var name in this.factories) { - var factory = this.factories[name]; - // Provide the necessary parameters and call f - f(name, factory, a1, a2, a3, a4, a5); - } - }; - this.bindItems = function(registry, loader) { // singleton: the singleton we want to finalize on. // loader (optional): use it for all operations @@ -177,18 +162,14 @@ } ;;; kukit.E = 'Binding registry [' + this.registryName + ']'; ;;; kukit.logDebug(kukit.E); - // Finalize all methods. - this.forEachFactory(function(name, factory) { - // finalize the attributes and store them on the registry - // - - // Get the finalized item from this factory + for (var name in this.factories) { + var factory = this.factories[name]; var item = factory.produceItem(loader); if (typeof(item) != 'undefined') { // Set the item on the registry registry[name] = item; }; - }); + }; // Store the registry itself on the registries // this means that it can be accessed as registries.registryname this.namedRegistries[this.registryName] = registry; @@ -207,6 +188,7 @@ }; /* end Registrar */ + this.NamedRegistries = function() { this.schema = {}; Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_registries.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_registries.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_registries.js Sun Oct 26 13:41:08 2008 @@ -75,15 +75,6 @@ registrar.getItemFactory('barItem').doThat() // Check this.assertListEquals(called, ['doThis', 'doThat']); - called = []; - // - // Now let's iterate on all factories: - registrar.forEachFactory(function(name, factory) { - factory.doThis(); - }); - // Check - this.assertListEquals(called, ['doThis', 'doThis']); - called = []; }; this.testReservedInterfaceNames = function() { From gotcha at codespeak.net Sun Oct 26 17:52:44 2008 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 26 Oct 2008 17:52:44 +0100 (CET) Subject: [KSS-checkins] r59424 - in kukit/kukit.js/branch/ree-service-layer-and-refactoring: kukit tests Message-ID: <20081026165244.BCF9416A0E2@codespeak.net> Author: gotcha Date: Sun Oct 26 17:52:44 2008 New Revision: 59424 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_registries.js Log: specify registry at bind time Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js Sun Oct 26 17:52:44 2008 @@ -127,8 +127,7 @@ var Registrar = function() { - this.initialize = function(namedRegistries, registryName, Factory) { - this.namedRegistries = namedRegistries; + this.initialize = function(registryName, Factory) { this.registryName = registryName; this.bound = false; this.factories = {}; @@ -148,7 +147,7 @@ return factory; }; - this.bindItems = function(registry, loader) { + this.bindItems = function(registries, registry, loader) { // singleton: the singleton we want to finalize on. // loader (optional): use it for all operations // (this means we never get errors but the loader @@ -172,7 +171,7 @@ }; // Store the registry itself on the registries // this means that it can be accessed as registries.registryname - this.namedRegistries[this.registryName] = registry; + registries[this.registryName] = registry; // Set bound state. // We are bound if the loader has no items to load. // If there is no loader, we are always bound at this point. @@ -218,7 +217,7 @@ // create the registrar on demand if (typeof(registrar) == 'undefined') { // create the registrar and store it on myself - this.schema[registryName] = new Registrar(this, registryName, Factory); + this.schema[registryName] = new Registrar(registryName, Factory); } else { // check that the same Factory was provided. If not, // it's a conflict. @@ -523,12 +522,12 @@ // Finalize global registries this.finalizeGlobalRegistries = function() { var schema = kukit.plugins.schema; - schema.events.bindItems({}); - schema.bindsequences.bindItems({}); - schema.actions.bindItems({}); - schema.valueproviders.bindItems({}); + schema.events.bindItems(kukit.plugins, {}); + schema.bindsequences.bindItems(kukit.plugins, {}); + schema.actions.bindItems(kukit.plugins, {}); + schema.valueproviders.bindItems(kukit.plugins, {}); schema = kukit.services.schema; - schema.core.bindItems({}); + schema.core.bindItems(kukit.services, {}); }; // At this point we setup the registries used by kukit, Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_registries.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_registries.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_registries.js Sun Oct 26 17:52:44 2008 @@ -108,7 +108,7 @@ called = []; // // At this point we are also ready to bind the items the registrar. - registrar.bindItems(s); + registrar.bindItems(this.registries, s); // This binds all the items. this.assertListEquals(called, ['FUNC fooItem', 'FUNC barItem']); called = []; @@ -202,7 +202,7 @@ getter: function() {return function() {return 'fourth/extra';}}}); // // Now bind the items. - registrar.bindItems(s); + registrar.bindItems(this.registries, s); // We can call the methods on it, this.assertEquals(this.registries.dummyservice.first(), 'first/core'); this.assertEquals(this.registries.dummyservice.second(), 'second/extra'); @@ -235,7 +235,7 @@ getter: function() {return function() {return 'first/extra';}}}); // // Now bind the items. - registrar.bindItems(s); + registrar.bindItems(this.registries, s); // call it this.assertEquals(this.registries.dummyservice.first(), 'first/core'); // Check that the checker has been called. @@ -257,7 +257,7 @@ registrar.getItemFactory('first').require({ preferredSources: ['corelib', 'extralib']}); // Now bind the items. - registrar.bindItems(s); + registrar.bindItems(this.registries, s); // We can call the methods on it, this.assertEquals(this.registries.dummyservice.first(), 'first/core'); }; @@ -275,10 +275,10 @@ registrar.getItemFactory('first').require({ preferredSources: ['corelib', 'extralib']}); // Now bind all items. - registrar.bindItems(s); + registrar.bindItems(this.registries, s); // Bind it again. this.assertThrows(function() { - registrar.bindItems(s); + registrar.bindItems(this.registries, s); }, Error); }; @@ -294,7 +294,7 @@ getter: function() {return function() {return 'first/core';}}}); // Now bind all items. this.assertThrows(function() { - registrar.bindItems(s); + registrar.bindItems(this.registries, s); }, Error) }; @@ -345,7 +345,7 @@ getter: function() {return function() {return 'first/crap';}}}); // Now bind all items. this.assertThrows(function() { - registrar.bindItems(s); + registrar.bindItems(this.registries, s); }, Error); }; @@ -390,7 +390,7 @@ sourceVersion: '12.4', getter: function() {return function() {return 'third/extra';}}}); // Now bind all items. It goes without error. - registrar.bindItems(s, loader); + registrar.bindItems(this.registries, s, loader); // We see the contents of the loader. Third is not in there. this.assertListEquals(loader.loaded, ['++resource++one', '++resource++two'], 'Loaded contents differs.'); // Third is actually working. @@ -400,11 +400,11 @@ this.assertEquals(typeof(this.registries.dummyservice.second), 'undefined'); // Now the loader can go to load the needed files... // then it is supposed to re-bind with and without a loader. Check if this is possible: - registrar.bindItems(s, loader); + registrar.bindItems(this.registries, s, loader); // If we re-bound without a loader, and the sources are still not loaded, // we get an error: this.assertThrows(function() { - registrar.bindItems(s); + registrar.bindItems(this.registries, s); }, Error); }; @@ -470,8 +470,8 @@ bindMethodName: 'bind'}); // // Now bind all items. - events.bindItems({}); - bindsequences.bindItems({}); + events.bindItems(this.registries, {}); + bindsequences.bindItems(this.registries, {}); // We can call the methods on it, this.assertEquals(this.registries.dummyevents.click.defaultActionMethodName, null); this.assertEquals(this.registries.dummyevents.keydown.defaultActionMethodName, null); @@ -527,7 +527,7 @@ binderClass: MSub, bindMethodName: 'bind'}); // bind - bindsequences.bindItems({}); + bindsequences.bindItems(this.registries, {}); // Check that our classes are set as expected. this.assertEquals(this.registries.dummybindsequences.click.binderClass, M); this.assertEquals(this.registries.dummybindsequences.timeout.binderClass, M); @@ -548,7 +548,7 @@ // Just call up the factoryr: this will create it with config=null. events.getItemFactory('click'); // bind - events.bindItems({}); + events.bindItems(this.registries, {}); // 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.registries.dummyevents.click), 'undefined'); From gotcha at codespeak.net Sun Oct 26 17:59:21 2008 From: gotcha at codespeak.net (gotcha at codespeak.net) Date: Sun, 26 Oct 2008 17:59:21 +0100 (CET) Subject: [KSS-checkins] r59426 - kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit Message-ID: <20081026165921.DA927169FC8@codespeak.net> Author: gotcha Date: Sun Oct 26 17:59:20 2008 New Revision: 59426 Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js Log: rename variable Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js ============================================================================== --- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js (original) +++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/registries.js Sun Oct 26 17:59:20 2008 @@ -18,7 +18,7 @@ * keyed by the action name. However in case of a service registry, * different components may provide the requested item, and the final * value of the method is decided at finalization and all this logic - * is handled by the Factory. In case of service + * is handled by the FactoryClass. In case of service * registries, this allows that "define service" and "provide service" * sections can be in different javascript files (plugins), and the * final outcome is independent of the order of their execution. @@ -51,7 +51,7 @@ * In the initialization the registry name and the item factory * need to be supplied as parameters. * - * registries.initializeRegistry('myregistry', MyFactory); + * registries.initializeRegistry('myregistry', MyFactoryClass); * * After this the registrar object can be looked up with: * @@ -127,11 +127,11 @@ var Registrar = function() { - this.initialize = function(registryName, Factory) { + this.initialize = function(registryName, FactoryClass) { this.registryName = registryName; this.bound = false; this.factories = {}; - this.Factory = Factory; + this.FactoryClass = FactoryClass; }; this.getItemFactory = function(name) { @@ -142,7 +142,7 @@ // for this method name // // instantiate the factory - factory = this.factories[name] = new this.Factory(this, name); + factory = this.factories[name] = new this.FactoryClass(this, name); } return factory; }; @@ -192,17 +192,17 @@ this.schema = {}; - this.initializeRegistry = function(registryName, Factory) { + this.initializeRegistry = function(registryName, FactoryClass) { // This sets up the registry given by name with the - // specified Factory class, or checks it. + // specified FactoryClass class, or checks it. // This method needs to be called preceding the calls // to getItemFactory on the given registrar. // It can be called more times for the same registry. // ;;; // Check for missing parameter; this will cause an error later anyway. -;;; if (! Factory) { +;;; if (! FactoryClass) { ;;; kukit.E = 'Registries.initializeRegistry() is called for registry ['; -;;; kukit.E += registryName + '] without a Factory parameter.'; +;;; kukit.E += registryName + '] without a FactoryClass parameter.'; ;;; throw new Error(kukit.E); ;;; } // Check prohibited names @@ -217,13 +217,13 @@ // create the registrar on demand if (typeof(registrar) == 'undefined') { // create the registrar and store it on myself - this.schema[registryName] = new Registrar(registryName, Factory); + this.schema[registryName] = new Registrar(registryName, FactoryClass); } else { - // check that the same Factory was provided. If not, + // check that the same FactoryClass was provided. If not, // it's a conflict. - if (registrar.Factory != Factory) { + if (registrar.FactoryClass != FactoryClass) { ;;; kukit.E = 'Registries.initializeRegistry() is called for registry ['; -;;; kukit.E += registryName + '] with a different Factory than earlier.'; +;;; kukit.E += registryName + '] with a different FactoryClass than earlier.'; throw new Error(kukit.E); } }