Skip to content

Commit b274c57

Browse files
committed
Cleanup places that use explicit wiring of the components
1 parent 32e67f6 commit b274c57

60 files changed

Lines changed: 252 additions & 574 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.apache.cloudstack.engine.cloud.entity.api;
2+
3+
import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
4+
import org.springframework.stereotype.Component;
5+
6+
@Component
7+
public class VMEntityManagerImpl implements VMEntityManager {
8+
9+
@Override
10+
public VMEntityVO loadVirtualMachine(String vmId) {
11+
// TODO Auto-generated method stub
12+
return null;
13+
}
14+
15+
@Override
16+
public void saveVirtualMachine(VMEntityVO vmInstanceVO) {
17+
// TODO Auto-generated method stub
18+
19+
}
20+
21+
}

engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/VirtualMachineEntityImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,18 @@
55
import java.util.List;
66
import java.util.Map;
77

8+
import javax.inject.Inject;
9+
810

911

1012
import org.apache.cloudstack.engine.cloud.entity.api.db.VMEntityVO;
13+
1114
import com.cloud.deploy.DeployDestination;
1215
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
1316

1417
public class VirtualMachineEntityImpl implements VirtualMachineEntity {
1518

16-
private VMEntityManager manager;
19+
@Inject private VMEntityManager manager;
1720

1821
private VMEntityVO vmEntityVO;
1922

engine/orchestration/src/org/apache/cloudstack/engine/cloud/entity/api/db/VMEntityVO.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,4 +557,10 @@ public void setNetworkIds(List<String> networkIds) {
557557
this.networkIds = networkIds;
558558
}
559559

560+
@Override
561+
public long getDiskOfferingId() {
562+
// TODO Auto-generated method stub
563+
return 0;
564+
}
565+
560566
}

engine/orchestration/src/org/apache/cloudstack/platform/orchestration/CloudOrchestrator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.apache.cloudstack.engine.cloud.entity.api.VMEntityManager;
3333
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
3434
import org.apache.cloudstack.engine.service.api.OrchestrationService;
35+
import org.springframework.stereotype.Component;
3536

3637
import com.cloud.deploy.DeploymentPlan;
3738
import com.cloud.exception.InsufficientCapacityException;
@@ -49,7 +50,7 @@
4950
import com.cloud.vm.dao.VMInstanceDao;
5051

5152

52-
53+
@Component
5354
public class CloudOrchestrator implements OrchestrationService {
5455

5556
@Inject

plugins/host-allocators/random/src/com/cloud/agent/manager/allocator/impl/RandomAllocator.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.Map;
2323

2424
import javax.ejb.Local;
25+
import javax.inject.Inject;
2526

2627
import org.apache.log4j.Logger;
2728
import org.springframework.stereotype.Component;
@@ -44,8 +45,8 @@
4445
public class RandomAllocator implements HostAllocator {
4546
private static final Logger s_logger = Logger.getLogger(RandomAllocator.class);
4647
private String _name;
47-
private HostDao _hostDao;
48-
private ResourceManager _resourceMgr;
48+
@Inject private HostDao _hostDao;
49+
@Inject private ResourceManager _resourceMgr;
4950

5051
@Override
5152
public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type,
@@ -119,13 +120,6 @@ public boolean isVirtualMachineUpgradable(VirtualMachine vm, ServiceOffering off
119120

120121
@Override
121122
public boolean configure(String name, Map<String, Object> params) {
122-
ComponentLocator locator = ComponentLocator.getCurrentLocator();
123-
_hostDao = locator.getDao(HostDao.class);
124-
_resourceMgr = locator.getManager(ResourceManager.class);
125-
if (_hostDao == null) {
126-
s_logger.error("Unable to get host dao.");
127-
return false;
128-
}
129123
_name=name;
130124

131125
return true;

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,6 @@ public boolean configure(String name, Map<String, Object> params)
348348

349349
super.configure(name, params);
350350

351-
ComponentLocator locator = ComponentLocator.getCurrentLocator();
352-
ConfigurationDao configDao = locator.getDao(ConfigurationDao.class);
353-
if (configDao == null) {
354-
throw new ConfigurationException(
355-
"Unable to get the configuration dao.");
356-
}
357-
358351
createVmwareToolsIso();
359352

360353
if (s_logger.isInfoEnabled()) {

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
114114
private String _instance;
115115

116116
@Inject AgentManager _agentMgr;
117-
@Inject
118-
protected NetworkManager _netMgr;
117+
@Inject NetworkManager _netMgr;
119118
@Inject HostDao _hostDao;
120119
@Inject ClusterDao _clusterDao;
121120
@Inject ClusterDetailsDao _clusterDetailsDao;
@@ -125,8 +124,8 @@ public class VmwareManagerImpl implements VmwareManager, VmwareStorageMount, Lis
125124
@Inject SecondaryStorageVmManager _ssvmMgr;
126125
@Inject CiscoNexusVSMDeviceDao _nexusDao;
127126
@Inject ClusterVSMMapDao _vsmMapDao;
128-
129-
ConfigurationServer _configServer;
127+
@Inject ConfigurationDao _configDao;
128+
@Inject ConfigurationServer _configServer;
130129

131130
String _mountParent;
132131
StorageLayer _storage;
@@ -174,24 +173,18 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
174173

175174
_name = name;
176175

177-
ComponentLocator locator = ComponentLocator.getCurrentLocator();
178-
ConfigurationDao configDao = locator.getDao(ConfigurationDao.class);
179-
if (configDao == null) {
180-
throw new ConfigurationException("Unable to get the configuration dao.");
181-
}
182-
183-
if(!configDao.isPremium()) {
176+
if(!_configDao.isPremium()) {
184177
s_logger.error("Vmware component can only run under premium distribution");
185178
throw new ConfigurationException("Vmware component can only run under premium distribution");
186179
}
187180

188-
_instance = configDao.getValue(Config.InstanceName.key());
181+
_instance = _configDao.getValue(Config.InstanceName.key());
189182
if (_instance == null) {
190183
_instance = "DEFAULT";
191184
}
192185
s_logger.info("VmwareManagerImpl config - instance.name: " + _instance);
193186

194-
_mountParent = configDao.getValue(Config.MountParent.key());
187+
_mountParent = _configDao.getValue(Config.MountParent.key());
195188
if (_mountParent == null) {
196189
_mountParent = File.separator + "mnt";
197190
}
@@ -220,7 +213,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
220213
}
221214
}
222215

223-
value = configDao.getValue(Config.VmwareUseNexusVSwitch.key());
216+
value = _configDao.getValue(Config.VmwareUseNexusVSwitch.key());
224217
if(value == null) {
225218
_nexusVSwitchActive = false;
226219
}
@@ -229,7 +222,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
229222
_nexusVSwitchActive = Boolean.parseBoolean(value);
230223
}
231224

232-
_privateNetworkVSwitchName = configDao.getValue(Config.VmwarePrivateNetworkVSwitch.key());
225+
_privateNetworkVSwitchName = _configDao.getValue(Config.VmwarePrivateNetworkVSwitch.key());
233226

234227
if (_privateNetworkVSwitchName == null) {
235228
if (_nexusVSwitchActive) {
@@ -239,7 +232,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
239232
}
240233
}
241234

242-
_publicNetworkVSwitchName = configDao.getValue(Config.VmwarePublicNetworkVSwitch.key());
235+
_publicNetworkVSwitchName = _configDao.getValue(Config.VmwarePublicNetworkVSwitch.key());
243236

244237
if (_publicNetworkVSwitchName == null) {
245238
if (_nexusVSwitchActive) {
@@ -249,7 +242,7 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
249242
}
250243
}
251244

252-
_guestNetworkVSwitchName = configDao.getValue(Config.VmwareGuestNetworkVSwitch.key());
245+
_guestNetworkVSwitchName = _configDao.getValue(Config.VmwareGuestNetworkVSwitch.key());
253246

254247
if (_guestNetworkVSwitchName == null) {
255248
if (_nexusVSwitchActive) {
@@ -259,69 +252,66 @@ public boolean configure(String name, Map<String, Object> params) throws Configu
259252
}
260253
}
261254

262-
_serviceConsoleName = configDao.getValue(Config.VmwareServiceConsole.key());
255+
_serviceConsoleName = _configDao.getValue(Config.VmwareServiceConsole.key());
263256
if(_serviceConsoleName == null) {
264257
_serviceConsoleName = "Service Console";
265258
}
266259

267-
_managemetPortGroupName = configDao.getValue(Config.VmwareManagementPortGroup.key());
260+
_managemetPortGroupName = _configDao.getValue(Config.VmwareManagementPortGroup.key());
268261
if(_managemetPortGroupName == null) {
269262
_managemetPortGroupName = "Management Network";
270263
}
271264

272-
_defaultSystemVmNicAdapterType = configDao.getValue(Config.VmwareSystemVmNicDeviceType.key());
265+
_defaultSystemVmNicAdapterType = _configDao.getValue(Config.VmwareSystemVmNicDeviceType.key());
273266
if(_defaultSystemVmNicAdapterType == null)
274267
_defaultSystemVmNicAdapterType = VirtualEthernetCardType.E1000.toString();
275268

276-
_additionalPortRangeStart = NumbersUtil.parseInt(configDao.getValue(Config.VmwareAdditionalVncPortRangeStart.key()), 59000);
269+
_additionalPortRangeStart = NumbersUtil.parseInt(_configDao.getValue(Config.VmwareAdditionalVncPortRangeStart.key()), 59000);
277270
if(_additionalPortRangeStart > 65535) {
278271
s_logger.warn("Invalid port range start port (" + _additionalPortRangeStart + ") for additional VNC port allocation, reset it to default start port 59000");
279272
_additionalPortRangeStart = 59000;
280273
}
281274

282-
_additionalPortRangeSize = NumbersUtil.parseInt(configDao.getValue(Config.VmwareAdditionalVncPortRangeSize.key()), 1000);
275+
_additionalPortRangeSize = NumbersUtil.parseInt(_configDao.getValue(Config.VmwareAdditionalVncPortRangeSize.key()), 1000);
283276
if(_additionalPortRangeSize < 0 || _additionalPortRangeStart + _additionalPortRangeSize > 65535) {
284277
s_logger.warn("Invalid port range size (" + _additionalPortRangeSize + " for range starts at " + _additionalPortRangeStart);
285278
_additionalPortRangeSize = Math.min(1000, 65535 - _additionalPortRangeStart);
286279
}
287280

288-
_routerExtraPublicNics = NumbersUtil.parseInt(configDao.getValue(Config.RouterExtraPublicNics.key()), 2);
281+
_routerExtraPublicNics = NumbersUtil.parseInt(_configDao.getValue(Config.RouterExtraPublicNics.key()), 2);
289282

290-
_maxHostsPerCluster = NumbersUtil.parseInt(configDao.getValue(Config.VmwarePerClusterHostMax.key()), VmwareManager.MAX_HOSTS_PER_CLUSTER);
291-
_cpuOverprovisioningFactor = configDao.getValue(Config.CPUOverprovisioningFactor.key());
283+
_maxHostsPerCluster = NumbersUtil.parseInt(_configDao.getValue(Config.VmwarePerClusterHostMax.key()), VmwareManager.MAX_HOSTS_PER_CLUSTER);
284+
_cpuOverprovisioningFactor = _configDao.getValue(Config.CPUOverprovisioningFactor.key());
292285
if(_cpuOverprovisioningFactor == null || _cpuOverprovisioningFactor.isEmpty())
293286
_cpuOverprovisioningFactor = "1";
294287

295-
_memOverprovisioningFactor = configDao.getValue(Config.MemOverprovisioningFactor.key());
288+
_memOverprovisioningFactor = _configDao.getValue(Config.MemOverprovisioningFactor.key());
296289
if(_memOverprovisioningFactor == null || _memOverprovisioningFactor.isEmpty())
297290
_memOverprovisioningFactor = "1";
298291

299-
_reserveCpu = configDao.getValue(Config.VmwareReserveCpu.key());
292+
_reserveCpu = _configDao.getValue(Config.VmwareReserveCpu.key());
300293
if(_reserveCpu == null || _reserveCpu.isEmpty())
301294
_reserveCpu = "false";
302-
_reserveMem = configDao.getValue(Config.VmwareReserveMem.key());
295+
_reserveMem = _configDao.getValue(Config.VmwareReserveMem.key());
303296
if(_reserveMem == null || _reserveMem.isEmpty())
304297
_reserveMem = "false";
305298

306-
_recycleHungWorker = configDao.getValue(Config.VmwareRecycleHungWorker.key());
299+
_recycleHungWorker = _configDao.getValue(Config.VmwareRecycleHungWorker.key());
307300
if(_recycleHungWorker == null || _recycleHungWorker.isEmpty())
308301
_recycleHungWorker = "false";
309302

310-
_rootDiskController = configDao.getValue(Config.VmwareRootDiskControllerType.key());
303+
_rootDiskController = _configDao.getValue(Config.VmwareRootDiskControllerType.key());
311304
if(_rootDiskController == null || _rootDiskController.isEmpty())
312305
_rootDiskController = DiskControllerType.ide.toString();
313306

314307
s_logger.info("Additional VNC port allocation range is settled at " + _additionalPortRangeStart + " to " + (_additionalPortRangeStart + _additionalPortRangeSize));
315308

316-
value = configDao.getValue("vmware.host.scan.interval");
309+
value = _configDao.getValue("vmware.host.scan.interval");
317310
_hostScanInterval = NumbersUtil.parseLong(value, DEFAULT_HOST_SCAN_INTERVAL);
318311
s_logger.info("VmwareManagerImpl config - vmware.host.scan.interval: " + _hostScanInterval);
319312

320313
((VmwareStorageManagerImpl)_storageMgr).configure(params);
321314

322-
if(_configServer == null)
323-
_configServer = (ConfigurationServer)ComponentLocator.getComponent(ConfigurationServer.Name);
324-
325315
_agentMgr.registerForHostEvents(this, true, true, true);
326316

327317
s_logger.info("VmwareManagerImpl has been successfully configured");

plugins/user-authenticators/ldap/src/com/cloud/server/auth/LDAPUserAuthenticator.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Map;
2121

2222
import javax.ejb.Local;
23+
import javax.inject.Inject;
2324
import javax.naming.AuthenticationException;
2425
import javax.naming.ConfigurationException;
2526
import javax.naming.Context;
@@ -48,8 +49,8 @@
4849
public class LDAPUserAuthenticator extends DefaultUserAuthenticator {
4950
public static final Logger s_logger = Logger.getLogger(LDAPUserAuthenticator.class);
5051

51-
private ConfigurationDao _configDao;
52-
private UserAccountDao _userAccountDao;
52+
@Inject private ConfigurationDao _configDao;
53+
@Inject private UserAccountDao _userAccountDao;
5354

5455
@Override
5556
public boolean authenticate(String username, String password, Long domainId, Map<String, Object[]> requestParameters ) {
@@ -156,9 +157,6 @@ public boolean authenticate(String username, String password, Long domainId, Map
156157
public boolean configure(String name, Map<String, Object> params)
157158
throws ConfigurationException {
158159
super.configure(name, params);
159-
ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
160-
_configDao = locator.getDao(ConfigurationDao.class);
161-
_userAccountDao = locator.getDao(UserAccountDao.class);
162160
return true;
163161
}
164162
}

plugins/user-authenticators/md5/src/com/cloud/server/auth/MD5UserAuthenticator.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.Map;
1919

2020
import javax.ejb.Local;
21+
import javax.inject.Inject;
2122
import javax.naming.ConfigurationException;
2223

2324
import org.apache.log4j.Logger;
@@ -38,7 +39,7 @@
3839
public class MD5UserAuthenticator extends DefaultUserAuthenticator {
3940
public static final Logger s_logger = Logger.getLogger(MD5UserAuthenticator.class);
4041

41-
private UserAccountDao _userAccountDao;
42+
@Inject private UserAccountDao _userAccountDao;
4243

4344
@Override
4445
public boolean authenticate(String username, String password, Long domainId, Map<String, Object[]> requestParameters ) {
@@ -85,8 +86,6 @@ public boolean authenticate(String username, String password, Long domainId, Map
8586
public boolean configure(String name, Map<String, Object> params)
8687
throws ConfigurationException {
8788
super.configure(name, params);
88-
ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
89-
_userAccountDao = locator.getDao(UserAccountDao.class);
9089
return true;
9190
}
9291
}

plugins/user-authenticators/plain-text/src/com/cloud/server/auth/PlainTextUserAuthenticator.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Map;
2222

2323
import javax.ejb.Local;
24+
import javax.inject.Inject;
2425
import javax.naming.ConfigurationException;
2526

2627
import org.apache.log4j.Logger;
@@ -38,7 +39,7 @@
3839
public class PlainTextUserAuthenticator extends DefaultUserAuthenticator {
3940
public static final Logger s_logger = Logger.getLogger(PlainTextUserAuthenticator.class);
4041

41-
private UserAccountDao _userAccountDao;
42+
@Inject private UserAccountDao _userAccountDao;
4243

4344
@Override
4445
public boolean authenticate(String username, String password, Long domainId, Map<String, Object[]> requestParameters ) {
@@ -85,8 +86,6 @@ public boolean authenticate(String username, String password, Long domainId, Map
8586
public boolean configure(String name, Map<String, Object> params)
8687
throws ConfigurationException {
8788
super.configure(name, params);
88-
ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name);
89-
_userAccountDao = locator.getDao(UserAccountDao.class);
9089
return true;
9190
}
9291
}

0 commit comments

Comments
 (0)