This repository has been archived by the owner on Nov 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
ConfigManagementFacility.ts
92 lines (80 loc) · 3.02 KB
/
ConfigManagementFacility.ts
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
* This program and the accompanying materials are made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Copyright Contributors to the Zowe Project.
*
*/
import { PerfTiming } from "@zowe/perf-timing";
import { UpdateImpConfig } from "../UpdateImpConfig";
import { Logger } from "../../../logger";
/**
* This class is the main engine for the Config Management Facility. The
* underlying class should be treated as a singleton and should be accessed
* via ConfigManagementFacility.instance.
*/
export class ConfigManagementFacility {
/**
* This is the variable that stores the specific instance of the CMF. Defined
* as static so that it can be accessed from anywhere.
*
* @private
* @type {ConfigManagementFacility}
*/
private static mInstance: ConfigManagementFacility;
/**
* Used for internal imperative logging.
*
* @private
* @type {Logger}
*/
private impLogger: Logger = Logger.getImperativeLogger();
/**
* Gets a single instance of the CMF. On the first call of
* ConfigManagementFacility.instance, a new CMF is initialized and returned.
* Every subsequent call will use the one that was first created.
*
* @returns {ConfigManagementFacility} - The newly initialized CMF object.
*/
public static get instance(): ConfigManagementFacility {
if (this.mInstance == null) {
this.mInstance = new ConfigManagementFacility();
}
return this.mInstance;
}
/**
* Initialize the CMF. Must be called to enable the various commands provided
* by the facility.
*/
public init(): void {
const timingApi = PerfTiming.api;
if (PerfTiming.isEnabled) {
// Marks point START
timingApi.mark("START_CONFIG_INIT");
}
this.impLogger.debug("ConfigManagementFacility.init() - Start");
// Add the config group and related commands.
UpdateImpConfig.addCmdGrp({
name: "config",
type: "group",
summary: "Manage configuration and overrides",
description: "Manage configuration and overrides. To see all set-able options use \"list\" command.",
children: [
// require("./cmd/get/get.definition").getDefinition,
require("./cmd/set/set.definition").setDefinition,
require("./cmd/reset/reset.definition").resetDefinition,
require("./cmd/list/list.definition").listDefinition,
require("./cmd/get/get.definition").getDefinition,
]
});
this.impLogger.debug("ConfigManagementFacility.init() - Success");
if (PerfTiming.isEnabled) {
// Marks point END
timingApi.mark("END_CONFIG_INIT");
timingApi.measure("ConfigManagementFacility.init()", "START_CONFIG_INIT", "END_CONFIG_INIT");
}
}
}