-
Notifications
You must be signed in to change notification settings - Fork 4
/
tezt.mjs
77 lines (53 loc) · 1.78 KB
/
tezt.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
/*<FILE_LICENSE>
* Azos (A to Z Application Operating System) Framework
* The A to Z Foundation (a.k.a. Azist) licenses this file to you under the MIT license.
* See the LICENSE file in the project root for more information.
</FILE_LICENSE>*/
//MANUAL TESTING
//$ node tezt.mjs
import * as conf from "azos/conf";
import * as apps from "azos/application";
import * as cmp from "azos/components";
import * as mod from "azos/modules";
import * as log from "azos/log";
log.writeConsole(log.normalizeMsg({type: log.LOG_TYPE.EMERGENCY, text: "My text!"}));
process.exit(0);
//new conf.Configuration("{ bb:");
class IWeather extends mod.Module{
constructor(dir, cfg){ super(dir, cfg); }
getWeather(code){ return null; }
}
class LocalWeather extends IWeather{
constructor(dir, cfg){ super(dir, cfg); }
getWeather(code){ return "Local weather is cloudy"; }
}
class NationWeather extends IWeather{
constructor(dir, cfg){ super(dir, cfg); }
getWeather(code){ return "Nationwide weather is fair; 75F"; }
}
class MainLogic extends mod.Module{
#ref = {
weather_nation: IWeather,
weather_local: IWeather
};
constructor(dir, cfg){
super(dir, cfg);
console.debug(this.#ref);
this.link(this.#ref); //dep injection
console.debug(this.#ref);
}
runLogic(){
return `Local weather is: ${this.#ref.weather_local.getWeather()}, County weather is: ${this.#ref.weather_nation.getWeather()} `;
}
}
const app = apps.application({
modules:[
{name: "local", type: LocalWeather},
{name: "nation", type: NationWeather},
{name: "main", type: MainLogic},
]
});
console.debug(app.moduleLinker.getHandlerInterfaces(new LocalWeather(app, app.config.root)));
process.exit(0);
const main = app.moduleLinker.resolve(MainLogic, "main");
console.info( main.runLogic() );