35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/cpee/implementation.rb', line 35
def self::implementation(opts)
opts[:instances] ||= File.expand_path(File.join(__dir__,'..','..','server','instances'))
opts[:global_handlerwrappers] ||= File.expand_path(File.join(__dir__,'..','..','server','handlerwrappers'))
opts[:handlerwrappers] ||= ''
opts[:topics] ||= File.expand_path(File.join(__dir__,'..','..','server','resources','topics.xml'))
opts[:properties_init] ||= File.expand_path(File.join(__dir__,'..','..','server','resources','properties.init'))
opts[:properties_schema_active] ||= File.expand_path(File.join(__dir__,'..','..','server','resources','properties.schema.active'))
opts[:properties_schema_finished] ||= File.expand_path(File.join(__dir__,'..','..','server','resources','properties.schema.finished'))
opts[:properties_schema_inactive] ||= File.expand_path(File.join(__dir__,'..','..','server','resources','properties.schema.inactive'))
opts[:transformation_dslx] ||= File.expand_path(File.join(__dir__,'..','..','server','resources','transformation_dslx.xsl'))
opts[:transformation_service] ||= File.expand_path(File.join(__dir__,'..','..','server','resources','transformation.xml'))
opts[:empty_dslx] ||= File.expand_path(File.join(__dir__,'..','..','server','resources','empty_dslx.xml'))
opts[:notifications_init] ||= File.expand_path(File.join(__dir__,'..','..','server','resources','notifications'))
opts[:infinite_loop_stop] ||= 10000
opts[:runtime_cmds] << [
"startclean", "Delete instances before starting.", Proc.new { |status|
Dir.glob(File.expand_path(File.join(opts[:instances],'*'))).each do |d|
FileUtils.rm_r(d) if File.basename(d) =~ /^\d+$/
end
}
]
Proc.new do
Dir[opts[:global_handlerwrappers] + "/*.rb"].each do |h|
require h
end unless opts[:global_handlerwrappers].strip == ''
Dir[opts[:handlerwrappers] + "/*.rb"].each do |h|
require h
end unless opts[:handlerwrappers].strip == ''
controller = {}
Dir[File.join(opts[:instances],'*','properties.xml')].each do |e|
id = ::File::basename(::File::dirname(e))
(controller[id.to_i] = (Controller.new(id,opts)) rescue nil)
end
interface 'properties' do |r|
id = r[:h]['RIDDL_DECLARATION_PATH'].split('/')[1].to_i
use Riddl::Utils::Properties::implementation(controller[id].properties, PropertiesHandler.new(controller[id]), opts[:mode]) if controller[id]
end
interface 'main' do
run CPEE::Instances, controller if get '*'
run CPEE::NewInstance, controller, opts if post 'instance-new'
run CPEE::NewXMLInstance, controller, opts if post 'instance-new-xml'
on resource do |r|
run CPEE::Info, controller if get
run CPEE::DeleteInstance, controller, opts if delete
on resource 'console' do
run CPEE::ConsoleUI, controller if get
run CPEE::Console, controller if get 'cmdin'
end
on resource 'callbacks' do
run CPEE::Callbacks, controller, opts if get
on resource do
run CPEE::ExCallback, controller if get || put || post || delete
end
end
end
end
interface 'notifications' do |r|
id = r[:h]['RIDDL_DECLARATION_PATH'].split('/')[1].to_i
use Riddl::Utils::Notifications::Producer::implementation(controller[id].notifications, NotificationsHandler.new(controller[id]), opts[:mode]) if controller[id]
end
end
end
|