26
27
28
29
30
31
32
33
34
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
|
# File 'lib/cpee/implementation.rb', line 26
def self::implementation(opts)
opts[:instances] ||= File.expand_path(File.dirname(__FILE__) + '/../../server/instances')
opts[:global_handlerwrappers] ||= File.expand_path(File.dirname(__FILE__) + '/../../server/handlerwrappers')
opts[:handlerwrappers] ||= ''
opts[:topics] ||= File.expand_path(File.dirname(__FILE__) + '/../../server/resources/topics.xml')
opts[:properties_init] ||= File.expand_path(File.dirname(__FILE__) + '/../../server/resources/properties.init')
opts[:properties_schema_active] ||= File.expand_path(File.dirname(__FILE__) + '/../../server/resources/properties.schema.active')
opts[:properties_schema_finished] ||= File.expand_path(File.dirname(__FILE__) + '/../../server/resources/properties.schema.finished')
opts[:properties_schema_inactive] ||= File.expand_path(File.dirname(__FILE__) + '/../../server/resources/properties.schema.inactive')
opts[:transformation_dslx] ||= File.expand_path(File.dirname(__FILE__) + '/../../server/resources/transformation_dslx.xsl')
opts[:transformation_service] ||= File.expand_path(File.dirname(__FILE__) + '/../../server/resources/transformation.xml')
opts[:empty_dslx] ||= File.expand_path(File.dirname(__FILE__) + '/../../server/resources/empty_dslx.xml')
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[opts[:instances] + '/*/properties.xml'].map{|e|::File::basename(::File::dirname(e))}.each do |id|
controller[id.to_i] = Controller.new(id,opts)
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'
on resource do |r|
run CPEE::Info, controller if get
run CPEE::DeleteInstance, controller, opts if delete
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
|