|
64 | 64 | import com.cloud.user.ResourceLimitService; |
65 | 65 | import com.cloud.utils.IdentityProxy; |
66 | 66 | import com.cloud.utils.Pair; |
| 67 | +import com.cloud.utils.component.ComponentContext; |
67 | 68 | import com.cloud.utils.component.ComponentLocator; |
68 | 69 | import com.cloud.vm.BareMetalVmService; |
69 | 70 | import com.cloud.vm.UserVmService; |
@@ -140,35 +141,46 @@ public enum CommandType { |
140 | 141 | public static Site2SiteVpnService _s2sVpnService; |
141 | 142 |
|
142 | 143 | static void setComponents(ResponseGenerator generator) { |
143 | | - ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name); |
144 | | - _mgr = (ManagementService) ComponentLocator.getComponent(ManagementService.Name); |
145 | | - _accountService = locator.getManager(AccountService.class); |
146 | | - _configService = locator.getManager(ConfigurationService.class); |
147 | | - _userVmService = locator.getManager(UserVmService.class); |
148 | | - _storageService = locator.getManager(StorageService.class); |
149 | | - _resourceService = locator.getManager(ResourceService.class); |
150 | | - _networkService = locator.getManager(NetworkService.class); |
151 | | - _templateService = locator.getManager(TemplateService.class); |
152 | | - _securityGroupService = locator.getManager(SecurityGroupService.class); |
153 | | - _snapshotService = locator.getManager(SnapshotService.class); |
154 | | - _consoleProxyService = locator.getManager(ConsoleProxyService.class); |
155 | | - _routerService = locator.getManager(VpcVirtualNetworkApplianceService.class); |
156 | | - _entityMgr = locator.getManager(EntityManager.class); |
157 | | - _rulesService = locator.getManager(RulesService.class); |
158 | | - _lbService = locator.getManager(LoadBalancingRulesService.class); |
159 | | - _ravService = locator.getManager(RemoteAccessVpnService.class); |
| 144 | + _mgr = (ManagementService) ComponentContext.getCompanent(ManagementService.class); |
| 145 | + _accountService = ComponentContext.getCompanent(AccountService.class); |
| 146 | + _configService = ComponentContext.getCompanent(ConfigurationService.class); |
| 147 | + |
| 148 | + _userVmService = ComponentContext.getCompanent(UserVmService.class); |
| 149 | + |
| 150 | + // TODO, ugly and will change soon |
| 151 | + // |
| 152 | + Map<String, UserVmService> svmServices = ComponentContext.getComponentsOfType(UserVmService.class); |
| 153 | + _userVmService = svmServices.get("BareMetalVmManagerImpl"); |
| 154 | + |
| 155 | + _storageService = ComponentContext.getCompanent(StorageService.class); |
| 156 | + _resourceService = ComponentContext.getCompanent(ResourceService.class); |
| 157 | + _networkService = ComponentContext.getCompanent(NetworkService.class); |
| 158 | + _templateService = ComponentContext.getCompanent(TemplateService.class); |
| 159 | + |
| 160 | + // TODO, will change to looking for primary component |
| 161 | + // ugly binding to a specific implementation |
| 162 | + Map<String, SecurityGroupService> _sgServices = ComponentContext.getComponentsOfType(SecurityGroupService.class); |
| 163 | + _securityGroupService = _sgServices.get("SecurityGroupManagerImpl2"); |
| 164 | + |
| 165 | + _snapshotService = ComponentContext.getCompanent(SnapshotService.class); |
| 166 | + _consoleProxyService = ComponentContext.getCompanent(ConsoleProxyService.class); |
| 167 | + _routerService = ComponentContext.getCompanent(VpcVirtualNetworkApplianceService.class); |
| 168 | + _entityMgr = ComponentContext.getCompanent(EntityManager.class); |
| 169 | + _rulesService = ComponentContext.getCompanent(RulesService.class); |
| 170 | + _lbService = ComponentContext.getCompanent(LoadBalancingRulesService.class); |
| 171 | + _ravService = ComponentContext.getCompanent(RemoteAccessVpnService.class); |
160 | 172 | _responseGenerator = generator; |
161 | | - _bareMetalVmService = locator.getManager(BareMetalVmService.class); |
162 | | - _projectService = locator.getManager(ProjectService.class); |
163 | | - _firewallService = locator.getManager(FirewallService.class); |
164 | | - _domainService = locator.getManager(DomainService.class); |
165 | | - _resourceLimitService = locator.getManager(ResourceLimitService.class); |
166 | | - _identityService = locator.getManager(IdentityService.class); |
167 | | - _storageNetworkService = locator.getManager(StorageNetworkService.class); |
168 | | - _taggedResourceService = locator.getManager(TaggedResourceService.class); |
169 | | - _vpcService = locator.getManager(VpcService.class); |
170 | | - _networkACLService = locator.getManager(NetworkACLService.class); |
171 | | - _s2sVpnService = locator.getManager(Site2SiteVpnService.class); |
| 173 | + _bareMetalVmService = ComponentContext.getCompanent(BareMetalVmService.class); |
| 174 | + _projectService = ComponentContext.getCompanent(ProjectService.class); |
| 175 | + _firewallService = ComponentContext.getCompanent(FirewallService.class); |
| 176 | + _domainService = ComponentContext.getCompanent(DomainService.class); |
| 177 | + _resourceLimitService = ComponentContext.getCompanent(ResourceLimitService.class); |
| 178 | + _identityService = ComponentContext.getCompanent(IdentityService.class); |
| 179 | + _storageNetworkService = ComponentContext.getCompanent(StorageNetworkService.class); |
| 180 | + _taggedResourceService = ComponentContext.getCompanent(TaggedResourceService.class); |
| 181 | + _vpcService = ComponentContext.getCompanent(VpcService.class); |
| 182 | + _networkACLService = ComponentContext.getCompanent(NetworkACLService.class); |
| 183 | + _s2sVpnService = ComponentContext.getCompanent(Site2SiteVpnService.class); |
172 | 184 | } |
173 | 185 |
|
174 | 186 | public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException; |
|
0 commit comments