openwferu 0.9.12 → 0.9.12.863

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/examples/engine_template.rb +30 -0
  2. data/lib/openwfe/contextual.rb +21 -0
  3. data/lib/openwfe/engine/engine.rb +24 -24
  4. data/lib/openwfe/expool/errorjournal.rb +1 -3
  5. data/lib/openwfe/expool/expressionpool.rb +29 -24
  6. data/lib/openwfe/expool/history.rb +1 -3
  7. data/lib/openwfe/expool/journal.rb +1 -3
  8. data/lib/openwfe/expool/wfidgen.rb +1 -3
  9. data/lib/openwfe/expool/yamlexpstorage.rb +7 -7
  10. data/lib/openwfe/expressions/environment.rb +17 -6
  11. data/lib/openwfe/expressions/expressionmap.rb +1 -2
  12. data/lib/openwfe/expressions/fe_command.rb +227 -0
  13. data/lib/openwfe/expressions/fe_concurrence.rb +8 -6
  14. data/lib/openwfe/expressions/fe_cursor.rb +3 -157
  15. data/lib/openwfe/expressions/fe_define.rb +6 -5
  16. data/lib/openwfe/expressions/fe_if.rb +8 -2
  17. data/lib/openwfe/expressions/fe_iterator.rb +141 -35
  18. data/lib/openwfe/expressions/fe_subprocess.rb +3 -29
  19. data/lib/openwfe/expressions/fe_value.rb +1 -4
  20. data/lib/openwfe/expressions/flowexpression.rb +0 -5
  21. data/lib/openwfe/expressions/raw.rb +0 -2
  22. data/lib/openwfe/expressions/raw_prog.rb +15 -15
  23. data/lib/openwfe/flowexpressionid.rb +3 -3
  24. data/lib/openwfe/listeners/listeners.rb +2 -6
  25. data/lib/openwfe/participants/enoparticipants.rb +1 -2
  26. data/lib/openwfe/participants/participantmap.rb +0 -2
  27. data/lib/openwfe/participants/participants.rb +95 -4
  28. data/lib/openwfe/participants/soapparticipants.rb +15 -8
  29. data/lib/openwfe/rest/osocket.rb +2 -3
  30. data/lib/openwfe/rest/xmlcodec.rb +0 -2
  31. data/lib/openwfe/rudefinitions.rb +0 -17
  32. data/lib/openwfe/storage/yamlfilestorage.rb +3 -8
  33. data/lib/openwfe/util/observable.rb +4 -2
  34. data/lib/openwfe/util/otime.rb +10 -9
  35. data/lib/openwfe/util/safe.rb +9 -6
  36. data/lib/openwfe/util/scheduler.rb +60 -9
  37. data/lib/openwfe/util/schedulers.rb +1 -1
  38. data/lib/openwfe/util/workqueue.rb +0 -3
  39. data/lib/openwfe/utils.rb +27 -11
  40. data/lib/openwfe/version.rb +1 -1
  41. data/lib/openwfe/workitem.rb +29 -3
  42. data/lib/openwfe/worklist/storeparticipant.rb +1 -5
  43. data/test/console_test.rb +1 -4
  44. data/test/file_persisted_engine_test.rb +64 -0
  45. data/test/file_persistence_test.rb +22 -1
  46. data/test/ft_15_iterator.rb +55 -1
  47. data/test/ft_20_cron.rb +0 -1
  48. data/test/ft_21_cron.rb +0 -1
  49. data/test/ft_26c_load.rb +4 -10
  50. data/test/ft_32_journal.rb +2 -2
  51. data/test/ft_61_elsub.rb +51 -0
  52. data/test/ft_62_procparticipant.rb +65 -0
  53. data/test/ft_tests.rb +3 -1
  54. data/test/hparticipant_test.rb +3 -3
  55. data/test/misc_test.rb +1 -1
  56. data/test/obs_test.rb +27 -0
  57. data/test/rake_qtest.rb +4 -3
  58. data/test/safely_test.rb +6 -1
  59. data/test/scheduler_test.rb +85 -2
  60. data/test/sec_test.rb +9 -7
  61. metadata +6 -14
  62. data/lib/openwfe/listeners/sqslisteners.rb +0 -145
  63. data/lib/openwfe/participants/atomparticipants.rb +0 -181
  64. data/lib/openwfe/participants/csvparticipants.rb +0 -127
  65. data/lib/openwfe/participants/sqsparticipants.rb +0 -121
  66. data/lib/openwfe/storage/yamlextras.rb +0 -115
  67. data/lib/openwfe/util/csvtable.rb +0 -448
  68. data/lib/openwfe/util/sqs.rb +0 -581
  69. data/test/atom_test.rb +0 -100
  70. data/test/csv_test.rb +0 -342
  71. data/test/ft_19_csv.rb +0 -65
  72. data/test/rest_test.rb +0 -189
  73. data/test/sqs_test.rb +0 -103
@@ -16,6 +16,7 @@ require 'openwfe/participants/participants'
16
16
  #
17
17
 
18
18
  #application_context = {}
19
+
19
20
  #application_context[:work_directory] = "work"
20
21
  #
21
22
  # OpenWFEru engines take one optional argument : application_context
@@ -28,8 +29,27 @@ require 'openwfe/participants/participants'
28
29
  # ...
29
30
  #
30
31
 
32
+ #application_context[:remote_definitions_allowed] = true
33
+ #
34
+ # unless this parameter is set to true, the engine will not accept
35
+ # to launch processes whose definition is given by a URL, only
36
+ # local process definitions (file:) or direct process definitions
37
+ # will be allowed.
38
+
39
+ #application_context[:ruby_eval_allowed] = true
40
+ #
41
+ # if this parameter is set to true, evaluation of ruby code in process
42
+ # definition strings will be allowed as well as the ruby version of
43
+ # certain expression attributes like :
44
+ #
45
+ # <participant name="${ruby:LDAP::lookup(customer_id)" />
46
+ # or
47
+ # <if rtest="var % 2 == 0"> ...
48
+ #
49
+
31
50
 
32
51
  #engine = OpenWFE::Engine.new
52
+ #engine = OpenWFE::Engine.new(application_context)
33
53
  #
34
54
  # an in-memory, totally transient engine
35
55
  #
@@ -37,17 +57,27 @@ require 'openwfe/participants/participants'
37
57
  # process definitions to run
38
58
 
39
59
  #engine = OpenWFE::FilePersistedEngine.new
60
+ #engine = OpenWFE::FilePersistedEngine.new(application_context)
40
61
  #
41
62
  # a file persisted engine, slow, used only within unit tests
42
63
  # do not use
43
64
 
44
65
  engine = OpenWFE::CachedFilePersistedEngine.new
66
+ #engine = OpenWFE::CachedFilePersistedEngine.new(application_context)
45
67
  #
46
68
  # a file persisted engine, with an in-memory cache.
47
69
  # use that
48
70
  #
49
71
  # persistence is done by default under ./work/
50
72
 
73
+ at_exit do
74
+ #
75
+ # making sure that the engine gets properly stopped when
76
+ # Ruby exits.
77
+ #
78
+ engine.stop
79
+ end
80
+
51
81
  # -- a console
52
82
 
53
83
  #engine.enable_irb_console
@@ -87,6 +87,27 @@ module OpenWFE
87
87
  s
88
88
  end
89
89
 
90
+ #
91
+ # Returns the work directory for the OpenWFE[ru] application context
92
+ # (if any).
93
+ #
94
+ def get_work_directory (context_or_dir=nil)
95
+
96
+ dir = if context_or_dir.is_a?(String)
97
+ context_or_dir
98
+ elsif context_or_dir.respond_to?(:[])
99
+ context_or_dir[:work_directory]
100
+ else
101
+ @application_context[:work_directory] if @application_context
102
+ end
103
+
104
+ dir = DEFAULT_WORK_DIRECTORY unless dir
105
+
106
+ FileUtils.makedirs(dir) unless File.exist?(dir)
107
+
108
+ dir
109
+ end
110
+
90
111
  end
91
112
 
92
113
  end
@@ -30,8 +30,6 @@
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
33
- # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
- #
35
33
 
36
34
  #
37
35
  # "made in Japan"
@@ -137,10 +135,11 @@ module OpenWFE
137
135
  end
138
136
 
139
137
  #
140
- # Call this method once the participant for a persisted engine
138
+ # Call this method once the participants for a persisted engine
141
139
  # have been [re]added.
142
- # If you call this method too soon, missing participants will
143
- # cause troubles... Call this method after all the participants
140
+ #
141
+ # If this method is called too soon, missing participants will
142
+ # cause trouble... Call this method after all the participants
144
143
  # have been added.
145
144
  #
146
145
  def reschedule
@@ -152,7 +151,7 @@ module OpenWFE
152
151
  #
153
152
  # When 'parameters' are used at the top of a process definition, this
154
153
  # method can be used to assert a launchitem before launch.
155
- # An expression will get raised if the parameters do not match the
154
+ # An expression will be raised if the parameters do not match the
156
155
  # requirements.
157
156
  #
158
157
  # Note that the launch method will raise those exceptions as well.
@@ -420,31 +419,32 @@ module OpenWFE
420
419
  fei_or_wfid
421
420
  end
422
421
 
423
- #Thread.pass
424
- # #
425
- # # let the flow 'stabilize' or progress before enquiring
426
- #fexp = get_expression_pool.fetch_expression(fei)
427
- #return unless fexp
428
- #
429
- # doesn't work well
430
-
431
422
  t = Thread.new { Thread.stop }
432
423
 
433
- get_expression_pool.add_observer(:terminate) do |channel, fe, wi|
424
+ to = get_expression_pool.add_observer(:terminate) do |c, fe, wi|
434
425
  t.wakeup if fe.fei.workflow_instance_id == wfid
435
426
  end
427
+ te = get_expression_pool.add_observer(:error) do |c, fei, m, wi, se|
428
+ t.wakeup if fei.parent_wfid == wfid
429
+ end
436
430
 
437
431
  ldebug { "wait_for() #{wfid}" }
438
432
 
439
433
  t.join
434
+
435
+ get_expression_pool.remove_observer to, :terminate
436
+ get_expression_pool.remove_observer te, :error
437
+ #
438
+ # it would work as well without specifying the channel,
439
+ # but it's thus a little bit faster
440
440
  end
441
441
 
442
442
  #
443
443
  # Returns a hash of ProcessStatus instances. The keys of the hash
444
444
  # are workflow instance ids.
445
445
  #
446
- # A ProcessStatus is a description of the state of a process instance
447
- # it enumerates the expressions where the process is currently
446
+ # A ProcessStatus is a description of the state of a process instance.
447
+ # It enumerates the expressions where the process is currently
448
448
  # located (waiting certainly) and the errors the process currently
449
449
  # has (hopefully none).
450
450
  #
@@ -500,13 +500,13 @@ module OpenWFE
500
500
  # Lists all workflow (process) instances currently in the expool (in
501
501
  # the engine).
502
502
  # This method will return a list of "process-definition" expressions
503
- # (root of flows).
504
- #
505
- # "wfid_prefix" allows your to query for specific workflow instance
506
- # id prefixes.
503
+ # (i.e. OpenWFE::DefineExpression objects -- each representing the root
504
+ # element of a flow).
507
505
  #
508
- # If consider_subprocesses is set to true, "process-definition"
509
- # expressions of subprocesses will be returned as well.
506
+ # consider_subprocesses :: if true, "process-definition" expressions of
507
+ # subprocesses will be returned as well.
508
+ # wfid_prefix :: allows your to query for specific workflow instance
509
+ # id prefixes.
510
510
  #
511
511
  def list_processes (consider_subprocesses=false, wfid_prefix=nil)
512
512
 
@@ -636,7 +636,7 @@ module OpenWFE
636
636
  end
637
637
 
638
638
  #
639
- # ProcessStatus gathers information about the status of a business
639
+ # ProcessStatus represents information about the status of a workflow
640
640
  # process instance.
641
641
  #
642
642
  # The status is mainly a list of expressions and a hash of errors.
@@ -30,8 +30,6 @@
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
33
- # $Id$
34
- #
35
33
 
36
34
  #
37
35
  # "made in Japan"
@@ -274,7 +272,7 @@ module OpenWFE
274
272
 
275
273
  super
276
274
 
277
- @workdir = OpenWFE::get_work_directory + "/ejournal"
275
+ @workdir = get_work_directory + "/ejournal"
278
276
 
279
277
  FileUtils.makedirs(@workdir) unless File.exist?(@workdir)
280
278
  end
@@ -30,8 +30,6 @@
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
33
- # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
- #
35
33
 
36
34
  #
37
35
  # "made in Japan"
@@ -69,7 +67,7 @@ module OpenWFE
69
67
  #
70
68
  # This special flow expression id is used by the forget() method
71
69
  # (which is used by the forget expression and the concurrence
72
- # synchronization expressions)
70
+ # synchronization expressions)
73
71
  #
74
72
  GONE_PARENT_ID = FlowExpressionId.new
75
73
  GONE_PARENT_ID.owfe_version = "any"
@@ -90,18 +88,18 @@ module OpenWFE
90
88
  # expressions.
91
89
  #
92
90
  class ExpressionPool
93
- include \
94
- ServiceMixin,
95
- MonitorMixin,
96
- OwfeServiceLocator,
97
- Observable,
98
- WorkqueueMixin,
99
- FeiMixin
91
+ include ServiceMixin
92
+ include OwfeServiceLocator
93
+ include Observable
94
+ include WorkqueueMixin
95
+ include FeiMixin
96
+ include MonitorMixin
100
97
 
98
+ #
99
+ # code loaded from a remote URI will get evaluated with
100
+ # that security level
101
+ #
101
102
  SAFETY_LEVEL = 2
102
- #
103
- # code loaded from a remote URI will get evaluated with
104
- # that security level
105
103
 
106
104
  def initialize (service_name, application_context)
107
105
 
@@ -122,8 +120,13 @@ module OpenWFE
122
120
  # Stops this expression pool (especially its workqueue).
123
121
  #
124
122
  def stop
123
+
125
124
  @stopped = true
125
+
126
126
  stop_workqueue
127
+ #
128
+ # flushes the work queue
129
+
127
130
  onotify :stop
128
131
  end
129
132
 
@@ -133,6 +136,7 @@ module OpenWFE
133
136
  # the monitor mixin by themselves
134
137
  #
135
138
  def get_monitor (fei)
139
+
136
140
  return @monitors[fei]
137
141
  end
138
142
 
@@ -851,7 +855,7 @@ module OpenWFE
851
855
  # "determine_representation() from class #{param.class.name}"
852
856
  #end
853
857
 
854
- param = read_uri(param) if param.is_a? URI
858
+ param = read_uri(param) if param.is_a?(URI)
855
859
 
856
860
  #ldebug do
857
861
  # "determine_representation() " +
@@ -966,16 +970,17 @@ module OpenWFE
966
970
 
967
971
  def [] (key)
968
972
  synchronize do
969
- #ldebug { "[] caller :\n" + OpenWFE::caller_to_s(8) }
970
- mon = @monitors[key]
971
- if not mon
972
- #ldebug { "[] creating new Monitor for #{key}" }
973
- mon = Monitor.new
974
- @monitors[key] = mon
975
- else
976
- #ldebug { "[] already had Monitor for #{key}" }
977
- end
978
- return mon
973
+
974
+ (@monitors[key] ||= Monitor.new)
975
+ #if not mon
976
+ # #ldebug { "[] creating new Monitor for #{key}" }
977
+ # mon = Monitor.new
978
+ # @monitors[key] = mon
979
+ #else
980
+ # #ldebug { "[] already had Monitor for #{key}" }
981
+ #end
982
+ #
983
+ #mon
979
984
  end
980
985
  end
981
986
 
@@ -30,8 +30,6 @@
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
33
- # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
- #
35
33
 
36
34
  #
37
35
  # "made in Japan"
@@ -153,7 +151,7 @@ module OpenWFE
153
151
 
154
152
  super
155
153
 
156
- @output = OpenWFE::get_work_directory + "/history.log"
154
+ @output = get_work_directory + "/history.log"
157
155
  @output = File.open(@output, "w+")
158
156
 
159
157
  linfo { "new() outputting history to #{@output.path}" }
@@ -30,8 +30,6 @@
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
33
- # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
- #
35
33
 
36
34
  #
37
35
  # "made in Japan"
@@ -73,7 +71,7 @@ module OpenWFE
73
71
 
74
72
  @buckets = {}
75
73
 
76
- @workdir = OpenWFE::get_work_directory + "/journal"
74
+ @workdir = get_work_directory + "/journal"
77
75
  @donedir = @workdir + "/done"
78
76
 
79
77
  FileUtils.makedirs(@donedir) unless File.exist?(@donedir)
@@ -30,8 +30,6 @@
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
33
- # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
- #
35
33
 
36
34
  #
37
35
  # "made in Japan"
@@ -61,7 +59,7 @@ module OpenWFE
61
59
  @last = -1
62
60
  @mutex = Mutex.new
63
61
 
64
- @last_fn = OpenWFE::get_work_directory + '/wfidgen.last'
62
+ @last_fn = get_work_directory + '/wfidgen.last'
65
63
 
66
64
  load_last()
67
65
 
@@ -30,8 +30,6 @@
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
33
- # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
- #
35
33
 
36
34
  #
37
35
  # "made in Japan"
@@ -41,7 +39,6 @@
41
39
  #
42
40
 
43
41
  require 'openwfe/utils'
44
- require 'openwfe/rudefinitions'
45
42
  require 'openwfe/storage/yamlextras'
46
43
  require 'openwfe/storage/yamlfilestorage'
47
44
 
@@ -57,16 +54,15 @@ require 'openwfe/expressions/raw_xml'
57
54
  module OpenWFE
58
55
 
59
56
  #
60
- # yaml expression storage
57
+ # YAML expression storage. Expressions (atomic pieces of process instances)
58
+ # are stored in a hierarchy of YAML files.
61
59
  #
62
60
  class YamlFileExpressionStorage < YamlFileStorage
63
61
  include OwfeServiceLocator
64
62
 
65
63
  def initialize (service_name, application_context)
66
64
 
67
- path = OpenWFE::get_work_directory + '/expool'
68
-
69
- super(service_name, application_context, path)
65
+ super(service_name, application_context, '/expool')
70
66
 
71
67
  observe_expool()
72
68
  end
@@ -117,6 +113,10 @@ module OpenWFE
117
113
 
118
114
  alias :real_each :each
119
115
 
116
+ #
117
+ # Returns a human-readable list of the current YAML file paths.
118
+ # (one expression per path).
119
+ #
120
120
  def to_s
121
121
 
122
122
  s = "\n\n==== #{self.class} ===="
@@ -29,9 +29,6 @@
29
29
  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
- #
33
- # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
- #
35
32
 
36
33
  #
37
34
  # "made in Japan"
@@ -55,8 +52,7 @@ module OpenWFE
55
52
 
56
53
  names :environment
57
54
 
58
- attr_accessor \
59
- :variables
55
+ attr_accessor :variables
60
56
 
61
57
  def initialize \
62
58
  (fei, parent, environment_id, application_context, attributes)
@@ -66,6 +62,9 @@ module OpenWFE
66
62
  @variables = {}
67
63
  end
68
64
 
65
+ #
66
+ # Looks up for the value of a variable in this environment.
67
+ #
69
68
  def [] (key)
70
69
 
71
70
  value = @variables[key]
@@ -75,10 +74,19 @@ module OpenWFE
75
74
 
76
75
  return get_parent[key] if @parent_id
77
76
 
78
- return get_expression_pool.fetch_engine_environment[key]
77
+ get_expression_pool.fetch_engine_environment[key]
79
78
  end
80
79
 
80
+ #
81
+ # Binds a variable in this environment.
82
+ #
81
83
  def []= (key, value)
84
+
85
+ #ldebug do
86
+ # "#{fei.to_debug_s} []= "+
87
+ # "'#{key}' => '#{value}' (#{value.class.name})"
88
+ #end
89
+
82
90
  synchronize do
83
91
 
84
92
  @variables[key] = value
@@ -86,6 +94,9 @@ module OpenWFE
86
94
  end
87
95
  end
88
96
 
97
+ #
98
+ # Removes a variable from this environment.
99
+ #
89
100
  def delete (key)
90
101
  synchronize do
91
102
 
@@ -30,8 +30,6 @@
30
30
  # POSSIBILITY OF SUCH DAMAGE.
31
31
  #++
32
32
  #
33
- # $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
34
- #
35
33
 
36
34
  #
37
35
  # "made in Japan"
@@ -55,6 +53,7 @@ require 'openwfe/expressions/fe_when'
55
53
  require 'openwfe/expressions/fe_wait'
56
54
  require 'openwfe/expressions/fe_reserve'
57
55
  require 'openwfe/expressions/fe_losfor'
56
+ require 'openwfe/expressions/fe_command'
58
57
  require 'openwfe/expressions/fe_cursor'
59
58
  require 'openwfe/expressions/fe_iterator'
60
59
  require 'openwfe/expressions/fe_fqv'