1 /** 2 Copyright 2018 Mark Fisher 3 4 Permission is hereby granted, free of charge, to any person obtaining a copy of 5 this software and associated documentation files (the "Software"), to deal in 6 the Software without restriction, including without limitation the rights to 7 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 of the Software, and to permit persons to whom the Software is furnished to do 9 so, subject to the following conditions: 10 11 The above copyright notice and this permission notice shall be included in all 12 copies or substantial portions of the Software. 13 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 SOFTWARE. 21 **/ 22 module dxx.app.rtmod; 23 24 private import aermicioi.aedi; 25 private import eph.args; 26 27 private import core.runtime; 28 29 private import std.experimental.logger; 30 31 private import dxx.util.injector; 32 private import dxx.util.config; 33 private import dxx.app; 34 35 36 @component 37 abstract class RuntimeModule { 38 static __gshared RuntimeModule MODULE; 39 40 static WorkflowRunner workflowRunner; 41 // static ArgParser argParser; 42 DefaultInjector _injector; 43 44 //static __gshared ExtensionPointManager extensionPointManager; 45 46 abstract void registerAppDependencies(DefaultInjector injector); 47 48 @component 49 public RuntimeModule getRuntimeModule() { 50 return MODULE; 51 } 52 53 @component 54 public Logger getLogger() { 55 return sharedLog; 56 } 57 58 nothrow 59 static DefaultInjector injector() { 60 return MODULE._injector; 61 } 62 @component 63 public ArgParser getArgParser() { 64 // if(argParser is null) { 65 // argParser = new ArgParser; 66 // Parameter param = new Parameter(); 67 // argParser.register(param); 68 // //string args = AppConfig.get(DXXConfig.keys.commandLine); 69 // //args.split(" "); 70 // //Argument[] arguments = resolveInjector!(Argument[])(); 71 // //arguments.each!(a => argParser.register(a)); 72 // 73 //// auto args = Runtime.args; 74 //// argParser.parse(args); 75 // } 76 // return argParser; 77 return new ArgParser; 78 } 79 80 @component 81 public WorkflowRunner getWorkflowRunner() { 82 if(workflowRunner is null) { 83 workflowRunner = new WorkflowRunner; 84 } 85 return workflowRunner; 86 } 87 88 //@component 89 //public ExtensionPointManager getExtensionPointManager() { 90 // if(extensionPointManager is null) { 91 // extensionPointManager = new ExtensionPointManager; 92 // } 93 // return extensionPointManager; 94 //} 95 96 public this(this T)() { 97 if(MODULE is null) { 98 MODULE = this; 99 } 100 _injector = newInjector!T; 101 registerAppDependencies(injector); 102 injector.instantiate(); 103 } 104 }