Module: CPEE

Defined in:
lib/cpee/callback.rb,
lib/cpee/controller.rb,
lib/cpee/value_helper.rb,
lib/cpee/instantiation.rb,
lib/cpee/implementation.rb,
lib/cpee/processtransformation/cpee.rb,
lib/cpee/processtransformation/bpmn2.rb,
lib/cpee/processtransformation/target.rb,
lib/cpee/processtransformation/structures.rb

Overview

This file is part of CPEE.

Apache License, Version 2.0

Copyright © 2013 Juergen Mangler

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defined Under Namespace

Modules: Instantiation, ProcessTransformation Classes: AttributesHelper, Callback, Callbacks, Console, ConsoleUI, Controller, DeleteInstance, ExCallback, Info, Instances, NewInstance, ValueHelper

Constant Summary collapse

SERVER =
File.expand_path(File.join(__dir__,'..','cpee.xml'))

Class Method Summary collapse

Class Method Details

.implementation(opts) ⇒ Object



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
# 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'
      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