Author: gotcha
Date: Sun Nov 16 13:38:37 2008
New Revision: 59946

Modified:
   kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/actionreg.js
   kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/commandreg.js
   kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/eventreg.js
   kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/providerreg.js
   kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js
   kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/selectorreg.js
   kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/service.js
   kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_registries.js
Log:
remove NamedRegistries first step

Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/actionreg.js
==============================================================================
--- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/actionreg.js      
(original)
+++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/actionreg.js      
Sun Nov 16 13:38:37 2008
@@ -36,7 +36,7 @@
 ;;;     kukit.e += ' [ActionRegistry.register].';
 ;;;     throw new Error(kukit.E);
 ;;; }
-    var actions = kukit.plugins.schema.actions;
+    var actions = kukit.registrars.actions;
     actions.getItemFactory(name).register({actionFunc: func});
 };
 

Modified: 
kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/commandreg.js
==============================================================================
--- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/commandreg.js     
(original)
+++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/commandreg.js     
Sun Nov 16 13:38:37 2008
@@ -33,7 +33,7 @@
 
 this.registerFromAction =
     function(srcname, factory, name) {
-    var actions = kukit.plugins.schema.actions;
+    var actions = kukit.registrars.actions;
     //
     // register a given action as a command, using the given vactor
     var action_factory = actions.getItemFactory(srcname);

Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/eventreg.js
==============================================================================
--- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/eventreg.js       
(original)
+++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/eventreg.js       
Sun Nov 16 13:38:37 2008
@@ -78,7 +78,7 @@
         }
         namespacedEventNames.push(eventName);
         // register the event informataion
-        var events = kukit.plugins.schema.events;
+        var events = kukit.registrars.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.plugins.schema.bindsequences;
+    var bindsequences = kukit.registrars.bindsequences;
     bindsequences.getItemFactory('').register({
             eventNames: namespacedEventNames,
             iterName: iterName,

Modified: 
kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/providerreg.js
==============================================================================
--- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/providerreg.js    
(original)
+++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/providerreg.js    
Sun Nov 16 13:38:37 2008
@@ -43,7 +43,7 @@
         returnType = 'string';
     }
     // Always use the global plugins to get the descriptor.
-    var registry = kukit.plugins.schema[this.name]; 
+    var registry = kukit.registrars[this.name]; 
     registry.getItemFactory(name).register({providerClass: func,
                                        returnType: returnType});
 };

Modified: 
kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js
==============================================================================
--- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js     
(original)
+++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js     
Sun Nov 16 13:38:37 2008
@@ -177,9 +177,11 @@
 
 
 this.NamedRegistries = function() {
-
-    this.schema = {};
     
+    this.initialize = function(registrars) {
+        this.registrars = registrars;
+    };
+
     this.initializeRegistry = function(registryName, FactoryClass) {
         // This sets up the registry given by name with the
         // specified FactoryClass class, or checks it.
@@ -193,19 +195,12 @@
 ;;;             kukit.E += registryName + '] without a FactoryClass 
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];
+        var registrar = this.registrars[registryName];
         // create the registrar on demand
         if (typeof(registrar) == 'undefined') {
             // create the registrar and store it on myself
-            this.schema[registryName] = new Registrar(registryName, 
FactoryClass);
+            this.registrars[registryName] = new Registrar(registryName, 
FactoryClass);
         } else {
             // check that the same FactoryClass was provided. If not,
             // it's a conflict.
@@ -218,7 +213,7 @@
     };
 
     this.getRegistryByType = function(type) {
-        var registry = this.schema[type];
+        var registry = this.registrars[type];
         if (typeof(registrar) == 'undefined') {
 ;;;         kukit.E = 'Registries.getRegistryByType() is called with 
unregistered type [';
 ;;;         kukit.E += type + '].';
@@ -227,6 +222,8 @@
         return registry;
     };
 
+    this.initialize.apply(this, arguments);
+
 }; /* end NamedRegistries */
 
 /*
@@ -239,7 +236,7 @@
         this.registrar = registrar;
         this.name = name;
         this.sources = {};
-        this.preferredSources = null;
+        this.preferredsources = null;
     };
 
 ;;; this._makeError = function(componentName, name) {
@@ -322,21 +319,21 @@
             // if not, we continue with the next best choice.
         }
         if (! func) {
-                // 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);
+            // 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 finalize now.
-;;;         kukit.E = 'Using method [';
-;;;         kukit.E += this.name + '] from source [';
-;;;         kukit.E += item.sourceName + '] version [';
-;;;         kukit.E += item.sourceVersion + '].';
-;;;         kukit.log(kukit.E);
+;;;         var msg = 'Using method [';
+;;;         msg += this.name + '] from source [';
+;;;         msg += item.sourceName + '] version [';
+;;;         msg += item.sourceVersion + '].';
+;;;         kukit.log(msg);
             // Return the func, optionally prefixed with a checker.
             if (this.checker) {
                 // if there is a checker, merge them together
@@ -499,8 +496,9 @@
 // Initialize global registries
 this.setupGlobalRegistries = function() {
     // instantiate registries
-    kukit.plugins = new this.NamedRegistries();
-    kukit.services = new this.NamedRegistries();
+    kukit.registrars = {}
+    kukit.plugins = new this.NamedRegistries(kukit.registrars);
+    kukit.services = new this.NamedRegistries(kukit.registrars);
     var r = kukit.plugins;
     r.initializeRegistry('events', this.PluginFactory);
     r.initializeRegistry('bindsequences', this.BindSequenceFactory);
@@ -512,13 +510,12 @@
 
 // Finalize global registries
 this.finalizeGlobalRegistries = function() {
-    var schema = kukit.plugins.schema;
-    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(kukit.services, {});
+    var registrars = kukit.registrars;
+    registrars.events.bindItems(kukit.plugins, {});
+    registrars.bindsequences.bindItems(kukit.plugins, {});
+    registrars.actions.bindItems(kukit.plugins, {});
+    registrars.valueproviders.bindItems(kukit.plugins, {});
+    registrars.core.bindItems(kukit.services, {});
 };
 
 // At this point we setup the registries used by kukit,

Modified: 
kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/selectorreg.js
==============================================================================
--- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/selectorreg.js    
(original)
+++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/selectorreg.js    
Sun Nov 16 13:38:37 2008
@@ -84,7 +84,7 @@
 
 };
 
-var registrar = kukit.plugins.schema.valueproviders;
+var registrar = kukit.registrars.valueproviders;
 registrar.getItemFactory('passnode').register({
         providerClass: sr.PassnodePP,
         returnType: 'selection'});
@@ -114,7 +114,7 @@
 ;;;     throw new Error(kukit.E);
 ;;; }
     // Also register the selector param provider
-    var registrar = kukit.plugins.schema.valueproviders;
+    var registrar = kukit.registrars.valueproviders;
     var providerClass = sr.makeAnySelectorProvider(selectorFunc);
     registrar.getItemFactory(name).register({
         providerClass: providerClass,

Modified: kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/service.js
==============================================================================
--- kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/service.js        
(original)
+++ kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/service.js        
Sun Nov 16 13:38:37 2008
@@ -2,7 +2,7 @@
 
 new function() {  // BEGIN CLOSURE service
 
-var core = kukit.services.schema.core;
+var core = kukit.registrars.core;
 
 
 // Requirements towards core services. It contains

Modified: 
kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_registries.js
==============================================================================
--- 
kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_registries.js    
    (original)
+++ 
kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_registries.js    
    Sun Nov 16 13:38:37 2008
@@ -25,7 +25,8 @@
     this.setUp = function() {
         // work with our own object, not interfering
         // with global object setup in registries.js
-        this.registries = new kukit.reg.NamedRegistries();
+        this.registrars = {}
+        this.registries = new kukit.reg.NamedRegistries(this.registrars);
     };
 }; /* end RegistriesTestCase */
 kukit.RegistriesTestCaseBase.prototype = new kukit.UtilsTestCaseBase();
@@ -62,7 +63,7 @@
         // We need to initialize it
         this.registries.initializeRegistry('dummytest', TestFactory);
         // Now we can access the schema.
-        var registrar = this.registries.schema.dummytest;
+        var registrar = this.registrars.dummytest;
         this.assert(typeof(registrar), 'object');
         // Let's get two items
         registrar.getItemFactory('fooItem').doThis()
@@ -77,20 +78,6 @@
         this.assertListEquals(called, ['doThis', 'doThat']);
     };
 
-    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.testFinalizeRegistries = function() {
         // We have a singleton, called s.
         var s = {};
@@ -99,7 +86,7 @@
         called = [];
         // Let's initialize a dummytest registry.
         this.registries.initializeRegistry('dummytest', TestFactory);
-        var registrar = this.registries.schema.dummytest;
+        var registrar = this.registrars.dummytest;
         // Let's get two factories
         registrar.getItemFactory('fooItem').doThis()
         registrar.getItemFactory('barItem').doThat()
@@ -154,7 +141,8 @@
     this.setUp = function() {
         // work with our own registries, not interfering
         // kukit.service or kukit.plugins.
-        this.registries = new kukit.reg.NamedRegistries();
+        this.registrars = {}
+        this.registries = new kukit.reg.NamedRegistries(this.registrars);
         // Let's initialize a dummyservice registry.
         this.registries.initializeRegistry('dummyservice', 
kukit.reg.ServiceFactory);
     };
@@ -162,7 +150,7 @@
     this.testServiceRegistry = function() {
         // We have a singleton, called s.
         var s = {};
-        var registrar = this.registries.schema.dummyservice;
+        var registrar = this.registrars.dummyservice;
         // Requires four methods, thie defines their necessity and preferred 
providers
         registrar.getItemFactory('first').require({
             preferredSources: ['corelib', 'extralib']});
@@ -214,7 +202,7 @@
         // Test with a checker function.
         // We have a singleton, called s.
         var s = {};
-        var registrar = this.registries.schema.dummyservice;
+        var registrar = this.registrars.dummyservice;
         // and a counter for the checker
         var checker_counter = 0;
         // Define three methods
@@ -247,7 +235,7 @@
         // 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;
+        var registrar = this.registrars.dummyservice;
         // Provide the method first
         registrar.getItemFactory('first').provide({
             sourceName: 'corelib',
@@ -265,7 +253,7 @@
     this.testFinalizeTwice = function() {
         // A registrar can only be bound once.
         var s = {};
-        var registrar = this.registries.schema.dummyservice;
+        var registrar = this.registrars.dummyservice;
         // Provide the method first
         registrar.getItemFactory('first').provide({
             sourceName: 'corelib',
@@ -286,7 +274,7 @@
     this.testNotDefined = function() {
         // A method is provided but not required.
         var s = {};
-        var registrar = this.registries.schema.dummyservice;
+        var registrar = this.registrars.dummyservice;
         // Provide the method first
         registrar.getItemFactory('first').provide({
             sourceName: 'corelib',
@@ -302,7 +290,7 @@
     this.testDoubleProvided = function() {
         // A method cannot be provided twice by the same source.
         // Let's initialize a dimmytest registry.
-        var registrar = this.registries.schema.dummyservice;
+        var registrar = this.registrars.dummyservice;
         // Provide the method first
         registrar.getItemFactory('first').provide({
             sourceName: 'corelib',
@@ -320,7 +308,7 @@
 
     this.testDoubleDefined = function() {
         // A method can only be required once.
-        var registrar = this.registries.schema.dummyservice;
+        var registrar = this.registrars.dummyservice;
         // Define the method first
         registrar.getItemFactory('first').require({
             preferredSources: ['corelib', 'extralib']});
@@ -334,7 +322,7 @@
     this.testNotProvided = function() {
         // No preferred provider can be found for a method.
         var s = {};
-        var registrar = this.registries.schema.dummyservice;
+        var registrar = this.registrars.dummyservice;
         // Define the method first
         registrar.getItemFactory('first').require({
             preferredSources: ['corelib', 'extralib']});
@@ -363,7 +351,8 @@
     this.setUp = function() {
         // work with our own object, not interfering
         // kukit.plugins
-        this.registries = new kukit.reg.NamedRegistries();
+        this.registrars = {}
+        this.registries = new kukit.reg.NamedRegistries(this.registrars);
         // Let's initialize an events and binditeration registry.
         this.registries.initializeRegistry('dummyevents', 
kukit.reg.PluginFactory);
         this.registries.initializeRegistry('dummybindsequences', 
kukit.reg.BindSequenceFactory);
@@ -373,8 +362,8 @@
         this.bind = function(oper) {};
     };
     this.testPluginRegistries = function() {
-        var events = this.registries.schema.dummyevents;
-        var bindsequences = this.registries.schema.dummybindsequences;
+        var events = this.registrars.dummyevents;
+        var bindsequences = this.registrars.dummybindsequences;
         // somewhere else, core registers the items:
         events.getItemFactory('click').register({
             name: 'click',
@@ -422,8 +411,8 @@
 
     this.testPluginNoDoubleReg = function() {
         // No double registration for test plugins.
-        var events = this.registries.schema.dummyevents;
-        var bindsequences = this.registries.schema.dummybindsequences;
+        var events = this.registrars.dummyevents;
+        var bindsequences = this.registrars.dummybindsequences;
         // somewhere a plugin registers an item:
         events.getItemFactory('click').register({
             name: 'click',
@@ -445,8 +434,8 @@
 
     this.testBindIterationNoDoubleReg = function() {
         // No double registration for test plugins.
-        var events = this.registries.schema.dummyevents;
-        var bindsequences = this.registries.schema.dummybindsequences;
+        var events = this.registrars.dummyevents;
+        var bindsequences = this.registrars.dummybindsequences;
         // somewhere else, core registers the items.
         // XXX registry name '' is used to call registry level methods
         bindsequences.getItemFactory('').register({
@@ -484,8 +473,8 @@
     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;
+        var events = this.registrars.dummyevents;
+        var bindsequences = this.registrars.dummybindsequences;
         // Just call up the factoryr: this will create it with config=null.
         events.getItemFactory('click');
         // bind
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins

Reply via email to