|
1 | 1 | /* |
2 | | - * Copyright (c) 2004, 2023, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
|
50 | 50 | * @see HostListener |
51 | 51 | */ |
52 | 52 | public abstract class MonitoredHost { |
53 | | - private static final Map<HostIdentifier, MonitoredHost> monitoredHosts = |
| 53 | + private static Map<HostIdentifier, MonitoredHost> monitoredHosts = |
54 | 54 | new HashMap<HostIdentifier, MonitoredHost>(); |
55 | 55 |
|
56 | 56 | /* |
@@ -133,6 +133,13 @@ public static MonitoredHost getMonitoredHost(VmIdentifier vmid) |
133 | 133 | return getMonitoredHost(hostId); |
134 | 134 | } |
135 | 135 |
|
| 136 | + |
| 137 | + /* |
| 138 | + * Load the MonitoredHostServices |
| 139 | + */ |
| 140 | + private static ServiceLoader<MonitoredHostService> monitoredHostServiceLoader = |
| 141 | + ServiceLoader.load(MonitoredHostService.class, MonitoredHostService.class.getClassLoader()); |
| 142 | + |
136 | 143 | /** |
137 | 144 | * Factory method to construct a MonitoredHost instance to manage the |
138 | 145 | * connection to the host indicated by {@code hostId}. |
@@ -160,12 +167,9 @@ public static MonitoredHost getMonitoredHost(HostIdentifier hostId) |
160 | 167 |
|
161 | 168 | hostId = resolveHostId(hostId); |
162 | 169 |
|
163 | | - ServiceLoader<MonitoredHostService> services = ServiceLoader.load( |
164 | | - MonitoredHostService.class, MonitoredHostService.class.getClassLoader()); |
165 | | - for (MonitoredHostService mhs : services) { |
| 170 | + for (MonitoredHostService mhs : monitoredHostServiceLoader) { |
166 | 171 | if (mhs.getScheme().equals(hostId.getScheme())) { |
167 | 172 | mh = mhs.getMonitoredHost(hostId); |
168 | | - break; |
169 | 173 | } |
170 | 174 | } |
171 | 175 |
|
|
0 commit comments