-
Notifications
You must be signed in to change notification settings - Fork 204
/
Copy pathGlobalInstanceHolder.java
97 lines (91 loc) · 5.48 KB
/
GlobalInstanceHolder.java
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
93
94
95
96
97
/*
* Copyright (c) 2020 SUSE LLC
*
* This software is licensed to you under the GNU General Public License,
* version 2 (GPLv2). There is NO WARRANTY for this software, express or
* implied, including the implied warranties of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
* along with this software; if not, see
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
*
* Red Hat trademarks are not licensed under GPLv2. No permission is
* granted to use or replicate Red Hat trademarks that are incorporated
* in this software or its documentation.
*/
package com.redhat.rhn;
import com.redhat.rhn.common.security.acl.Access;
import com.redhat.rhn.common.security.acl.AclFactory;
import com.redhat.rhn.domain.server.ServerFactory;
import com.redhat.rhn.domain.server.ServerGroupFactory;
import com.redhat.rhn.frontend.taglibs.helpers.RenderUtils;
import com.redhat.rhn.manager.formula.FormulaManager;
import com.redhat.rhn.manager.formula.FormulaMonitoringManager;
import com.redhat.rhn.manager.org.MigrationManager;
import com.redhat.rhn.manager.system.ServerGroupManager;
import com.redhat.rhn.manager.system.SystemManager;
import com.redhat.rhn.manager.system.entitling.SystemEntitlementManager;
import com.redhat.rhn.manager.system.entitling.SystemEntitler;
import com.redhat.rhn.manager.system.entitling.SystemUnentitler;
import com.suse.cloud.CloudPaygManager;
import com.suse.manager.attestation.AttestationManager;
import com.suse.manager.kubernetes.KubernetesManager;
import com.suse.manager.utils.SaltKeyUtils;
import com.suse.manager.utils.SaltUtils;
import com.suse.manager.webui.controllers.bootstrap.RegularMinionBootstrapper;
import com.suse.manager.webui.controllers.bootstrap.SSHMinionBootstrapper;
import com.suse.manager.webui.menu.MenuTree;
import com.suse.manager.webui.services.SaltServerActionService;
import com.suse.manager.webui.services.ThrottlingService;
import com.suse.manager.webui.services.iface.MonitoringManager;
import com.suse.manager.webui.services.iface.SaltApi;
import com.suse.manager.webui.services.iface.SystemQuery;
import com.suse.manager.webui.services.impl.SaltService;
import com.suse.manager.webui.utils.MinionActionUtils;
import com.suse.manager.webui.utils.UserPreferenceUtils;
import com.suse.manager.webui.utils.ViewHelper;
import com.suse.manager.webui.websocket.WebsocketHeartbeatService;
/**
* This class only exists to have a single place for initializing objects
* and share a single consistent instance in multiple parts of tomcat/taskomatic.
* These instances should only be referenced from entry points of the program and
* places that cant receive them otherwise though the constructor (i.e because of reflection)
*/
public class GlobalInstanceHolder {
private GlobalInstanceHolder() {
}
private static final SaltService SALT_SERVICE = new SaltService();
public static final SystemQuery SYSTEM_QUERY = SALT_SERVICE;
public static final SaltApi SALT_API = SALT_SERVICE;
public static final CloudPaygManager PAYG_MANAGER = new CloudPaygManager();
public static final AttestationManager ATTESTATION_MANAGER = new AttestationManager();
public static final ServerGroupManager SERVER_GROUP_MANAGER = new ServerGroupManager(SALT_API);
public static final FormulaManager FORMULA_MANAGER = new FormulaManager(SALT_API);
public static final SaltUtils SALT_UTILS = new SaltUtils(SYSTEM_QUERY, SALT_API);
public static final SaltKeyUtils SALT_KEY_UTILS = new SaltKeyUtils(SALT_API);
public static final SaltServerActionService SALT_SERVER_ACTION_SERVICE = new SaltServerActionService(
SALT_API, SALT_UTILS, SALT_KEY_UTILS);
public static final Access ACCESS = new Access();
public static final AclFactory ACL_FACTORY = new AclFactory(ACCESS);
// Referenced from JSP
public static final MenuTree MENU_TREE = new MenuTree(ACL_FACTORY);
public static final UserPreferenceUtils USER_PREFERENCE_UTILS = new UserPreferenceUtils(ACL_FACTORY);
public static final RenderUtils RENDER_UTILS = new RenderUtils(ACL_FACTORY);
public static final MinionActionUtils MINION_ACTION_UTILS = new MinionActionUtils(SALT_API, SALT_UTILS);
public static final KubernetesManager KUBERNETES_MANAGER = new KubernetesManager(SALT_API);
public static final RegularMinionBootstrapper REGULAR_MINION_BOOTSTRAPPER =
new RegularMinionBootstrapper(SYSTEM_QUERY, SALT_API, PAYG_MANAGER, ATTESTATION_MANAGER);
public static final SSHMinionBootstrapper SSH_MINION_BOOTSTRAPPER =
new SSHMinionBootstrapper(SYSTEM_QUERY, SALT_API, PAYG_MANAGER, ATTESTATION_MANAGER);
public static final MonitoringManager MONITORING_MANAGER = new FormulaMonitoringManager(SALT_API);
public static final SystemEntitlementManager SYSTEM_ENTITLEMENT_MANAGER = new SystemEntitlementManager(
new SystemUnentitler(MONITORING_MANAGER, SERVER_GROUP_MANAGER),
new SystemEntitler(SALT_API, MONITORING_MANAGER,
SERVER_GROUP_MANAGER)
);
public static final SystemManager SYSTEM_MANAGER = new SystemManager(ServerFactory.SINGLETON,
ServerGroupFactory.SINGLETON, SALT_API);
public static final MigrationManager MIGRATION_MANAGER = new MigrationManager(SERVER_GROUP_MANAGER);
public static final WebsocketHeartbeatService WEBSOCKET_SESSION_MANAGER = new WebsocketHeartbeatService();
public static final ViewHelper VIEW_HELPER = ViewHelper.getInstance();
public static final ThrottlingService THROTTLING_SERVICE = new ThrottlingService();
}