lib/openwfe/engine/engine.rb in openwferu-0.9.7 vs lib/openwfe/engine/engine.rb in openwferu-0.9.8

- old
+ new

@@ -43,10 +43,11 @@ require 'logger' require 'openwfe/workitem' require 'openwfe/rudefinitions' require 'openwfe/service' +require 'openwfe/util/irb' require 'openwfe/util/scheduler' require 'openwfe/util/schedulers' require 'openwfe/expool/wfidgen' require 'openwfe/expool/expressionpool' require 'openwfe/expool/expstorage' @@ -64,16 +65,17 @@ include OwfeServiceLocator # # Builds an OpenWFEru engine. # - def initialize () + # Accepts an optional initial application_context (containing + # initialization params for services for example). + # + def initialize (application_context={}) - super(S_ENGINE, {}) + super(S_ENGINE, application_context) - @application_context[@service_name] = self - $OWFE_LOG = Logger.new("engine.log") unless $OWFE_LOG # build order matters. # # especially for the expstorage which 'observes' the expression @@ -235,11 +237,11 @@ name = nil if listener.kind_of? Class - listener = init_service(nil, listener) + listener = init_service nil, listener name = listener.service_name else name = listener.name if listener.respond_to? :name @@ -284,10 +286,34 @@ get_scheduler.join end # + # Enabling the console means that hitting CTRL-C on the window / + # term / dos box / whatever does run the OpenWFEru engine will + # open an IRB interactive console for directly manipulating the + # engine instance. + # + # Hit CTRL-D to get out of the console. + # + def enable_irb_console + + OpenWFE::trap_int_irb(binding) + end + + # + # Makes sure that hitting CTRL-C will actually kill the engine VM and + # not open an IRB console. + # + #def disable_irb_console + # $openwfe_irb = nil + # trap 'INT' do + # exit 0 + # end + #end + + # # Stopping the engine will stop all the services in the # application context. # def stop @@ -305,10 +331,12 @@ "stop() stopped service '#{service.service_name}' "+ "(#{service.class})" end end end + + nil end # # METHODS FROM THE EXPRESSION POOL # @@ -375,11 +403,11 @@ # # the following methods may get overridden upon extension # see for example file_persisted_engine.rb # - def build_expression_map () + def build_expression_map @application_context[S_EXPRESSION_MAP] = ExpressionMap.new # # the expression map is not a Service anymore, # it's a simple instance (that will be reused in other @@ -389,32 +417,39 @@ # "build_expression_map() :\n" + # get_expression_map.to_s #end end - def build_wfid_generator () + def build_wfid_generator - #init_service(S_WFID_GENERATOR, DefaultWfidGenerator) - #init_service(S_WFID_GENERATOR, UuidWfidGenerator) - init_service(S_WFID_GENERATOR, KotobaWfidGenerator) + #init_service S_WFID_GENERATOR, DefaultWfidGenerator + #init_service S_WFID_GENERATOR, UuidWfidGenerator + init_service S_WFID_GENERATOR, KotobaWfidGenerator + + #g = FieldWfidGenerator.new( + # S_WFID_GENERATOR, @application_context, "wfid") + # + # showing how to initialize a FieldWfidGenerator that + # will take as workflow instance id the value found in + # the field "wfid" of the LaunchItem. end - def build_expression_pool () + def build_expression_pool init_service(S_EXPRESSION_POOL, ExpressionPool) end - def build_expression_storage () + def build_expression_storage init_service(S_EXPRESSION_STORAGE, InMemoryExpressionStorage) end - def build_participant_map () + def build_participant_map init_service(S_PARTICIPANT_MAP, ParticipantMap) end - def build_scheduler () + def build_scheduler init_service(S_SCHEDULER, SchedulerService) end end