Author: gotcha
Date: Sun Dec 28 14:03:45 2008
New Revision: 60714

Modified:
   kukit/kukit.js/branch/gotcha-simplify-service-layer/kukit/registries.js
   kukit/kukit.js/branch/gotcha-simplify-service-layer/tests/test_registries.js
Log:
build instead of bind

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 Dec 28 14:03:45 2008
@@ -47,60 +47,18 @@
  * case of the plugins), then the order of these javascripts is
  * arbitrary for registries to work.
  *
- * This concludes everything we can do, before binding the registry.
- * Binding freezes the factorization of items in the registrar and
- * allows its direct use.  For the binding, a
- * singleton registry object has to be provided. The items are 
- * bound on this registry.
+ * This concludes everything we can do, before building the registry.
  *
+ *    plugins.events.click           - is an event's registry
+ *    plugins.actions.setAttr        - is an action's registry
  *
- * 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
- *
- * 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.plugins":
- *
- * name            purpose                  attribute class
- * ----            -------                  ---------------
- * events          kss event name registry  kukit.reg.PluginFactory
- * bindsequences   kss event binding reg.   kukit.reg.BindSequenceFactory
- * actions         kss action registry      kukit.reg.PluginFactory
- * valueproviders  value provider registry  kukit.reg.PluginFactory
- *
- * Created on the global registries "kukit.service":
- *
- * name            purpose                  attribute class
- * ----            -------                  ---------------
- * services        services                 kukit.reg.ServiceFactory
- *
- *
- *  For more information, see ../tests/test_registries.js .
- * 
  */
 
 reg.Registrar = function() {
 
     this.initialize = function(registryName, FactoryClass) {
         this.registryName = registryName;
-        this.bound = false;
+        this.built = false;
         this.factories = {};
         this.FactoryClass = FactoryClass;
     };
@@ -118,14 +76,13 @@
         return factory;
     };
 
-    this.bindItems = function() {
-        // Check if we are finalized.        
-        if (this.bound) {
-;;;         kukit.E = 'Attempt to bind already bound registry [';
-;;;         kukit.E += this.registryName + ']';
+    this.buildRegistry = function() {
+        if (this.built) {
+;;;         kukit.E = 'Registry [';
+;;;         kukit.E += this.registryName + '] already built !';
             throw new Error(kukit.E);
         }
-;;;     kukit.E = 'Binding registry [' + this.registryName + ']';
+;;;     kukit.E = 'Building registry [' + this.registryName + ']';
 ;;;     kukit.logDebug(kukit.E);
         var registry = {};
         for (var name in this.factories) {
@@ -136,8 +93,7 @@
                 registry[name] = item;
             };
         };
-        // Set bound state.
-        this.bound = true;
+        this.built = true;
         return registry;
     };
     
@@ -195,7 +151,7 @@
 ;;;     if (! config.sourceVersion) {
 ;;;         throw this._makeError(componentName, 'config.sourceVersion');
 ;;;     }
-        if (this.registrar.bound) {
+        if (this.registrar.built) {
 ;;;         kukit.E = 'Attempt to provide implementation to method [';
 ;;;         kukit.E += this.methodName + '] on already finalized registry [';
 ;;;         kukit.E += this.registrar.registryName + ']';
@@ -283,9 +239,6 @@
     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;
     };
 
@@ -299,11 +252,6 @@
     };
 
     this.create = function() {
-        // 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;
     };
 
@@ -394,7 +342,7 @@
 };
 
 reg.cleanRoomFinalize = function(suite) {
-    // Need to finalize (bind) these registries
+    // Need to build these registries
     this.finalizeGlobalRegistries();
 };
 
@@ -428,11 +376,11 @@
 reg.finalizeGlobalRegistries = function() {
     var registrars = kukit.registrars;
     kukit.plugins = {};
-    kukit.plugins.events = registrars.events.bindItems();
-    kukit.plugins.bindsequences = registrars.bindsequences.bindItems();
-    kukit.plugins.actions = registrars.actions.bindItems();
-    kukit.plugins.valueproviders = registrars.valueproviders.bindItems();
-    kukit.services = registrars.services.bindItems();
+    kukit.plugins.events = registrars.events.buildRegistry();
+    kukit.plugins.bindsequences = registrars.bindsequences.buildRegistry();
+    kukit.plugins.actions = registrars.actions.buildRegistry();
+    kukit.plugins.valueproviders = registrars.valueproviders.buildRegistry();
+    kukit.services = registrars.services.buildRegistry();
 };
 
 // At this point we setup the registries used by kukit,

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 Dec 28 14:03:45 2008
@@ -81,10 +81,7 @@
         // Check
         this.assertListEquals(called, ['doThis', 'doThat']);
         called = [];
-        //
-        // At this point we are also ready to bind the items the registrar.
-        this.dummytest = registrar.bindItems();
-        // This binds all the items.
+        this.dummytest = registrar.buildRegistry();
         this.assertListEquals(called, ['FUNC fooItem', 'FUNC barItem']);
         called = [];
         // At the same time it also set up these on the class prototype.
@@ -148,9 +145,7 @@
             sourceName: 'extralib', 
             sourceVersion: '12.4', 
             getter: function() {return function() {return 'fourth/extra';}}});
-        //
-        // Now bind the items.
-        this.dummyservice = registrar.bindItems();
+        this.dummyservice = registrar.buildRegistry();
         // We can call the methods on it,
         this.assertEquals(this.dummyservice.first(), 'first/core');
         this.assertEquals(this.dummyservice.second(), 'second/extra');
@@ -181,9 +176,7 @@
             sourceName: 'extralib', 
             sourceVersion: '12.4', 
             getter: function() {return function() {return 'first/extra';}}});
-        //
-        // Now bind the items.
-        this.dummyservice = registrar.bindItems();
+        this.dummyservice = registrar.buildRegistry();
         // call it
         this.assertEquals(this.dummyservice.first(), 'first/core');
         // Check that the checker has been called.
@@ -204,14 +197,13 @@
         // Define the method later
         registrar.getItemFactory('first').require({
             preferredSources: ['corelib', 'extralib']});
-        // Now bind the items.
-        this.dummyservice = registrar.bindItems();
+        this.dummyservice = registrar.buildRegistry();
         // We can call the methods on it,
         this.assertEquals(this.dummyservice.first(), 'first/core');
     };
 
     this.testFinalizeTwice = function() {
-        // A registrar can only be bound once.
+        // A registrar can only be built once.
         var s = {};
         var registrar = this.registrars.dummyservice;
         // Provide the method first
@@ -222,11 +214,9 @@
         // Define the method later
         registrar.getItemFactory('first').require({
             preferredSources: ['corelib', 'extralib']});
-        // Now  bind all items.
-        registrar.bindItems();
-        // Bind it again.
+        registrar.buildRegistry();
         this.assertThrows(function() {
-            registrar.bindItems();
+            registrar.buildRegistry();
             },
             Error);
     };
@@ -240,9 +230,8 @@
             sourceName: 'corelib',
             sourceVersion: '1.1',
             getter: function() {return function() {return 'first/core';}}});
-        // Now bind all items.
         this.assertThrows(function() {
-            registrar.bindItems();
+            registrar.buildRegistry();
             },
             Error)
     };
@@ -290,9 +279,8 @@
             sourceName: 'craplib',
             sourceVersion: '1.1',
             getter: function() {return function() {return 'first/crap';}}});
-        // Now bind all items.
         this.assertThrows(function() {
-            registrar.bindItems();
+            registrar.buildRegistry();
             },
             Error);
     };
@@ -353,10 +341,8 @@
             iterName: 'Each',
             binderClass: M,
             bindMethodName: 'bind'});
-        //
-        // Now bind all items.
-        this.dummyevents = events.bindItems();
-        this.dummybindsequences = bindsequences.bindItems();
+        this.dummyevents = events.buildRegistry();
+        this.dummybindsequences = bindsequences.buildRegistry();
         // We can call the methods on it,
         this.assertEquals(this.dummyevents.click.defaultActionMethodName, 
null);
         this.assertEquals(this.dummyevents.keydown.defaultActionMethodName, 
null);
@@ -411,8 +397,7 @@
             iterName: 'Each',
             binderClass: MSub,
             bindMethodName: 'bind'});
-        // bind
-        this.dummybindsequences = bindsequences.bindItems();
+        this.dummybindsequences = bindsequences.buildRegistry();
         // Check that our classes are set as expected.
         this.assertEquals(this.dummybindsequences.click.binderClass, M);
         this.assertEquals(this.dummybindsequences.timeout.binderClass, M);
@@ -425,15 +410,14 @@
         this.assertNotEquals(M.prototype.__className__, 
MSub.prototype.__className__);
     };
 
-    this.testOnlyRegisteredPluginsCanBeBound = function() {
+    this.testOnlyRegisteredPluginsCanBeBuilt = function() {
         // We assure that if an item is produced but it is not registered,
-        // it will not be bound on the configuration.
+        // it will not be built on the configuration.
         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
-        this.dummyevents = events.bindItems();
+        this.dummyevents = events.buildRegistry();
         // 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.dummyevents.click), 'undefined');
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins

Reply via email to