Module: OpenWFE::LocalParticipant

Overview

Local participants provide handy methods like reply_to_engine() to further implementations of the Participant concept.

Instance Attribute Summary

Attributes included from Contextual

#application_context

Instance Method Summary collapse

Methods included from Participant

#consume

Methods included from Contextual

#get_work_directory, #init_service, #lookup

Methods included from Logging

#ldebug, #ldebug_callstack, #lerror, #lfatal, #linfo, #llog, #lunknown, #lwarn

Methods included from OwfeServiceLocator

#get_engine, #get_error_journal, #get_expool, #get_expression_map, #get_expression_pool, #get_expression_storage, #get_expression_storages, #get_journal, #get_participant_map, #get_scheduler, #get_wfid_generator

Instance Method Details

#call_block(block, workitem) ⇒ Object

A convenience method for calling block passed to participants for templates (mail participants) or execution (BlockParticipant).

Allows for such blocks :

{ |workitem| ... }
{ |participant_expression, workitem| ... }
{ |participant_expression, participant, workitem| ... }

For 0 or more than 3 arguments, the block will be called without arguments.



117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/openwfe/participants/participant.rb', line 117

def call_block (block, workitem)

    if block.arity == 1
        block.call workitem
    elsif block.arity == 2
        block.call get_flow_expression(workitem), workitem
    elsif block.arity == 3
        block.call get_flow_expression(workitem), self, workitem
    else
        block.call
    end
end

#get_flow_expression(workitem) ⇒ Object

Returns the FlowExpression instance that triggered this participant. A ParticipantExpression instance will most likely be returned.



97
98
99
100
101
102
# File 'lib/openwfe/participants/participant.rb', line 97

def get_flow_expression (workitem)

    return nil if not @application_context

    get_expression_pool.fetch_expression(workitem.flow_expression_id)
end

#reply_to_engine(workitem) ⇒ Object

Participants use this method to reply to their engine when their job is done.



134
135
136
137
# File 'lib/openwfe/participants/participant.rb', line 134

def reply_to_engine (workitem)

    get_engine.reply(workitem)
end