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');
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins

Reply via email to