56 |
# Loads all the plugins based on the load list calculated by the depenency resolution |
# Loads all the plugins based on the load list calculated by the depenency resolution |
57 |
# |
# |
58 |
def load_plugins |
def load_plugins |
59 |
@load_list.each do |plugin| |
num = 0 |
60 |
|
while num < @load_list.size |
61 |
|
plugin = @load_list[num] |
62 |
plugin.instance.load |
plugin.instance.load |
63 |
|
if plugin.instance.state != LOADED |
64 |
|
fail_load_dependencies(plugin) |
65 |
|
fail_start_dependencies(plugin) |
66 |
|
else |
67 |
|
num += 1 |
68 |
|
end |
69 |
end |
end |
70 |
end |
end |
71 |
|
|
73 |
# Starts all the plugins based on the start list calculated by the depenency resolution |
# Starts all the plugins based on the start list calculated by the depenency resolution |
74 |
# |
# |
75 |
def start_plugins |
def start_plugins |
76 |
@start_list.each do |plugin| |
num = 0 |
77 |
|
while num < @start_list.size |
78 |
|
plugin = @start_list[num] |
79 |
plugin.instance.start |
plugin.instance.start |
80 |
|
if plugin.instance.state != RUNNING |
81 |
|
fail_start_dependencies(plugin) |
82 |
|
else |
83 |
|
num += 1 |
84 |
|
end |
85 |
end |
end |
86 |
end |
end |
87 |
|
|
105 |
|
|
106 |
private |
private |
107 |
|
|
108 |
|
def fail_load_dependencies(plugin) |
109 |
|
puts "Failing to load: #{plugin.name}" |
110 |
|
@load_list.delete(plugin) |
111 |
|
plugin.rev_load_graph.each { |other| fail_load_dependencies(other) } |
112 |
|
end |
113 |
|
|
114 |
|
def fail_start_dependencies(plugin) |
115 |
|
puts "Failing to start: #{plugin.name}" |
116 |
|
@start_list.delete(plugin) |
117 |
|
plugin.rev_start_graph.each { |other| fail_start_dependencies(other) } |
118 |
|
end |
119 |
|
|
120 |
def resolve_dependencies |
def resolve_dependencies |
121 |
# graph dependencies |
# graph dependencies |
122 |
@plugins.each_value do |plugin| |
@plugins.each_value do |plugin| |