lib/openwfe/engine/engine.rb in openwferu-0.9.4 vs lib/openwfe/engine/engine.rb in openwferu-0.9.5
- old
+ new
@@ -65,28 +65,50 @@
super(S_ENGINE, {})
@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
+ # pool and thus needs to be instantiated after it.
+
build_scheduler()
build_expression_map()
- build_expression_storage()
+
build_expression_pool()
+ build_expression_storage()
build_participant_map()
- $OWFE_LOG = Logger.new("engine.log") unless $LOG
+ #
+ # engine components are ready for operation, it's time to
+ # check persisted expressions (if any) to see if something
+ # has to be rescheduled (like a long time sleep expression or
+ # a cron)
+
+ get_expression_pool.reschedule()
+
+ linfo { "new() --- engine started --- #{self.object_id}" }
end
#
# Launches a [business] process.
# The 'launch_object' param may contain either a LaunchItem instance,
# either a String containing the URL of the process definition
# to launch (with an empty LaunchItem created on the fly).
#
- def launch (launch_object)
+ # If async is set to true, the process will be launched asynchronously
+ # (in his own thread).
+ #
+ # Returns a FlowExpressionId instance or a tuple FlowExpressionId /
+ # Thread object if async is set to true.
+ #
+ def launch (launch_object, async=false)
launchitem = nil
if launch_object.kind_of? OpenWFE::LaunchItem
launchitem = launch_object
@@ -100,11 +122,11 @@
else
launchitem.workflowDefinitionUrl = launch_object
end
end
- get_expression_pool.launch(launchitem)
+ get_expression_pool.launch(launchitem, async)
end
#
# This method is used to feed a workitem back to the engine (after
# it got sent to a worklist or wherever by a participant).
@@ -118,10 +140,14 @@
#
# Registers a participant in this [embedded] engine.
# This method is a shortcut to the ParticipantMap method
# with the same name.
#
+ # Returns the participant instance.
+ #
+ # see ParticipantMap#register_participant
+ #
def register_participant (regex, participant=nil, &block)
get_participant_map.register_participant(regex, participant, &block)
end
@@ -178,9 +204,10 @@
def build_participant_map ()
init_service(S_PARTICIPANT_MAP, ParticipantMap)
end
def build_scheduler ()
+ #ldebug { "build_scheduler()" }
init_service(S_SCHEDULER, SchedulerService)
end
end