openwferu 0.9.16 → 0.9.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/examples/about_state.rb +81 -0
  2. data/examples/engine_template.rb +7 -0
  3. data/lib/openwfe/contextual.rb +2 -2
  4. data/lib/openwfe/def.rb +2 -3
  5. data/lib/openwfe/{util/schedulers.rb → engine.rb} +3 -39
  6. data/lib/openwfe/engine/engine.rb +202 -251
  7. data/lib/openwfe/engine/process_status.rb +359 -0
  8. data/lib/openwfe/expool/errorjournal.rb +6 -6
  9. data/lib/openwfe/expool/expressionpool.rb +161 -239
  10. data/lib/openwfe/expool/expstorage.rb +185 -55
  11. data/lib/openwfe/expool/journal.rb +1 -2
  12. data/lib/openwfe/expool/parser.rb +233 -0
  13. data/lib/openwfe/expool/threadedexpstorage.rb +6 -18
  14. data/lib/openwfe/expool/wfidgen.rb +25 -7
  15. data/lib/openwfe/expool/yamlexpstorage.rb +60 -37
  16. data/lib/openwfe/expressions/condition.rb +49 -12
  17. data/lib/openwfe/expressions/environment.rb +45 -15
  18. data/lib/openwfe/expressions/expressionmap.rb +39 -19
  19. data/lib/openwfe/expressions/fe_concurrence.rb +24 -13
  20. data/lib/openwfe/expressions/fe_cron.rb +19 -18
  21. data/lib/openwfe/expressions/fe_cursor.rb +69 -28
  22. data/lib/openwfe/expressions/fe_define.rb +4 -1
  23. data/lib/openwfe/expressions/fe_do.rb +1 -3
  24. data/lib/openwfe/expressions/fe_equals.rb +131 -20
  25. data/lib/openwfe/expressions/fe_fqv.rb +27 -3
  26. data/lib/openwfe/expressions/fe_iterator.rb +14 -7
  27. data/lib/openwfe/expressions/fe_listen.rb +7 -2
  28. data/lib/openwfe/expressions/fe_misc.rb +187 -20
  29. data/lib/openwfe/expressions/fe_participant.rb +8 -7
  30. data/lib/openwfe/expressions/fe_reserve.rb +105 -33
  31. data/lib/openwfe/expressions/fe_save.rb +55 -5
  32. data/lib/openwfe/expressions/{fe_value.rb → fe_set.rb} +6 -82
  33. data/lib/openwfe/expressions/fe_sleep.rb +25 -15
  34. data/lib/openwfe/expressions/fe_subprocess.rb +2 -2
  35. data/lib/openwfe/expressions/fe_wait.rb +3 -2
  36. data/lib/openwfe/expressions/fe_when.rb +7 -15
  37. data/lib/openwfe/expressions/flowexpression.rb +90 -49
  38. data/lib/openwfe/expressions/merge.rb +7 -1
  39. data/lib/openwfe/expressions/raw.rb +261 -63
  40. data/lib/openwfe/expressions/{raw_prog.rb → rprocdef.rb} +94 -179
  41. data/lib/openwfe/expressions/time.rb +36 -12
  42. data/lib/openwfe/expressions/timeout.rb +9 -7
  43. data/lib/openwfe/expressions/value.rb +126 -0
  44. data/lib/openwfe/flowexpressionid.rb +52 -22
  45. data/lib/openwfe/listeners/listeners.rb +3 -3
  46. data/lib/openwfe/listeners/socketlisteners.rb +8 -5
  47. data/lib/openwfe/logging.rb +6 -3
  48. data/lib/openwfe/omixins.rb +8 -6
  49. data/lib/openwfe/orest/xmlcodec.rb +16 -12
  50. data/lib/openwfe/participants.rb +38 -0
  51. data/lib/openwfe/participants/participant.rb +1 -1
  52. data/lib/openwfe/participants/participantmap.rb +24 -10
  53. data/lib/openwfe/participants/participants.rb +4 -3
  54. data/lib/openwfe/participants/soapparticipants.rb +1 -1
  55. data/lib/openwfe/participants/socketparticipants.rb +1 -1
  56. data/lib/openwfe/rudefinitions.rb +7 -5
  57. data/lib/openwfe/storage/yamlcustom.rb +10 -10
  58. data/lib/openwfe/storage/yamlfilestorage.rb +12 -12
  59. data/lib/openwfe/tools/flowtracer.rb +6 -5
  60. data/lib/openwfe/util/dollar.rb +42 -85
  61. data/lib/openwfe/util/ometa.rb +1 -3
  62. data/lib/openwfe/util/workqueue.rb +1 -1
  63. data/lib/openwfe/utils.rb +33 -11
  64. data/lib/openwfe/version.rb +2 -2
  65. data/lib/openwfe/workitem.rb +76 -14
  66. data/lib/openwfe/worklist/storelocks.rb +9 -4
  67. data/lib/openwfe/worklist/storeparticipant.rb +1 -1
  68. data/test/back_0916_test.rb +101 -0
  69. data/test/bm/ft_26_load.rb +1 -1
  70. data/test/bm/ft_26b_load.rb +1 -1
  71. data/test/bm/ft_26c_load.rb +3 -2
  72. data/test/bm/ft_26d_load.rb +97 -0
  73. data/test/bm/ft_recu.rb +71 -0
  74. data/test/concurrence_test.rb +1 -1
  75. data/test/condition_test.rb +152 -0
  76. data/test/description_test.rb +12 -7
  77. data/test/eno_test.rb +1 -1
  78. data/test/expool_20031219_0916.tgz +0 -0
  79. data/test/fe_lookup_att_test.rb +1 -1
  80. data/test/fei_test.rb +16 -0
  81. data/test/file_persistence_test.rb +8 -12
  82. data/test/filep_cancel_test.rb +116 -0
  83. data/test/flowtestbase.rb +47 -25
  84. data/test/ft_0.rb +1 -1
  85. data/test/ft_10_loop.rb +29 -14
  86. data/test/{ft_10b_loop2.rb → ft_10b_loop.rb} +2 -11
  87. data/test/ft_11_ppd.rb +6 -17
  88. data/test/ft_11b_ppd.rb +1 -4
  89. data/test/ft_12_blockparticipant.rb +1 -1
  90. data/test/ft_13_eno.rb +1 -1
  91. data/test/ft_15_iterator.rb +1 -1
  92. data/test/ft_15b_iterator.rb +1 -1
  93. data/test/ft_17_condition.rb +6 -6
  94. data/test/ft_18_pname.rb +1 -1
  95. data/test/ft_20_cron.rb +1 -1
  96. data/test/ft_21_cron.rb +6 -4
  97. data/test/ft_22_history.rb +1 -1
  98. data/test/ft_23_when.rb +1 -1
  99. data/test/ft_23b_when.rb +18 -6
  100. data/test/ft_23c_wait.rb +8 -6
  101. data/test/ft_25_cancel.rb +7 -5
  102. data/test/ft_27_getflowpos.rb +22 -17
  103. data/test/ft_28_fileparticipant.rb +1 -2
  104. data/test/ft_2_concurrence.rb +1 -1
  105. data/test/ft_2b_concurrence.rb +25 -20
  106. data/test/ft_30_socketlistener.rb +0 -3
  107. data/test/ft_34_cancelwfid.rb +9 -9
  108. data/test/ft_35_localdefs.rb +0 -1
  109. data/test/ft_36_subprocids.rb +6 -6
  110. data/test/ft_38_tag.rb +3 -2
  111. data/test/ft_38b_tag.rb +229 -0
  112. data/test/ft_39_reserve.rb +3 -18
  113. data/test/ft_39b_reserve.rb +34 -5
  114. data/test/ft_3b_lookup_vf.rb +83 -0
  115. data/test/ft_40_defined.rb +2 -11
  116. data/test/ft_42_environments.rb +4 -6
  117. data/test/ft_44b_restore.rb +88 -22
  118. data/test/ft_45_citerator.rb +57 -11
  119. data/test/ft_49_condition.rb +4 -2
  120. data/test/ft_4_misc.rb +24 -3
  121. data/test/ft_50_xml_attribute.rb +17 -20
  122. data/test/ft_54_listen.rb +1 -1
  123. data/test/ft_54b_listen.rb +2 -2
  124. data/test/ft_56_timeout.rb +8 -1
  125. data/test/ft_57_a.rb +10 -10
  126. data/test/ft_59_ps.rb +49 -16
  127. data/test/ft_60_ecancel.rb +52 -10
  128. data/test/ft_63_pause.rb +8 -8
  129. data/test/ft_65_stringlaunch.rb +4 -6
  130. data/test/ft_67_schedlaunch.rb +4 -4
  131. data/test/ft_69_cancelmissing.rb +4 -2
  132. data/test/ft_70_lookupvar.rb +2 -2
  133. data/test/ft_72_lookup_processes.rb +2 -2
  134. data/test/ft_73_cancel_sub.rb +8 -8
  135. data/test/ft_77_segments.rb +38 -0
  136. data/test/ft_78_eval.rb +154 -0
  137. data/test/ft_79_tticket.rb +185 -0
  138. data/test/ft_80_spname.rb +95 -0
  139. data/test/ft_81_exp.rb +64 -0
  140. data/test/ft_82_trecu.rb +48 -0
  141. data/test/ft_83_badpause.rb +62 -0
  142. data/test/ft_84_updateexp.rb +125 -0
  143. data/test/ft_9b_cursor.rb +105 -0
  144. data/test/ft_tests.rb +14 -1
  145. data/test/hash_test.rb +7 -7
  146. data/test/hparticipant_test.rb +4 -4
  147. data/test/lookup_vf_test.rb +94 -0
  148. data/test/misc_test.rb +5 -3
  149. data/test/orest_test.rb +4 -3
  150. data/test/param_test.rb +12 -16
  151. data/test/participant_test.rb +36 -0
  152. data/test/pending.rb +10 -10
  153. data/test/rake_ltest.rb +1 -10
  154. data/test/rake_qtest.rb +7 -6
  155. data/test/raw_prog_test.rb +89 -121
  156. data/test/restart_cron_test.rb +84 -36
  157. data/test/restart_paused_test.rb +100 -0
  158. data/test/restart_sleep_test.rb +1 -1
  159. data/test/restart_tests.rb +1 -0
  160. data/test/restart_when_test.rb +33 -22
  161. data/test/ruby_procdef_test.rb +19 -18
  162. data/test/sec_test.rb +74 -35
  163. data/test/storage_test.rb +44 -0
  164. data/test/test.rb +3 -0
  165. data/test/timeout_test.rb +7 -18
  166. data/test/wfid_test.rb +2 -1
  167. data/test/wi_test.rb +29 -18
  168. metadata +121 -57
  169. data/lib/openwfe/expressions/raw_xml.rb +0 -176
  170. data/lib/openwfe/expressions/simplerep.rb +0 -266
  171. data/lib/openwfe/util/kotoba.rb +0 -236
  172. data/lib/openwfe/util/lru.rb +0 -171
  173. data/lib/openwfe/util/otime.rb +0 -246
  174. data/lib/openwfe/util/safe.rb +0 -160
  175. data/lib/openwfe/util/scheduler.rb +0 -1158
  176. data/test/cron_test.rb +0 -113
  177. data/test/cronline_test.rb +0 -60
  178. data/test/dollar_test.rb +0 -90
  179. data/test/kotoba_test.rb +0 -72
  180. data/test/lru_test.rb +0 -79
  181. data/test/safely_test.rb +0 -84
  182. data/test/scheduler_1_test.rb +0 -88
  183. data/test/scheduler_test.rb +0 -363
  184. data/test/time_test.rb +0 -84
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2007-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -37,11 +37,10 @@
37
37
  # John Mettraux at openwfe.org
38
38
  #
39
39
 
40
- require 'rexml/document'
40
+ require 'rufus/eval' # gem 'rufus-eval'
41
41
 
42
42
  require 'openwfe/utils'
43
43
  require 'openwfe/expressions/raw'
44
- require 'openwfe/expressions/simplerep'
45
44
 
46
45
 
47
46
  module OpenWFE
@@ -72,7 +71,8 @@ module OpenWFE
72
71
 
73
72
  attr_reader :context
74
73
 
75
- def initialize ()
74
+ def initialize
75
+
76
76
  super()
77
77
  @context = Context.new
78
78
  end
@@ -90,7 +90,7 @@ module OpenWFE
90
90
 
91
91
  def self.method_missing (m, *args, &block)
92
92
 
93
- @ccontext = Context.new() \
93
+ @ccontext = Context.new \
94
94
  if (not @ccontext) or @ccontext.discarded?
95
95
 
96
96
  ProcessDefinition.make_expression(
@@ -100,15 +100,22 @@ module OpenWFE
100
100
  &block)
101
101
  end
102
102
 
103
+ #
104
+ # builds an actual expression representation (a node in the
105
+ # process definition tree).
106
+ #
103
107
  def self.make_expression (context, exp_name, params, &block)
104
108
 
105
109
  string_child = nil
106
- attributes = OpenWFE::SymbolHash.new
110
+ #attributes = OpenWFE::SymbolHash.new
111
+ attributes = Hash.new
107
112
 
108
113
  #puts " ... params.class is #{params.class}"
109
114
 
110
115
  if params.kind_of?(Hash)
116
+
111
117
  params.each do |k, v|
118
+
112
119
  if k == '0'
113
120
  string_child = v.to_s
114
121
  else
@@ -116,20 +123,22 @@ module OpenWFE
116
123
  attributes[OpenWFE::symbol_to_name(k.to_s)] = v
117
124
  end
118
125
  end
126
+
119
127
  elsif params
128
+
120
129
  string_child = params.to_s
121
130
  end
122
131
 
123
- exp = SimpleExpRepresentation.new(exp_name, attributes)
132
+ exp = [ exp_name, attributes, [] ]
124
133
 
125
- exp.children << string_child \
134
+ exp.last << string_child \
126
135
  if string_child
127
136
 
128
137
  if context.parent_expression
129
138
  #
130
139
  # adding this new expression to its parent
131
140
  #
132
- context.parent_expression << exp
141
+ context.parent_expression.last << exp
133
142
  else
134
143
  #
135
144
  # an orphan, a top expression
@@ -137,14 +146,14 @@ module OpenWFE
137
146
  context.top_expressions << exp
138
147
  end
139
148
 
140
- return exp if not block
149
+ return exp unless block
141
150
 
142
- context.push_parent_expression(exp)
151
+ context.push_parent_expression exp
143
152
 
144
153
  result = block.call
145
154
 
146
- exp.children << result \
147
- if result and result.kind_of? String
155
+ exp.last << result \
156
+ if result and result.kind_of?(String)
148
157
 
149
158
  context.pop_parent_expression
150
159
 
@@ -152,23 +161,28 @@ module OpenWFE
152
161
  end
153
162
 
154
163
  def do_make
155
- ProcessDefinition.do_make(self)
164
+
165
+ ProcessDefinition.do_make self
156
166
  end
157
167
 
158
168
  #
159
169
  # A class method for actually "making" the process
160
170
  # segment raw representation
161
171
  #
162
- def ProcessDefinition.do_make (instance=nil)
172
+ def self.do_make (instance=nil)
163
173
 
164
174
  context = if @ccontext
175
+
165
176
  @ccontext.discard
166
177
  # preventing further additions in case of reevaluation
167
178
  @ccontext
179
+
168
180
  elsif instance
181
+
169
182
  instance.make
170
183
  instance.context
171
184
  else
185
+
172
186
  pdef = self.new
173
187
  pdef.make
174
188
  pdef.context
@@ -179,14 +193,11 @@ module OpenWFE
179
193
  name, revision =
180
194
  extract_name_and_revision(self.metaclass.to_s[8..-2])
181
195
 
182
- attributes = {}
183
- attributes["name"] = name
184
- attributes["revision"] = revision
185
-
186
- top_expression = SimpleExpRepresentation.new(
187
- "process-definition", attributes)
188
-
189
- top_expression.children = context.top_expressions
196
+ top_expression = [
197
+ "process-definition",
198
+ { "name" => name, "revision" => revision },
199
+ context.top_expressions
200
+ ]
190
201
 
191
202
  top_expression
192
203
  end
@@ -199,7 +210,8 @@ module OpenWFE
199
210
 
200
211
  ruby_proc_def_string.each_line do |l|
201
212
 
202
- m = l.match " *class *([a-zA-Z0-9]*) *< .*ProcessDefinition"
213
+ m = ClassNameRex.match l
214
+
203
215
  return eval(m[1]) if m
204
216
  end
205
217
 
@@ -211,20 +223,57 @@ module OpenWFE
211
223
  #
212
224
  def self.eval_ruby_process_definition (code, safety_level=2)
213
225
 
214
- o = OpenWFE::eval_safely(code, safety_level)
226
+ #puts "\nin:\n#{code}\n"
227
+
228
+ code, is_wrapped = wrap_code code
229
+
230
+ o = Rufus::eval_safely code, safety_level, binding()
215
231
 
216
232
  o = extract_class(code) \
217
- if (o == nil) or o.is_a?(SimpleExpRepresentation)
233
+ if (o == nil) or o.is_a?(Array)
234
+ #if (o == nil) or o.is_a?(SimpleExpRepresentation)
235
+ #
236
+ # grab the first process definition class found
237
+ # in the given code
218
238
 
219
- return o.do_make \
220
- if o.is_a?(ProcessDefinition) or o.is_a?(Class)
239
+ #return o.do_make \
240
+ # if o.is_a?(ProcessDefinition) or o.is_a?(Class)
241
+ #o
221
242
 
222
- o
243
+ result = o.do_make
244
+
245
+ #return result.first_child if is_wrapped
246
+ return result.last.first if is_wrapped
247
+
248
+ result
223
249
  end
224
250
 
225
251
  protected
226
252
 
227
- def ProcessDefinition.pack_args (args)
253
+ ClassNameRex = Regexp.compile(
254
+ " *class *([a-zA-Z0-9]*) *< .*ProcessDefinition")
255
+ ProcessDefinitionRex = Regexp.compile(
256
+ "^class *[a-zA-Z0-9]* *< .*ProcessDefinition")
257
+ ProcessNameAndDefRex = Regexp.compile(
258
+ "([^0-9_]*)_*([0-9].*)$")
259
+ ProcessNameRex = Regexp.compile(
260
+ "(.*$)")
261
+ EndsInDefinitionRex = Regexp.compile(
262
+ ".*Definition$")
263
+
264
+ def self.wrap_code (code)
265
+
266
+ return [ code, false ] if ProcessDefinitionRex.match(code)
267
+
268
+ s = "class NoName0 < ProcessDefinition"
269
+ s << "\n"
270
+ s << code
271
+ s << "\nend"
272
+
273
+ [ s, true ]
274
+ end
275
+
276
+ def self.pack_args (args)
228
277
 
229
278
  return args[0] if args.length == 1
230
279
 
@@ -239,26 +288,27 @@ module OpenWFE
239
288
  a
240
289
  end
241
290
 
242
- def ProcessDefinition.extract_name_and_revision (s)
291
+ def self.extract_name_and_revision (s)
243
292
 
244
- #puts "s is >#{s}<"
293
+ i = s.rindex("::")
294
+ s = s[i+2..-1] if i
245
295
 
246
- m = Regexp.compile(".*::([^0-9_]*)_*([0-9][0-9_]*)$").match(s)
296
+ m = ProcessNameAndDefRex.match s
247
297
  return [ as_name(m[1]), as_revision(m[2]) ] if m
248
298
 
249
- m = Regexp.compile(".*::(.*$)").match(s)
299
+ m = ProcessNameRex.match s
250
300
  return [ as_name(m[1]), '0' ] if m
251
301
 
252
302
  [ as_name(s), '0' ]
253
303
  end
254
304
 
255
- def ProcessDefinition.as_name (s)
305
+ def self.as_name (s)
256
306
 
257
- return s[0..-11] if s.match(".*Definition$")
307
+ return s[0..-11] if EndsInDefinitionRex.match(s)
258
308
  s
259
309
  end
260
310
 
261
- def ProcessDefinition.as_revision (s)
311
+ def self.as_revision (s)
262
312
 
263
313
  s.gsub("_", ".")
264
314
  end
@@ -287,8 +337,10 @@ module OpenWFE
287
337
  # is replaced with the supplied parent expression.
288
338
  #
289
339
  def push_parent_expression (exp)
340
+
290
341
  @previous_parent_expressions.push(@parent_expression) \
291
342
  if @parent_expression
343
+
292
344
  @parent_expression = exp
293
345
  end
294
346
 
@@ -297,6 +349,7 @@ module OpenWFE
297
349
  # on the top of the previous parent expression stack (pop).
298
350
  #
299
351
  def pop_parent_expression
352
+
300
353
  @parent_expression = @previous_parent_expressions.pop
301
354
  end
302
355
 
@@ -305,154 +358,16 @@ module OpenWFE
305
358
  # top expressions...
306
359
  #
307
360
  def top_expression
308
- return nil if @top_expressions.size > 1
309
- exp = @top_expressions[0]
310
- return exp if exp.name == "process-definition"
311
- nil
312
- end
313
- end
314
- end
315
-
316
- #
317
- # The actual 'programmatic' raw expression.
318
- # Its raw_representation being an instance of SimpleExpRepresentation.
319
- #
320
- class ProgRawExpression < RawExpression
321
-
322
- attr_accessor \
323
- :raw_representation
324
-
325
- def initialize \
326
- (fei, parent_id, env_id, application_context, raw_representation)
327
-
328
- super(
329
- fei,
330
- parent_id,
331
- env_id,
332
- application_context,
333
- raw_representation)
334
- end
335
-
336
- protected
337
-
338
- def extract_attributes ()
339
-
340
- raw_representation.attributes
341
- end
342
-
343
- def extract_descriptions ()
344
-
345
- result = []
346
- raw_representation.children.each do |child|
347
-
348
- next unless child.is_a?(SimpleExpRepresentation)
349
- next if child.name.intern != :description
350
-
351
- lang = child.attributes[:language]
352
- lang = child.attributes[:lang] unless lang
353
- lang = "default" unless lang
354
-
355
- result << [ lang, child.children[0] ]
356
- end
357
- result
358
- end
359
-
360
- def extract_children ()
361
-
362
- i = 0
363
- result = []
364
- raw_representation.children.each do |child|
365
-
366
- if child.kind_of?(SimpleExpRepresentation)
367
361
 
368
- cname = child.name.intern
369
-
370
- next if cname == :param
371
- next if cname == :parameter
372
- next if cname == :description
373
-
374
- cfei = @fei.dup
375
- cfei.expression_name = child.name
376
- cfei.expression_id = "#{cfei.expression_id}.#{i}"
377
-
378
- efei = @environment_id
379
-
380
- rawexp = ProgRawExpression\
381
- .new(cfei, @fei, efei, @application_context, child)
382
-
383
- get_expression_pool.update rawexp
384
-
385
- i = i + 1
386
-
387
- result << rawexp.fei
388
- else
389
-
390
- result << child
391
- end
392
- end
393
- result
394
- end
395
-
396
- def extract_text_children ()
397
-
398
- raw_representation.children.collect do |child|
399
- next if child.is_a?(SimpleExpRepresentation)
400
- child.to_s
401
- end
402
- end
403
-
404
- def extract_parameters ()
405
-
406
- r = []
407
- raw_representation.children.each do |child|
408
-
409
- next unless child.is_a?(SimpleExpRepresentation)
362
+ return nil if @top_expressions.size > 1
410
363
 
411
- name = child.name.to_sym
412
- next unless (name == :parameter or name == :param)
364
+ exp = @top_expressions.first
413
365
 
414
- r << Parameter.new(
415
- child.attributes[:field],
416
- child.attributes[:match],
417
- child.attributes[:default],
418
- child.attributes[:type])
366
+ return exp if exp.first == "process-definition"
367
+ nil
419
368
  end
420
- r
421
369
  end
422
370
  end
423
371
 
424
- private
425
-
426
- #
427
- # OpenWFE process definitions do use some
428
- # Ruby keywords... The workaround is to put an underscore
429
- # just before the name to 'escape' it.
430
- #
431
- # 'undo' isn't reserved by Ruby, but lets keep it in line
432
- # with 'do' and 'redo' that are.
433
- #
434
- KEYWORDS = [
435
- :if, :do, :redo, :undo, :print, :sleep, :loop, :break, :when
436
- #:until, :while
437
- ]
438
-
439
- #
440
- # Ensures the method name is not conflicting with Ruby keywords
441
- # and turn dashes to underscores.
442
- #
443
- def OpenWFE.make_safe (method_name)
444
- method_name = OpenWFE::to_underscore(method_name)
445
- return "_" + method_name \
446
- if KEYWORDS.include? eval(":"+method_name)
447
- method_name
448
- end
449
-
450
- def OpenWFE.to_expression_name (method_name)
451
- method_name = method_name.to_s
452
- method_name = method_name[1..-1] if method_name[0, 1] == "_"
453
- method_name = OpenWFE::to_dash(method_name)
454
- method_name
455
- end
456
-
457
372
  end
458
373
 
@@ -1,6 +1,6 @@
1
1
  #
2
2
  #--
3
- # Copyright (c) 2006-2007, John Mettraux, OpenWFE.org
3
+ # Copyright (c) 2006-2008, John Mettraux, OpenWFE.org
4
4
  # All rights reserved.
5
5
  #
6
6
  # Redistribution and use in source and binary forms, with or without
@@ -37,8 +37,7 @@
37
37
  # John Mettraux at openwfe.org
38
38
  #
39
39
 
40
- require 'openwfe/util/otime'
41
- require 'openwfe/util/scheduler'
40
+ require 'rufus/otime'
42
41
  require 'openwfe/expressions/timeout'
43
42
 
44
43
 
@@ -51,7 +50,7 @@ module OpenWFE
51
50
  # localization for <sleep/> and <cron/>.
52
51
  #
53
52
  class TimeExpression < FlowExpression
54
- include Schedulable
53
+ include Rufus::Schedulable
55
54
 
56
55
  #
57
56
  # The workitem received at apply time
@@ -93,12 +92,21 @@ module OpenWFE
93
92
 
94
93
  ldebug { "unschedule() @scheduler_job_id is #{@scheduler_job_id}" }
95
94
 
95
+ sleep get_scheduler.precision + 0.001
96
+ #
97
+ # make sure not to unschedule before the actual scheduling
98
+ # got done.
99
+
96
100
  get_scheduler.unschedule(@scheduler_job_id) \
97
101
  if @scheduler_job_id
98
102
  end
99
103
 
100
104
  protected
101
105
 
106
+ #
107
+ # looks up potential scheduler tags in the expression
108
+ # attributes
109
+ #
102
110
  def determine_scheduler_tags
103
111
 
104
112
  st = lookup_attribute :scheduler_tags, @applied_workitem
@@ -130,11 +138,17 @@ module OpenWFE
130
138
  #
131
139
  DEFAULT_FREQUENCY = "10s"
132
140
 
141
+ #
142
+ # Don't go under 300 milliseconds.
143
+ #
144
+ MIN_FREQUENCY = 0.300
145
+
133
146
  #
134
147
  # Classes extending this WaitingExpression have a 'conditions' class
135
148
  # method (like 'attr_accessor').
136
149
  #
137
150
  def self.conditions (*attnames)
151
+
138
152
  attnames = attnames.collect do |n|
139
153
  n.to_s.intern
140
154
  end
@@ -151,8 +165,10 @@ module OpenWFE
151
165
 
152
166
  @frequency = lookup_attribute(
153
167
  :frequency, workitem, :default => DEFAULT_FREQUENCY)
154
- @frequency = OpenWFE::parse_time_string(
168
+ @frequency = Rufus::parse_time_string(
155
169
  @frequency)
170
+ @frequency = MIN_FREQUENCY \
171
+ if @frequency < MIN_FREQUENCY
156
172
 
157
173
  determine_timeout
158
174
  determine_scheduler_tags
@@ -173,15 +189,19 @@ module OpenWFE
173
189
  end
174
190
  end
175
191
 
176
- def cancel ()
192
+ #
193
+ # Cancels this expression (takes care of unscheduling a timeout
194
+ # if there is one).
195
+ #
196
+ def cancel
177
197
 
178
- to_unschedule()
198
+ unschedule_timeout
179
199
  super()
180
200
  end
181
201
 
182
202
  def trigger (params={})
183
203
 
184
- ldebug { "trigger() #{@fei.to_debug_s} params is #{params}" }
204
+ ldebug { "trigger() #{@fei.to_debug_s} params : #{params.inspect}" }
185
205
 
186
206
  if params[:do_timeout!]
187
207
  #
@@ -215,10 +235,10 @@ module OpenWFE
215
235
 
216
236
  def reply_to_parent (workitem)
217
237
 
218
- unschedule()
219
- unschedule_timeout()
238
+ unschedule
239
+ unschedule_timeout
220
240
 
221
- super(workitem)
241
+ super workitem
222
242
  end
223
243
 
224
244
  protected
@@ -255,7 +275,11 @@ module OpenWFE
255
275
  # trigger the first child (the condition child)
256
276
 
257
277
  get_expression_pool.launch_template(
258
- self, @condition_sub_id, @children[0], @applied_workitem)
278
+ self,
279
+ @environment_id,
280
+ @condition_sub_id,
281
+ @children[0],
282
+ @applied_workitem)
259
283
  end
260
284
 
261
285
  #