lib/openwfe/participants/participantmap.rb in openwferu-0.9.9 vs lib/openwfe/participants/participantmap.rb in openwferu-0.9.10

- old
+ new

@@ -39,10 +39,11 @@ # John Mettraux at openwfe.org # require 'openwfe/workitem' require 'openwfe/service' +require 'openwfe/util/observable' require 'openwfe/participants/participants' include OpenWFE @@ -50,18 +51,21 @@ # # A very simple directory of participants # class ParticipantMap < Service + include Observable attr_accessor \ :participants def initialize (service_name, application_context) super(service_name, application_context) @participants = [] + + @observers = {} end # # Adds a participant to this map. # This method is called by the engine's own register_participant() @@ -165,15 +169,24 @@ raise "Didn't find participant named '#{participant_name}'" \ if not participant workitem.participant_name = participant_name - if workitem.kind_of? CancelItem and participant.respond_to? :cancel + if (workitem.kind_of?(CancelItem) and + participant.respond_to?(:cancel)) + participant.cancel(workitem) + + onotify :dispatch, :cancel, workitem + return end + onotify :dispatch, :before_consume, workitem + participant.consume(workitem) + + onotify :dispatch, :after_consume, workitem end end end