mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Switch to setter injection for extensibility
Various classes are using member injection to inject extensible objects. Really those object should come from an AdapterList that is injected in. This patch switches the code to use setter injection that will later allow spring to inject an AdapterList or something similar to allow extensibility.
This commit is contained in:
parent
692535f928
commit
efbfae723e
@ -257,7 +257,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
this._hostAllocators = _hostAllocators;
|
||||
}
|
||||
|
||||
@Inject
|
||||
protected List<StoragePoolAllocator> _storagePoolAllocators;
|
||||
|
||||
@Inject
|
||||
@ -3271,4 +3270,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
VmOpWaitInterval};
|
||||
}
|
||||
|
||||
public List<StoragePoolAllocator> getStoragePoolAllocators() {
|
||||
return _storagePoolAllocators;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setStoragePoolAllocators(List<StoragePoolAllocator> storagePoolAllocators) {
|
||||
this._storagePoolAllocators = storagePoolAllocators;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -99,7 +99,6 @@ public class VMEntityManagerImpl implements VMEntityManager {
|
||||
@Inject
|
||||
protected VirtualMachineManager _itMgr;
|
||||
|
||||
@Inject
|
||||
protected List<DeploymentPlanner> _planners;
|
||||
|
||||
@Inject
|
||||
@ -257,4 +256,13 @@ public class VMEntityManagerImpl implements VMEntityManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<DeploymentPlanner> getPlanners() {
|
||||
return _planners;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setPlanners(List<DeploymentPlanner> planners) {
|
||||
this._planners = planners;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIC
|
||||
private static Map<RoleType, Set<String>> s_roleBasedApisMap =
|
||||
new HashMap<RoleType, Set<String>>();
|
||||
|
||||
@Inject List<PluggableService> _services;
|
||||
List<PluggableService> _services;
|
||||
@Inject AccountService _accountService;
|
||||
|
||||
protected StaticRoleBasedAPIAccessChecker() {
|
||||
@ -95,4 +95,13 @@ public class StaticRoleBasedAPIAccessChecker extends AdapterBase implements APIC
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<PluggableService> getServices() {
|
||||
return _services;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setServices(List<PluggableService> _services) {
|
||||
this._services = _services;
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,8 +169,8 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
|
||||
@Inject
|
||||
private EntityManager _entityMgr;
|
||||
|
||||
@Inject List<PluggableService> _pluggableServices;
|
||||
@Inject List<APIChecker> _apiAccessCheckers;
|
||||
List<PluggableService> _pluggableServices;
|
||||
List<APIChecker> _apiAccessCheckers;
|
||||
|
||||
@Inject
|
||||
protected ApiAsyncJobDispatcher _asyncDispatcher;
|
||||
@ -1096,4 +1096,22 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
|
||||
}
|
||||
return responseText;
|
||||
}
|
||||
|
||||
public List<PluggableService> getPluggableServices() {
|
||||
return _pluggableServices;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setPluggableServices(List<PluggableService> _pluggableServices) {
|
||||
this._pluggableServices = _pluggableServices;
|
||||
}
|
||||
|
||||
public List<APIChecker> getApiAccessCheckers() {
|
||||
return _apiAccessCheckers;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setApiAccessCheckers(List<APIChecker> _apiAccessCheckers) {
|
||||
this._apiAccessCheckers = _apiAccessCheckers;
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,7 +250,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
@Inject
|
||||
AlertManager _alertMgr;
|
||||
// @com.cloud.utils.component.Inject(adapter = SecurityChecker.class)
|
||||
@Inject
|
||||
List<SecurityChecker> _secChecker;
|
||||
|
||||
@Inject
|
||||
@ -4934,5 +4933,14 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<SecurityChecker> getSecChecker() {
|
||||
return _secChecker;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setSecChecker(List<SecurityChecker> secChecker) {
|
||||
this._secChecker = secChecker;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -166,7 +166,6 @@ VirtualMachineGuru, SystemVmLoadScanHandler<Long>, ResourceStateAdapter {
|
||||
|
||||
private int _mgmt_port = 8250;
|
||||
|
||||
@Inject
|
||||
private List<ConsoleProxyAllocator> _consoleProxyAllocators;
|
||||
|
||||
@Inject
|
||||
@ -1702,4 +1701,13 @@ VirtualMachineGuru, SystemVmLoadScanHandler<Long>, ResourceStateAdapter {
|
||||
public void prepareStop(VirtualMachineProfile profile) {
|
||||
}
|
||||
|
||||
public List<ConsoleProxyAllocator> getConsoleProxyAllocators() {
|
||||
return _consoleProxyAllocators;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setConsoleProxyAllocators(List<ConsoleProxyAllocator> consoleProxyAllocators) {
|
||||
this._consoleProxyAllocators = consoleProxyAllocators;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ package com.cloud.hypervisor;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Local;
|
||||
@ -26,6 +27,7 @@ import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.utils.Pair;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -43,8 +45,8 @@ public class HypervisorGuruManagerImpl extends ManagerBase implements Hypervisor
|
||||
|
||||
@Inject HostDao _hostDao;
|
||||
|
||||
@Inject List<HypervisorGuru> _hvGuruList;
|
||||
Map<HypervisorType, HypervisorGuru> _hvGurus = new HashMap<HypervisorType, HypervisorGuru>();
|
||||
List<HypervisorGuru> _hvGuruList;
|
||||
Map<HypervisorType, HypervisorGuru> _hvGurus = new ConcurrentHashMap<HypervisorType, HypervisorGuru>();
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
@ -55,7 +57,19 @@ public class HypervisorGuruManagerImpl extends ManagerBase implements Hypervisor
|
||||
|
||||
@Override
|
||||
public HypervisorGuru getGuru(HypervisorType hypervisorType) {
|
||||
return _hvGurus.get(hypervisorType);
|
||||
HypervisorGuru result = _hvGurus.get(hypervisorType);
|
||||
|
||||
if ( result == null ) {
|
||||
for ( HypervisorGuru guru : _hvGuruList ) {
|
||||
if ( guru.getHypervisorType() == hypervisorType ) {
|
||||
_hvGurus.put(hypervisorType, guru);
|
||||
result = guru;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -68,4 +82,14 @@ public class HypervisorGuruManagerImpl extends ManagerBase implements Hypervisor
|
||||
}
|
||||
return hostId;
|
||||
}
|
||||
|
||||
public List<HypervisorGuru> getHvGuruList() {
|
||||
return _hvGuruList;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setHvGuruList(List<HypervisorGuru> hvGuruList) {
|
||||
this._hvGuruList = hvGuruList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -230,7 +230,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
||||
@Inject
|
||||
UsageEventDao _usageEventDao;
|
||||
|
||||
@Inject List<NetworkGuru> _networkGurus;
|
||||
List<NetworkGuru> _networkGurus;
|
||||
|
||||
@Inject
|
||||
NetworkDomainDao _networkDomainDao;
|
||||
@ -3944,4 +3944,13 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
|
||||
return _networkMgr.listVmNics(vmId, nicId);
|
||||
}
|
||||
|
||||
public List<NetworkGuru> getNetworkGurus() {
|
||||
return _networkGurus;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setNetworkGurus(List<NetworkGuru> networkGurus) {
|
||||
this._networkGurus = networkGurus;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -675,7 +675,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
@Inject
|
||||
private HypervisorCapabilitiesDao _hypervisorCapabilitiesDao;
|
||||
private List<HostAllocator> _hostAllocators;
|
||||
@Inject
|
||||
private List<StoragePoolAllocator> _storagePoolAllocators;
|
||||
@Inject
|
||||
private ResourceTagDao _resourceTagDao;
|
||||
@ -3870,4 +3869,13 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
|
||||
_dpMgr.cleanupVMReservations();
|
||||
}
|
||||
|
||||
public List<StoragePoolAllocator> getStoragePoolAllocators() {
|
||||
return _storagePoolAllocators;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setStoragePoolAllocators(List<StoragePoolAllocator> storagePoolAllocators) {
|
||||
this._storagePoolAllocators = storagePoolAllocators;
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,7 +273,6 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
protected VmDiskStatisticsDao _vmDiskStatsDao;
|
||||
@Inject
|
||||
protected VMSnapshotDao _vmSnapshotDao;
|
||||
@Inject
|
||||
protected List<StoragePoolAllocator> _storagePoolAllocators;
|
||||
@Inject
|
||||
ConfigurationDao _configDao;
|
||||
@ -1693,4 +1692,13 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<StoragePoolAllocator> getStoragePoolAllocators() {
|
||||
return _storagePoolAllocators;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setStoragePoolAllocators(List<StoragePoolAllocator> storagePoolAllocators) {
|
||||
this._storagePoolAllocators = storagePoolAllocators;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -169,7 +169,6 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
||||
|
||||
private int _mgmt_port = 8250;
|
||||
|
||||
@Inject
|
||||
private List<SecondaryStorageVmAllocator> _ssVmAllocators;
|
||||
|
||||
@Inject
|
||||
@ -1374,4 +1373,13 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
||||
public void prepareStop(VirtualMachineProfile profile) {
|
||||
|
||||
}
|
||||
|
||||
public List<SecondaryStorageVmAllocator> getSecondaryStorageVmAllocators() {
|
||||
return _ssVmAllocators;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setSecondaryStorageVmAllocators(List<SecondaryStorageVmAllocator> ssVmAllocators) {
|
||||
this._ssVmAllocators = ssVmAllocators;
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,7 +291,6 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
boolean _disableExtraction = false;
|
||||
ExecutorService _preloadExecutor;
|
||||
|
||||
@Inject
|
||||
protected List<TemplateAdapter> _adapters;
|
||||
|
||||
@Inject
|
||||
@ -1823,4 +1822,13 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
public ConfigKey<?>[] getConfigKeys() {
|
||||
return new ConfigKey<?>[] {AllowPublicUserTemplates};
|
||||
}
|
||||
|
||||
public List<TemplateAdapter> getTemplateAdapters() {
|
||||
return _adapters;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setTemplateAdapters(List<TemplateAdapter> adapters) {
|
||||
this._adapters = adapters;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user