Changeset 2536
- Timestamp:
- 11/27/09 14:45:01 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure/Manager/PluginValidator.cs
r2527 r2536 77 77 /// 1. All assemblies in the plugins directory are loaded into the reflection only context. 78 78 /// 2. The validator checks if all necessary files for each plugin are available. 79 /// 3. The validator builds the tree of plugin descriptions (dependencies) 80 /// 4. The validator checks if all dependencies for each plugin are ok. 81 /// 5. All plugins for which there are no dependencies missing are loaded into the execution context. 82 /// 6. Each loaded plugin (all assemblies) is searched for a types that implement IPlugin 79 /// 3. The validator checks if all declared plugin assemblies can be loaded. 80 /// 4. The validator builds the tree of plugin descriptions (dependencies) 81 /// 5. The validator checks if there are any cycles in the plugin dependency graph and disables plugin with circular dependencies 82 /// 6. The validator checks for each plugin if any dependency is disabled. 83 /// 7. All plugins that are not disabled are loaded into the execution context. 84 /// 8. Each loaded plugin (all assemblies) is searched for a types that implement IPlugin 83 85 /// then one instance of each IPlugin type is activated and the OnLoad hook is called. 84 /// 7. All types implementing IApplication are discovered86 /// 9. All types implementing IApplication are discovered 85 87 /// </summary> 86 88 internal void DiscoverAndCheckPlugins() { … … 91 93 CheckPluginFiles(pluginDescriptions); 92 94 95 // check if all plugin assemblies can be loaded 93 96 CheckPluginAssemblies(pluginDescriptions); 94 97 95 98 // a full list of plugin descriptions is available now we can build the dependency tree 96 99 BuildDependencyTree(pluginDescriptions); 100 101 // check for dependency cycles 102 CheckPluginDependencyCycles(pluginDescriptions); 97 103 98 104 // recursively check if all necessary plugins are available and not disabled … … 100 106 CheckPluginDependencies(pluginDescriptions); 101 107 102 // mark all plugins as enabled that were not disabled in CheckPluginFiles or CheckPluginDependencies 108 // mark all plugins as enabled that were not disabled in CheckPluginFiles, CheckPluginAssemblies, 109 // CheckCircularDependencies, or CheckPluginDependencies 103 110 foreach (var desc in pluginDescriptions) 104 111 if (desc.PluginState != PluginState.Disabled) … … 300 307 } 301 308 309 private void CheckPluginDependencyCycles(IEnumerable<PluginDescription> pluginDescriptions) { 310 foreach (var plugin in pluginDescriptions) { 311 // if the plugin is not disabled anyway check if there are cycles 312 if (plugin.PluginState != PluginState.Disabled && HasCycleInDependencies(plugin, plugin.Dependencies)) { 313 plugin.Disable(); 314 } 315 } 316 } 317 318 private bool HasCycleInDependencies(PluginDescription plugin, IEnumerable<PluginDescription> pluginDependencies) { 319 foreach (var dep in pluginDependencies) { 320 // if one of the dependencies is the original plugin we found a cycle and can return 321 // if the dependency is already disabled we can ignore the cycle detection because we will disable the plugin anyway 322 // if following one of the dependencies recursively leads to a cycle then we also return 323 if (dep == plugin || dep.PluginState == PluginState.Disabled || HasCycleInDependencies(plugin, dep.Dependencies)) return true; 324 } 325 // no cycle found and none of the direct and indirect dependencies is disabled 326 return false; 327 } 328 302 329 private void CheckPluginDependencies(IEnumerable<PluginDescription> pluginDescriptions) { 303 330 foreach (PluginDescription pluginDescription in pluginDescriptions.Where(x => x.PluginState != PluginState.Disabled)) {
Note: See TracChangeset
for help on using the changeset viewer.