lib/ruote/exp/fe_participant.rb in ruote-2.1.10 vs lib/ruote/exp/fe_participant.rb in ruote-2.1.11
- old
+ new
@@ -121,25 +121,31 @@
# Should return true when the dispatch was successful.
#
h_reader :dispatched
+ h_reader :participant
+
def apply
#
# determine participant
- h.participant_name = attribute(:ref) || attribute_text
+ h.participant_name = (attribute(:ref) || attribute_text).to_s
- h.participant_name = h.participant_name.to_s
+ raise ArgumentError.new(
+ "no participant name specified"
+ ) if h.participant_name == ''
- if h.participant_name == ''
- raise ArgumentError.new("no participant name specified")
+ participant_info =
+ h.participant ||
+ @context.plist.lookup_info(h.participant_name, h.applied_workitem)
+
+ unless participant_info.respond_to?(:consume)
+ h.participant = participant_info
end
- participant_info = @context.plist.lookup_info(h.participant_name)
-
raise(ArgumentError.new(
"no participant named #{h.participant_name.inspect}")
) if participant_info.nil?
#
@@ -157,10 +163,11 @@
@context.storage.put_msg(
'dispatch',
'fei' => h.fei,
'participant_name' => h.participant_name,
+ 'participant' => h.participant,
'workitem' => h.applied_workitem,
'for_engine_worker?' => (participant_info.class != Array))
end
def cancel (flavour)
@@ -175,19 +182,23 @@
@context.storage.put_msg(
'dispatch_cancel',
'fei' => h.fei,
'participant_name' => h.participant_name,
+ 'participant' => h.participant,
'flavour' => flavour,
'workitem' => h.applied_workitem)
end
def reply (workitem)
- pa = @context.plist.lookup(
- workitem['participant_name'], :on_reply => true)
+ pinfo =
+ h.participant ||
+ @context.plist.lookup_info(h.participant_name, workitem)
+ pa = @context.plist.instantiate(pinfo, :if_respond_to? => :on_reply)
+
pa.on_reply(Ruote::Workitem.new(workitem)) if pa
super(workitem)
end
@@ -225,13 +236,20 @@
# Note that process definition timeout has priority over participant
# specified timeout.
#
def schedule_timeout (p_info)
- timeout =
- attribute(:timeout) ||
- (p_info.timeout rescue nil) ||
- (p_info.is_a?(Array) ? p_info.last['timeout'] : nil)
+ timeout = attribute(:timeout)
+
+ unless timeout
+
+ pa = @context.plist.instantiate(p_info, :if_respond_to? => :timeout)
+
+ timeout = pa.timeout if pa && pa.method(:timeout).arity == 0
+ #
+ # the arity check is for jruby which seems to have a timeout
+ # method here and there
+ end
do_schedule_timeout(timeout)
end
end
end