Subversion Repositories HomeAutomation

Rev

Rev 977 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1.  
  2. function ServiceManager() {}
  3.  
  4. ServiceManager.Services = new Array();
  5.  
  6. ServiceManager.getService = function(type, name, id)
  7. {
  8.     var fullId = name + id;
  9.  
  10.     if (!ServiceManager.Services[fullId])
  11.     {
  12.         if (eval("typeof " + name + " != 'function'"))///FIXME: eval = evil!
  13.         {
  14.             if (!loadScript(type + "/" + name + ".js"))
  15.             {
  16.                 log("Could not load " + name + ".js\n");
  17.                 return null;
  18.             }
  19.             else
  20.             {
  21.                 log("Successfully loaded " + name + ".js\n");
  22.             }
  23.         }
  24.        
  25.         ServiceManager.Services[fullId] = eval("(new " + name + "('" + name + "', " + id + "))");///FIXME: Can we do this without eval??
  26.     }
  27.    
  28.     return ServiceManager.Services[fullId];
  29. }
  30.  
  31. ServiceManager.startService = function(type, name, id, args)
  32. {
  33.     var service = ServiceManager.getService(type, name, id);
  34.     if (service != null)
  35.     {
  36.         service.initialize(args);
  37.     }
  38. }
  39.