/[freeride]/freeride/freebase/core.rb
ViewVC logotype

Diff of /freeride/freebase/core.rb

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by richkilmer, Sat Nov 2 06:26:11 2002 UTC revision 1.12 by richkilmer, Sun Nov 10 07:54:24 2002 UTC
# Line 54  module FreeBASE Line 54  module FreeBASE
54        load_setup        load_setup
55        @bus["/log/info"] << "--- #{@properties['config/product_name']} Started on #{Time.now.to_s}"        @bus["/log/info"] << "--- #{@properties['config/product_name']} Started on #{Time.now.to_s}"
56        @bus["/system/state/all_plugins_loaded"].data = false;        @bus["/system/state/all_plugins_loaded"].data = false;
57        load_plugins        @plugin_config = Configuration.new(self, @properties["config/plugin_path"])
58          @plugin_config.load_plugins
59          @plugin_config.start_plugins
60        @bus["/system/state/all_plugins_loaded"].data = true;        @bus["/system/state/all_plugins_loaded"].data = true;
61          @core_thread = Thread.current
62        tui = Thread.new {        tui = Thread.new {
63          @bus["/system/ui/messagepump"].call()          @bus["/system/ui/messagepump"].call()
64        }        }
# Line 68  module FreeBASE Line 71  module FreeBASE
71      # Shutdown stops if requested by a plugin to abort.      # Shutdown stops if requested by a plugin to abort.
72      #      #
73      def shutdown      def shutdown
74        SHUTDOWN_STATES.each {|state| @bus["/plugins"].data = state}        @plugin_config.stop_plugins
75          @plugin_config.unload_plugins
76          @bus["/system/state/all_plugins_loaded"].data = false;
77        @bus["/log/info"] << "--- Shutting down #{@properties['config/product_name']} on #{Time.now.to_s}"        @bus["/log/info"] << "--- Shutting down #{@properties['config/product_name']} on #{Time.now.to_s}"
78        exit        @core_thread.wakeup if @core_thread.stop?
79      end      end
80            
81      private      private
# Line 97  module FreeBASE Line 102  module FreeBASE
102        @bus["log"].subscribe do |event, slot|        @bus["log"].subscribe do |event, slot|
103          if event == :notify_queue_join and slot.name != "log"          if event == :notify_queue_join and slot.name != "log"
104            @bus["log"].call(slot.name, slot.queue.leave) if @bus["log"].is_proc_slot?            @bus["log"].call(slot.name, slot.queue.leave) if @bus["log"].is_proc_slot?
105            slot.queue.leave if slot.queue.count > 20            slot.queue.leave if slot.queue.count > 500
106          end          end
107        end        end
108      end      end
# Line 135  module FreeBASE Line 140  module FreeBASE
140                                       @propertiesFile)                                       @propertiesFile)
141        end        end
142      end      end
       
     ##  
     # Opens the supplied file and parse <plugin> elements  
     # yielding each to the supplied block.  
     #  
     # filespec:: [String] The file name to parse  
     # &block:: [String] The block to be yielded the REXML element  
     #  
     def each_plugin_element(filespec, &block)  
       file = File.new(filespec)  
       xml = REXML::Document.new file  
       file.close  
       plugin_element = xml.root  
       if plugin_element.name=="plugin"  
         yield plugin_element  
         return  
       else  
         yield plugin_element if plugin_element.attributes["name"] #register subsystem plugin  
         plugin_element.each_element("plugin") {|element| yield element}  
       end  
     end  
       
     ##  
     # Iterates over the directory(s) defined in the properties["/config/plugin_path"]  
     # looking for subdirectories. When found, the plugin.xml file is read and the  
     # identified file is "required" and the identified module has startup(bus,localbus)  
     # called upon it.  
     #  
     def load_plugins  
       plugin_element = nil  
       @properties["config/plugin_path"].split(";").each do |path|  
         Dir.foreach(path) do |file|  
           if file!=".." and file!="." and File.stat("#{path}/#{file}").directory?  
             filespec = "#{path}/#{file}/plugin.xml"  
             next unless File.exist?(filespec)  
             each_plugin_element(filespec) do |plugin_element|  
               FreeBASE::Plugin.new(self, filespec, plugin_element)  
             end  
           elsif file[-4..-1]==".xml" and !File.stat("#{path}/#{file}").directory?  
             filespec = "#{path}/#{file}"  
             each_plugin_element(filespec) do |plugin_element|  
               FreeBASE::Plugin.new(self, filespec, plugin_element)  
             end  
           end  
         end  
       end  
       STARTUP_STATES.each {|state| @bus["/plugins"].data = state}  
     end  
143    end    end
144        
145  end  end

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26