mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
better componentslocator
This commit is contained in:
parent
d43a8e983c
commit
17afeade00
@ -24,7 +24,7 @@ import com.cloud.utils.SerialVersionUID;
|
||||
* command.
|
||||
*
|
||||
*/
|
||||
public class AgentUnavailableException extends Exception {
|
||||
public class AgentUnavailableException extends ResourceUnavailableException {
|
||||
|
||||
private static final long serialVersionUID = SerialVersionUID.AgentUnavailableException;
|
||||
|
||||
|
||||
@ -33,4 +33,8 @@ public interface NetworkElement extends Adapter {
|
||||
boolean release(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
boolean shutdown(NetworkConfiguration config, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException;
|
||||
|
||||
boolean addRule();
|
||||
|
||||
boolean revokeRule();
|
||||
}
|
||||
|
||||
@ -128,7 +128,7 @@ changeServiceForRouter=com.cloud.api.commands.UpgradeRouterCmd;3
|
||||
listRouters=com.cloud.api.commands.ListRoutersCmd;7
|
||||
|
||||
#### system vm commands
|
||||
startSystemVm=com.cloud.api.commands.StartSystemVMCmd;1
|
||||
startSystemVm=com.cloud.api.commands.StartSystemVmCmd;1
|
||||
rebootSystemVm=com.cloud.api.commands.RebootSystemVmCmd;1
|
||||
stopSystemVm=com.cloud.api.commands.StopSystemVmCmd;1
|
||||
listSystemVms=com.cloud.api.commands.ListSystemVMsCmd;1
|
||||
|
||||
@ -1,76 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.network;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
|
||||
@Local(value=VirtualNetworkAllocator.class)
|
||||
public class BasicVirtualNetworkAllocator implements VirtualNetworkAllocator {
|
||||
DataCenterDao _dcDao;
|
||||
String _name;
|
||||
|
||||
public BasicVirtualNetworkAllocator() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String allocateTag(AccountVO account, HostVO host, VMInstanceVO vm, ServiceOfferingVO so) {
|
||||
return _dcDao.allocateVnet(host.getDataCenterId(), account.getId(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseTag(String tag, HostVO host, AccountVO account, VMInstanceVO vm) {
|
||||
_dcDao.releaseVnet(tag, host.getDataCenterId(), account.getId(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
ComponentLocator locator = ComponentLocator.getCurrentLocator();
|
||||
_dcDao = locator.getDao(DataCenterDao.class);
|
||||
if (_dcDao == null) {
|
||||
throw new ConfigurationException("Unable to get DataCenterDao");
|
||||
}
|
||||
_name = name;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return _name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@ -19,7 +19,6 @@ package com.cloud.network;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -145,18 +144,6 @@ public class HAProxyConfigurator implements LoadBalancerConfigurator {
|
||||
return new String("\t ");
|
||||
}
|
||||
|
||||
public static void main(String [] args) {
|
||||
/* FirewallRulesDao dao = new FirewallRulesDaoImpl();
|
||||
List<FirewallRuleVO> rules = dao.listIPForwarding();
|
||||
|
||||
HAProxyConfigurator hapc = new HAProxyConfigurator();
|
||||
String [] result = hapc.generateConfiguration(rules);
|
||||
for (int i=0; i < result.length; i++) {
|
||||
System.out.println(result[i]);
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[][] generateFwRules(List<FirewallRuleVO> fwRules) {
|
||||
String [][] result = new String [2][];
|
||||
|
||||
@ -1,51 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.network;
|
||||
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
|
||||
public interface VirtualNetworkAllocator extends Adapter {
|
||||
|
||||
/**
|
||||
* Allocate an virtual network tag
|
||||
*
|
||||
* @param account account that this network belongs to.
|
||||
* @param host host being deployed to.
|
||||
* @param dc datacenter being deployed to.
|
||||
* @param vm vm that is being deployed.
|
||||
* @param so service offering for that vm.
|
||||
* @return tag
|
||||
*/
|
||||
String allocateTag(AccountVO account, HostVO host, VMInstanceVO vm, ServiceOfferingVO so);
|
||||
|
||||
|
||||
/**
|
||||
* Release the virtual network tag.
|
||||
*
|
||||
* @param tag tag retrieved in allocateTag
|
||||
* @param host host to release this tag in.
|
||||
* @param account account to release this tag in.
|
||||
* @param vm vm that is releasing this tag.
|
||||
*/
|
||||
void releaseTag(String tag, HostVO host, AccountVO account, VMInstanceVO vm);
|
||||
|
||||
}
|
||||
97
server/src/com/cloud/api/commands/DestroyVm2Cmd.java
Normal file
97
server/src/com/cloud/api/commands/DestroyVm2Cmd.java
Normal file
@ -0,0 +1,97 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.api.commands;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.api.ApiConstants;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.ApiResponseHelper;
|
||||
import com.cloud.api.BaseAsyncCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.ServerApiException;
|
||||
import com.cloud.api.response.UserVmResponse;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
|
||||
@Implementation(description="Destroys a virtual machine. Once destroyed, only the administrator can recover it.")
|
||||
public class DestroyVm2Cmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(DestroyVm2Cmd.class.getName());
|
||||
|
||||
private static final String s_name = "destroyvirtualmachineresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="The ID of the virtual machine")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAccountId() {
|
||||
UserVm vm = ApiDBUtils.findUserVmById(getId());
|
||||
if (vm != null) {
|
||||
return vm.getAccountId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_VM_DESTROY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "destroying vm: " + getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException{
|
||||
UserVm result = _userVmService.destroyVm(this);
|
||||
UserVmResponse response = ApiResponseHelper.createUserVmResponse(result);
|
||||
response.setResponseName("virtualmachine");
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
}
|
||||
368
server/src/com/cloud/configuration/DefaultComponentLibrary.java
Normal file
368
server/src/com/cloud/configuration/DefaultComponentLibrary.java
Normal file
@ -0,0 +1,368 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.configuration;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.agent.manager.AgentManagerImpl;
|
||||
import com.cloud.agent.manager.allocator.HostAllocator;
|
||||
import com.cloud.agent.manager.allocator.PodAllocator;
|
||||
import com.cloud.agent.manager.allocator.impl.RecreateHostAllocator;
|
||||
import com.cloud.agent.manager.allocator.impl.UserConcentratedAllocator;
|
||||
import com.cloud.alert.AlertManagerImpl;
|
||||
import com.cloud.alert.dao.AlertDaoImpl;
|
||||
import com.cloud.async.AsyncJobExecutorContextImpl;
|
||||
import com.cloud.async.AsyncJobManagerImpl;
|
||||
import com.cloud.async.SyncQueueManagerImpl;
|
||||
import com.cloud.async.dao.AsyncJobDaoImpl;
|
||||
import com.cloud.async.dao.SyncQueueDaoImpl;
|
||||
import com.cloud.async.dao.SyncQueueItemDaoImpl;
|
||||
import com.cloud.capacity.dao.CapacityDaoImpl;
|
||||
import com.cloud.certificate.dao.CertificateDaoImpl;
|
||||
import com.cloud.cluster.DummyClusterManagerImpl;
|
||||
import com.cloud.cluster.dao.ManagementServerHostDaoImpl;
|
||||
import com.cloud.configuration.dao.ConfigurationDaoImpl;
|
||||
import com.cloud.configuration.dao.ResourceCountDaoImpl;
|
||||
import com.cloud.configuration.dao.ResourceLimitDaoImpl;
|
||||
import com.cloud.consoleproxy.AgentBasedStandaloneConsoleProxyManager;
|
||||
import com.cloud.consoleproxy.ConsoleProxyAllocator;
|
||||
import com.cloud.consoleproxy.ConsoleProxyBalanceAllocator;
|
||||
import com.cloud.dc.dao.AccountVlanMapDaoImpl;
|
||||
import com.cloud.dc.dao.ClusterDaoImpl;
|
||||
import com.cloud.dc.dao.DataCenterDaoImpl;
|
||||
import com.cloud.dc.dao.DataCenterIpAddressDaoImpl;
|
||||
import com.cloud.dc.dao.HostPodDaoImpl;
|
||||
import com.cloud.dc.dao.PodVlanMapDaoImpl;
|
||||
import com.cloud.dc.dao.VlanDaoImpl;
|
||||
import com.cloud.deploy.SimplePlanner;
|
||||
import com.cloud.domain.dao.DomainDaoImpl;
|
||||
import com.cloud.event.dao.EventDaoImpl;
|
||||
import com.cloud.ha.CheckOnAgentInvestigator;
|
||||
import com.cloud.ha.HighAvailabilityManagerImpl;
|
||||
import com.cloud.ha.InvestigatorImpl;
|
||||
import com.cloud.ha.StorageFence;
|
||||
import com.cloud.ha.XenServerInvestigator;
|
||||
import com.cloud.ha.dao.HighAvailabilityDaoImpl;
|
||||
import com.cloud.host.dao.DetailsDaoImpl;
|
||||
import com.cloud.host.dao.HostDaoImpl;
|
||||
import com.cloud.hypervisor.kvm.discoverer.KvmServerDiscoverer;
|
||||
import com.cloud.hypervisor.xen.discoverer.XcpServerDiscoverer;
|
||||
import com.cloud.maid.StackMaidManagerImpl;
|
||||
import com.cloud.maid.dao.StackMaidDaoImpl;
|
||||
import com.cloud.maint.UpgradeManagerImpl;
|
||||
import com.cloud.maint.dao.AgentUpgradeDaoImpl;
|
||||
import com.cloud.network.ExteralIpAddressAllocator;
|
||||
import com.cloud.network.NetworkManagerImpl;
|
||||
import com.cloud.network.configuration.ControlNetworkGuru;
|
||||
import com.cloud.network.configuration.GuestNetworkGuru;
|
||||
import com.cloud.network.configuration.PodBasedNetworkGuru;
|
||||
import com.cloud.network.configuration.PublicNetworkGuru;
|
||||
import com.cloud.network.dao.FirewallRulesDaoImpl;
|
||||
import com.cloud.network.dao.IPAddressDaoImpl;
|
||||
import com.cloud.network.dao.LoadBalancerDaoImpl;
|
||||
import com.cloud.network.dao.LoadBalancerVMMapDaoImpl;
|
||||
import com.cloud.network.dao.NetworkConfigurationDaoImpl;
|
||||
import com.cloud.network.dao.NetworkRuleConfigDaoImpl;
|
||||
import com.cloud.network.dao.RemoteAccessVpnDaoImpl;
|
||||
import com.cloud.network.dao.VpnUserDaoImpl;
|
||||
import com.cloud.network.router.DomainRouterManagerImpl;
|
||||
import com.cloud.network.security.NetworkGroupManagerImpl;
|
||||
import com.cloud.network.security.dao.IngressRuleDaoImpl;
|
||||
import com.cloud.network.security.dao.NetworkGroupDaoImpl;
|
||||
import com.cloud.network.security.dao.NetworkGroupRulesDaoImpl;
|
||||
import com.cloud.network.security.dao.NetworkGroupVMMapDaoImpl;
|
||||
import com.cloud.network.security.dao.NetworkGroupWorkDaoImpl;
|
||||
import com.cloud.network.security.dao.VmRulesetLogDaoImpl;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDaoImpl;
|
||||
import com.cloud.server.auth.MD5UserAuthenticator;
|
||||
import com.cloud.service.dao.ServiceOfferingDaoImpl;
|
||||
import com.cloud.storage.StorageManagerImpl;
|
||||
import com.cloud.storage.allocator.FirstFitStoragePoolAllocator;
|
||||
import com.cloud.storage.allocator.GarbageCollectingStoragePoolAllocator;
|
||||
import com.cloud.storage.allocator.LocalStoragePoolAllocator;
|
||||
import com.cloud.storage.allocator.StoragePoolAllocator;
|
||||
import com.cloud.storage.dao.DiskOfferingDaoImpl;
|
||||
import com.cloud.storage.dao.DiskTemplateDaoImpl;
|
||||
import com.cloud.storage.dao.GuestOSCategoryDaoImpl;
|
||||
import com.cloud.storage.dao.GuestOSDaoImpl;
|
||||
import com.cloud.storage.dao.LaunchPermissionDaoImpl;
|
||||
import com.cloud.storage.dao.SnapshotDaoImpl;
|
||||
import com.cloud.storage.dao.SnapshotPolicyDaoImpl;
|
||||
import com.cloud.storage.dao.SnapshotScheduleDaoImpl;
|
||||
import com.cloud.storage.dao.StoragePoolDaoImpl;
|
||||
import com.cloud.storage.dao.StoragePoolHostDaoImpl;
|
||||
import com.cloud.storage.dao.UploadDaoImpl;
|
||||
import com.cloud.storage.dao.VMTemplateDaoImpl;
|
||||
import com.cloud.storage.dao.VMTemplateHostDaoImpl;
|
||||
import com.cloud.storage.dao.VMTemplatePoolDaoImpl;
|
||||
import com.cloud.storage.dao.VMTemplateZoneDaoImpl;
|
||||
import com.cloud.storage.dao.VolumeDaoImpl;
|
||||
import com.cloud.storage.download.DownloadMonitorImpl;
|
||||
import com.cloud.storage.preallocatedlun.dao.PreallocatedLunDaoImpl;
|
||||
import com.cloud.storage.secondary.SecondaryStorageDiscoverer;
|
||||
import com.cloud.storage.secondary.SecondaryStorageManagerImpl;
|
||||
import com.cloud.storage.secondary.SecondaryStorageVmDefaultAllocator;
|
||||
import com.cloud.storage.snapshot.SnapshotManagerImpl;
|
||||
import com.cloud.storage.snapshot.SnapshotSchedulerImpl;
|
||||
import com.cloud.storage.upload.UploadMonitorImpl;
|
||||
import com.cloud.template.TemplateManagerImpl;
|
||||
import com.cloud.user.AccountManagerImpl;
|
||||
import com.cloud.user.dao.AccountDaoImpl;
|
||||
import com.cloud.user.dao.UserAccountDaoImpl;
|
||||
import com.cloud.user.dao.UserDaoImpl;
|
||||
import com.cloud.user.dao.UserStatisticsDaoImpl;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
import com.cloud.utils.component.ComponentLibrary;
|
||||
import com.cloud.utils.component.ComponentLocator.ComponentInfo;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.vm.MauriceMoss;
|
||||
import com.cloud.vm.UserVmManagerImpl;
|
||||
import com.cloud.vm.dao.ConsoleProxyDaoImpl;
|
||||
import com.cloud.vm.dao.DomainRouterDaoImpl;
|
||||
import com.cloud.vm.dao.InstanceGroupDaoImpl;
|
||||
import com.cloud.vm.dao.InstanceGroupVMMapDaoImpl;
|
||||
import com.cloud.vm.dao.NicDaoImpl;
|
||||
import com.cloud.vm.dao.SecondaryStorageVmDaoImpl;
|
||||
import com.cloud.vm.dao.UserVmDaoImpl;
|
||||
import com.cloud.vm.dao.VMInstanceDaoImpl;
|
||||
|
||||
public class DefaultComponentLibrary implements ComponentLibrary {
|
||||
|
||||
protected final Map<String, ComponentInfo<GenericDao<?, ? extends Serializable>>> _daos = new LinkedHashMap<String, ComponentInfo<GenericDao<?, ?>>>();
|
||||
|
||||
protected void addDao(String name, Class<? extends GenericDao<?, ? extends Serializable>> clazz) {
|
||||
addDao(name, clazz, null, true);
|
||||
}
|
||||
|
||||
protected void addDao(String name, Class<? extends GenericDao<?, ? extends Serializable>> clazz, List<Pair<String, Object>> params,
|
||||
boolean singleton) {
|
||||
ComponentInfo<GenericDao<?, ? extends Serializable>> ComponentInfo = new ComponentInfo<GenericDao<?, ? extends Serializable>>(name, clazz, params, singleton);
|
||||
for (String key : ComponentInfo.getKeys()) {
|
||||
_daos.put(key, ComponentInfo);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addDaos() {
|
||||
addDao("StackMaidDao", StackMaidDaoImpl.class);
|
||||
addDao("VMTemplateZoneDao", VMTemplateZoneDaoImpl.class);
|
||||
addDao("DomainRouterDao", DomainRouterDaoImpl.class);
|
||||
addDao("HostDao", HostDaoImpl.class);
|
||||
addDao("VMInstanceDao", VMInstanceDaoImpl.class);
|
||||
addDao("UserVmDao", UserVmDaoImpl.class);
|
||||
addDao("ServiceOfferingDao", ServiceOfferingDaoImpl.class);
|
||||
addDao("DiskOfferingDao", DiskOfferingDaoImpl.class);
|
||||
addDao("DataCenterDao", DataCenterDaoImpl.class);
|
||||
addDao("HostPodDao", HostPodDaoImpl.class);
|
||||
addDao("IPAddressDao", IPAddressDaoImpl.class);
|
||||
addDao("VlanDao", VlanDaoImpl.class);
|
||||
addDao("PodVlanMapDao", PodVlanMapDaoImpl.class);
|
||||
addDao("AccountVlanMapDao", AccountVlanMapDaoImpl.class);
|
||||
addDao("VolumeDao", VolumeDaoImpl.class);
|
||||
addDao("EventDao", EventDaoImpl.class);
|
||||
addDao("UserDao", UserDaoImpl.class);
|
||||
addDao("UserStatisticsDao", UserStatisticsDaoImpl.class);
|
||||
addDao("DiskTemplateDao", DiskTemplateDaoImpl.class);
|
||||
addDao("FirewallRulesDao", FirewallRulesDaoImpl.class);
|
||||
addDao("LoadBalancerDao", LoadBalancerDaoImpl.class);
|
||||
addDao("NetworkRuleConfigDao", NetworkRuleConfigDaoImpl.class);
|
||||
addDao("LoadBalancerVMMapDao", LoadBalancerVMMapDaoImpl.class);
|
||||
addDao("DataCenterIpAddressDao", DataCenterIpAddressDaoImpl.class);
|
||||
addDao("NetworkGroupDao", NetworkGroupDaoImpl.class);
|
||||
addDao("IngressRuleDao", IngressRuleDaoImpl.class);
|
||||
addDao("NetworkGroupVMMapDao", NetworkGroupVMMapDaoImpl.class);
|
||||
addDao("NetworkGroupRulesDao", NetworkGroupRulesDaoImpl.class);
|
||||
addDao("NetworkGroupWorkDao", NetworkGroupWorkDaoImpl.class);
|
||||
addDao("VmRulesetLogDao", VmRulesetLogDaoImpl.class);
|
||||
addDao("AlertDao", AlertDaoImpl.class);
|
||||
addDao("CapacityDao", CapacityDaoImpl.class);
|
||||
addDao("DomainDao", DomainDaoImpl.class);
|
||||
addDao("AccountDao", AccountDaoImpl.class);
|
||||
addDao("ResourceLimitDao", ResourceLimitDaoImpl.class);
|
||||
addDao("ResourceCountDao", ResourceCountDaoImpl.class);
|
||||
addDao("UserAccountDao", UserAccountDaoImpl.class);
|
||||
addDao("VMTemplateHostDao", VMTemplateHostDaoImpl.class);
|
||||
addDao("UploadDao", UploadDaoImpl.class);
|
||||
addDao("VMTemplatePoolDao", VMTemplatePoolDaoImpl.class);
|
||||
addDao("LaunchPermissionDao", LaunchPermissionDaoImpl.class);
|
||||
addDao("ConfigurationDao", ConfigurationDaoImpl.class);
|
||||
addDao("VMTemplateDao", VMTemplateDaoImpl.class);
|
||||
addDao("HighAvailabilityDao", HighAvailabilityDaoImpl.class);
|
||||
addDao("ConsoleProxyDao", ConsoleProxyDaoImpl.class);
|
||||
addDao("SecondaryStorageVmDao", SecondaryStorageVmDaoImpl.class);
|
||||
addDao("ManagementServerHostDao", ManagementServerHostDaoImpl.class);
|
||||
addDao("AgentUpgradeDao", AgentUpgradeDaoImpl.class);
|
||||
addDao("SnapshotDao", SnapshotDaoImpl.class);
|
||||
addDao("AsyncJobDao", AsyncJobDaoImpl.class);
|
||||
addDao("SyncQueueDao", SyncQueueDaoImpl.class);
|
||||
addDao("SyncQueueItemDao", SyncQueueItemDaoImpl.class);
|
||||
addDao("GuestOSDao", GuestOSDaoImpl.class);
|
||||
addDao("GuestOSCategoryDao", GuestOSCategoryDaoImpl.class);
|
||||
addDao("StoragePoolDao", StoragePoolDaoImpl.class);
|
||||
addDao("StoragePoolHostDao", StoragePoolHostDaoImpl.class);
|
||||
addDao("DetailsDao", DetailsDaoImpl.class);
|
||||
addDao("SnapshotPolicyDao", SnapshotPolicyDaoImpl.class);
|
||||
addDao("SnapshotScheduleDao", SnapshotScheduleDaoImpl.class);
|
||||
addDao("PreallocatedLunDao", PreallocatedLunDaoImpl.class);
|
||||
addDao("ClusterDao", ClusterDaoImpl.class);
|
||||
addDao("CertificateDao", CertificateDaoImpl.class);
|
||||
addDao("NetworkConfigurationDao", NetworkConfigurationDaoImpl.class);
|
||||
addDao("NetworkOfferingDao", NetworkOfferingDaoImpl.class);
|
||||
addDao("NicDao", NicDaoImpl.class);
|
||||
addDao("InstanceGroupDao", InstanceGroupDaoImpl.class);
|
||||
addDao("InstanceGroupVMMapDao", InstanceGroupVMMapDaoImpl.class);
|
||||
addDao("RemoteAccessVpnDao", RemoteAccessVpnDaoImpl.class);
|
||||
addDao("VpnUserDao", VpnUserDaoImpl.class);
|
||||
}
|
||||
|
||||
Map<String, ComponentInfo<Manager>> _managers = new HashMap<String, ComponentInfo<Manager>>();
|
||||
Map<String, List<ComponentInfo<Adapter>>> _adapters = new HashMap<String, List<ComponentInfo<Adapter>>>();
|
||||
|
||||
@Override
|
||||
public synchronized Map<String, ComponentInfo<GenericDao<?, ?>>> getDaos() {
|
||||
if (_daos.size() == 0) {
|
||||
addDaos();
|
||||
}
|
||||
return _daos;
|
||||
}
|
||||
|
||||
protected void addManager(String name, Class<? extends Manager> clazz, List<Pair<String, Object>> params, boolean singleton) {
|
||||
ComponentInfo<Manager> ComponentInfo = new ComponentInfo<Manager>(name, clazz, params, singleton);
|
||||
for (String key : ComponentInfo.getKeys()) {
|
||||
_managers.put(key, ComponentInfo);
|
||||
}
|
||||
}
|
||||
|
||||
protected void addManager(String name, Class<? extends Manager> clazz) {
|
||||
addManager(name, clazz, null, true);
|
||||
}
|
||||
|
||||
protected void addManagers() {
|
||||
addManager("StackMaidManager", StackMaidManagerImpl.class);
|
||||
addManager("agent manager", AgentManagerImpl.class);
|
||||
addManager("account manager", AccountManagerImpl.class);
|
||||
addManager("configuration manager", ConfigurationManagerImpl.class);
|
||||
addManager("network manager", NetworkManagerImpl.class);
|
||||
addManager("download manager", DownloadMonitorImpl.class);
|
||||
addManager("upload manager", UploadMonitorImpl.class);
|
||||
addManager("console proxy manager", AgentBasedStandaloneConsoleProxyManager.class);
|
||||
addManager("secondary storage vm manager", SecondaryStorageManagerImpl.class);
|
||||
addManager("vm manager", UserVmManagerImpl.class);
|
||||
addManager("upgrade manager", UpgradeManagerImpl.class);
|
||||
addManager("StorageManager", StorageManagerImpl.class);
|
||||
addManager("Cluster Manager", DummyClusterManagerImpl.class);
|
||||
addManager("SyncQueueManager", SyncQueueManagerImpl.class);
|
||||
addManager("AsyncJobManager", AsyncJobManagerImpl.class);
|
||||
addManager("AsyncJobExecutorContext", AsyncJobExecutorContextImpl.class);
|
||||
addManager("HA Manager", HighAvailabilityManagerImpl.class);
|
||||
addManager("Alert Manager", AlertManagerImpl.class);
|
||||
addManager("Template Manager", TemplateManagerImpl.class);
|
||||
addManager("Snapshot Manager", SnapshotManagerImpl.class);
|
||||
addManager("SnapshotScheduler", SnapshotSchedulerImpl.class);
|
||||
addManager("NetworkGroupManager", NetworkGroupManagerImpl.class);
|
||||
addManager("VmManager", MauriceMoss.class);
|
||||
addManager("DomainRouterManager", DomainRouterManagerImpl.class);
|
||||
}
|
||||
|
||||
protected <T> void addAdapterChain(Class<T> interphace, List<Pair<String, Class<? extends T>>> adapters) {
|
||||
ArrayList<ComponentInfo<Adapter>> lst = new ArrayList<ComponentInfo<Adapter>>(adapters.size());
|
||||
for (Pair<String, Class<? extends T>> adapter : adapters) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<? extends Adapter> clazz = (Class<? extends Adapter>)adapter.second();
|
||||
lst.add(new ComponentInfo<Adapter>(adapter.first(), clazz));
|
||||
}
|
||||
_adapters.put(interphace.getName(), lst);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Map<String, ComponentInfo<Manager>> getManagers() {
|
||||
if (_managers.size() == 0) {
|
||||
addManagers();
|
||||
}
|
||||
return _managers;
|
||||
}
|
||||
|
||||
public void addAllAdapters() {
|
||||
|
||||
List<Pair<String, Class<? extends HostAllocator>>> hostAllocators = new ArrayList<Pair<String, Class<? extends HostAllocator>>>();
|
||||
hostAllocators.add(new Pair<String, Class<? extends HostAllocator>>("FirstFitRouting", RecreateHostAllocator.class));
|
||||
//addAdapter("FirstFit", FirstFitAllocator.class);
|
||||
addAdapterChain(HostAllocator.class, hostAllocators);
|
||||
|
||||
|
||||
List<Pair<String, Class<? extends StoragePoolAllocator>>> poolAllocators = new ArrayList<Pair<String, Class<? extends StoragePoolAllocator>>>();
|
||||
poolAllocators.add(new Pair<String, Class<? extends StoragePoolAllocator>>("LocalStorage", LocalStoragePoolAllocator.class));
|
||||
poolAllocators.add(new Pair<String, Class<? extends StoragePoolAllocator>>("Storage", FirstFitStoragePoolAllocator.class));
|
||||
poolAllocators.add(new Pair<String, Class<? extends StoragePoolAllocator>>("GarbageCollecting", GarbageCollectingStoragePoolAllocator.class));
|
||||
addAdapterChain(StoragePoolAllocator.class, poolAllocators);
|
||||
|
||||
List<Pair<String, Class<? extends PodAllocator>>> podAllocators = new ArrayList<Pair<String, Class<? extends PodAllocator>>>();
|
||||
podAllocators.add(new Pair<String, Class<? extends PodAllocator>>("User First", UserConcentratedAllocator.class));
|
||||
addAdapterChain(PodAllocator.class, podAllocators);
|
||||
|
||||
List<Pair<String, Class<? extends ConsoleProxyAllocator>>> proxyAllocators = new ArrayList<Pair<String, Class<? extends ConsoleProxyAllocator>>>();
|
||||
proxyAllocators.add(new Pair<String, Class<? extends ConsoleProxyAllocator>>("Balance", ConsoleProxyBalanceAllocator.class));
|
||||
addAdapterChain(ConsoleProxyAllocator.class, proxyAllocators);
|
||||
|
||||
// NetworkGuru
|
||||
addAdapterChain("GuestNetworkGuru", GuestNetworkGuru.class);
|
||||
addAdapterChain("PublicNetworkGuru", PublicNetworkGuru.class);
|
||||
addAdapterChain("PodBasedNetworkGuru", PodBasedNetworkGuru.class);
|
||||
addAdapterChain("ControlNetworkGuru", ControlNetworkGuru.class);
|
||||
|
||||
// Secondary Storage Vm Allocator
|
||||
addAdapterChain("Balance", SecondaryStorageVmDefaultAllocator.class);
|
||||
|
||||
// Ip Address Allocator
|
||||
addAdapterChain("Basic", ExteralIpAddressAllocator.class);
|
||||
|
||||
|
||||
// User Authenticator
|
||||
addAdapterChain("MD5", MD5UserAuthenticator.class);
|
||||
|
||||
// HA Investigator
|
||||
addAdapterChain("SimpleInvestigator", CheckOnAgentInvestigator.class);
|
||||
addAdapterChain("XenServerInvestigator", XenServerInvestigator.class);
|
||||
addAdapterChain("PingInvestigator", InvestigatorImpl.class);
|
||||
|
||||
// HA Fence Builder
|
||||
addAdapterChain("StorageFenceBuilder", StorageFence.class);
|
||||
|
||||
// Discoverer
|
||||
addAdapterChain("XCP Agent", XcpServerDiscoverer.class);
|
||||
addAdapterChain("SecondaryStorage", SecondaryStorageDiscoverer.class);
|
||||
addAdapterChain("KVM Agent", KvmServerDiscoverer.class);
|
||||
|
||||
// Deployment Planner
|
||||
addAdapterChain("Simple", SimplePlanner.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Map<String, List<ComponentInfo<Adapter>>> getAdapters() {
|
||||
if (_adapters.size() == 0) {
|
||||
addAdapters();
|
||||
}
|
||||
return _adapters;
|
||||
}
|
||||
}
|
||||
@ -531,7 +531,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
||||
@Override
|
||||
public ConsoleProxyVO startProxy(long proxyVmId, long startEventId) {
|
||||
try {
|
||||
return start(proxyVmId, startEventId);
|
||||
return start2(proxyVmId, startEventId);
|
||||
} catch (StorageUnavailableException e) {
|
||||
s_logger.warn("Exception while trying to start console proxy", e);
|
||||
return null;
|
||||
@ -881,7 +881,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
|
||||
|
||||
Map<String, Object> context = createProxyInstance(dataCenterId);
|
||||
Map<String, Object> context = createProxyInstance2(dataCenterId);
|
||||
|
||||
long proxyVmId = (Long) context.get("proxyVmId");
|
||||
if (proxyVmId == 0) {
|
||||
@ -921,7 +921,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
||||
if (s_logger.isDebugEnabled())
|
||||
s_logger.debug("Assign console proxy from a newly started instance for request from data center : " + dataCenterId);
|
||||
|
||||
Map<String, Object> context = createProxyInstance(dataCenterId);
|
||||
Map<String, Object> context = createProxyInstance2(dataCenterId);
|
||||
|
||||
long proxyVmId = (Long) context.get("proxyVmId");
|
||||
if (proxyVmId == 0) {
|
||||
@ -1468,7 +1468,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
|
||||
try {
|
||||
if (proxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
|
||||
try {
|
||||
readyProxy = start(readyProxy.getId(), 0);
|
||||
readyProxy = start2(readyProxy.getId(), 0);
|
||||
} finally {
|
||||
proxyLock.unlock();
|
||||
}
|
||||
|
||||
@ -114,6 +114,16 @@ public class DomainRouterElement extends AdapterBase implements NetworkElement {
|
||||
return _routerMgr.stopRouter(router.getId(), 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addRule() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeRule() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected DomainRouterElement() {
|
||||
super();
|
||||
}
|
||||
|
||||
@ -205,10 +205,41 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
|
||||
return allocate(vm, template, serviceOffering, new Pair<DiskOfferingVO, Long>(serviceOffering, null), null, networks, null, plan, owner);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
// TODO Auto-generated method stub
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends VMInstanceVO> VirtualMachineGuru<T> getVmGuru(T vm) {
|
||||
return (VirtualMachineGuru<T>)_vmGurus.get(vm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> boolean destroy(T vm, User caller, Account account) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException {
|
||||
if (vm == null || vm.getState() == State.Destroyed || vm.getState() == State.Expunging || vm.getRemoved() != null) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Unable to find vm or vm is destroyed: " + vm);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Destroying vm " + vm);
|
||||
}
|
||||
|
||||
if (!stop(vm, caller, account)) {
|
||||
s_logger.error("Unable to stop vm so we can't destroy it: " + vm);
|
||||
return false;
|
||||
}
|
||||
|
||||
VirtualMachineGuru<T> guru = getVmGuru(vm);
|
||||
vm = guru.findById(vm.getId());
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Destroying vm " + vm);
|
||||
}
|
||||
if (!_vmDao.updateIf(vm, VirtualMachine.Event.DestroyRequested, vm.getHostId())) {
|
||||
s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vm.toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -71,6 +71,7 @@ import com.cloud.api.commands.CreateVMGroupCmd;
|
||||
import com.cloud.api.commands.DeleteVMGroupCmd;
|
||||
import com.cloud.api.commands.DeployVm2Cmd;
|
||||
import com.cloud.api.commands.DestroyVMCmd;
|
||||
import com.cloud.api.commands.DestroyVm2Cmd;
|
||||
import com.cloud.api.commands.DetachVolumeCmd;
|
||||
import com.cloud.api.commands.RebootVMCmd;
|
||||
import com.cloud.api.commands.RecoverVMCmd;
|
||||
@ -3880,4 +3881,37 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
|
||||
return _itMgr.start(vm, null, user, account);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserVm destroyVm(DestroyVm2Cmd cmd) throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
Account account = UserContext.current().getAccount();
|
||||
Long userId = UserContext.current().getUserId();
|
||||
Long vmId = cmd.getId();
|
||||
|
||||
//Verify input parameters
|
||||
UserVmVO vm = _vmDao.findById(vmId.longValue());
|
||||
if (vm == null) {
|
||||
throw new ServerApiException(BaseCmd.VM_INVALID_PARAM_ERROR, "unable to find a virtual machine with id " + vmId);
|
||||
}
|
||||
|
||||
userId = accountAndUserValidation(vmId, account, userId, vm);
|
||||
User caller = _userDao.findById(userId);
|
||||
|
||||
EventUtils.saveScheduledEvent(userId, vm.getAccountId(), EventTypes.EVENT_VM_DESTROY, "Destroying Vm with Id: "+vmId);
|
||||
|
||||
boolean status;
|
||||
try {
|
||||
status = _itMgr.destroy(vm, caller, account);
|
||||
} catch (OperationTimedoutException e) {
|
||||
throw new ResourceUnavailableException("Resource not available to complete the command", e);
|
||||
}
|
||||
|
||||
if (status) {
|
||||
EventUtils.saveEvent(userId, vm.getAccountId(), EventTypes.EVENT_VM_DESTROY, "Successfully destroyed vm with id:"+vmId);
|
||||
return _vmDao.findById(vmId);
|
||||
} else {
|
||||
EventUtils.saveEvent(userId, vm.getAccountId(), EventTypes.EVENT_VM_DESTROY, "Failed to destroy vm with id:"+vmId);
|
||||
throw new CloudRuntimeException("Failed to destroy vm with id " + vmId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ import com.cloud.api.commands.CreateVMGroupCmd;
|
||||
import com.cloud.api.commands.DeleteVMGroupCmd;
|
||||
import com.cloud.api.commands.DeployVm2Cmd;
|
||||
import com.cloud.api.commands.DestroyVMCmd;
|
||||
import com.cloud.api.commands.DestroyVm2Cmd;
|
||||
import com.cloud.api.commands.DetachVolumeCmd;
|
||||
import com.cloud.api.commands.RebootVMCmd;
|
||||
import com.cloud.api.commands.RecoverVMCmd;
|
||||
@ -56,6 +57,15 @@ public interface UserVmService {
|
||||
*/
|
||||
UserVm destroyVm(DestroyVMCmd cmd);
|
||||
|
||||
/**
|
||||
* Destroys one virtual machine
|
||||
* @param userId the id of the user performing the action
|
||||
* @param vmId the id of the virtual machine.
|
||||
* @throws ConcurrentOperationException
|
||||
* @throws ResourceUnavailableException
|
||||
*/
|
||||
UserVm destroyVm(DestroyVm2Cmd cmd) throws ResourceUnavailableException, ConcurrentOperationException;
|
||||
|
||||
/**
|
||||
* Resets the password of a virtual machine.
|
||||
* @param cmd - the command specifying vmId, password
|
||||
|
||||
@ -71,7 +71,8 @@ public interface VmManager extends Manager {
|
||||
|
||||
<T extends VMInstanceVO> boolean stop(T vm, User caller, Account account) throws AgentUnavailableException, ConcurrentOperationException, OperationTimedoutException;
|
||||
|
||||
void destroy();
|
||||
<T extends VMInstanceVO> boolean destroy(T vm, User caller, Account account) throws ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException;
|
||||
;
|
||||
|
||||
<T extends VMInstanceVO> void registerGuru(VirtualMachine.Type type, VirtualMachineGuru<T> guru);
|
||||
|
||||
|
||||
30
utils/src/com/cloud/utils/component/ComponentLibrary.java
Normal file
30
utils/src/com/cloud/utils/component/ComponentLibrary.java
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
||||
*
|
||||
* This software is licensed under the GNU General Public License v3 or later.
|
||||
*
|
||||
* It is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.cloud.utils.component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.utils.component.ComponentLocator.ComponentInfo;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public interface ComponentLibrary {
|
||||
Map<String, ComponentInfo<GenericDao<?,?>>> getDaos();
|
||||
Map<String, ComponentInfo<Manager>> getManagers();
|
||||
Map<String, List<ComponentInfo<Adapter>>> getAdapters();
|
||||
}
|
||||
@ -19,6 +19,7 @@ package com.cloud.utils.component;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
@ -55,6 +56,7 @@ import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.PropertiesUtil;
|
||||
import com.cloud.utils.db.DatabaseCallback;
|
||||
import com.cloud.utils.db.DatabaseCallbackFilter;
|
||||
@ -74,22 +76,19 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
protected static final Logger s_logger = Logger.getLogger(ComponentLocator.class);
|
||||
|
||||
protected static HashMap<String, Object> s_singletons = new HashMap<String, Object>(111);
|
||||
|
||||
protected HashMap<String, Adapters<? extends Adapter>> _adapterMap;
|
||||
protected HashMap<String, Info<Manager>> _managerMap;
|
||||
protected LinkedHashMap<String, Info<GenericDao<?, ?>>> _daoMap;
|
||||
protected static HashMap<String, Object> _componentMap = new HashMap<String, Object>();
|
||||
protected static HashMap<String, String> _implementationClassMap = new HashMap<String, String>();
|
||||
protected ComponentLocator _parentLocator;
|
||||
protected String _serverName;
|
||||
private static boolean s_doOnce = false;
|
||||
|
||||
protected static final Callback[] s_callbacks = new Callback[] { NoOp.INSTANCE, new DatabaseCallback() };
|
||||
protected static final CallbackFilter s_callbackFilter = new DatabaseCallbackFilter();
|
||||
|
||||
protected static final HashMap<Class<?>, InjectInfo> s_factories = new HashMap<Class<?>, InjectInfo>();
|
||||
|
||||
protected static HashMap<String, ComponentLocator> s_locatorMap = new HashMap<String, ComponentLocator>();
|
||||
protected static HashMap<String, Object> _componentMap = new HashMap<String, Object>();
|
||||
protected static HashMap<String, String> _implementationClassMap = new HashMap<String, String>();
|
||||
|
||||
protected HashMap<String, Adapters<? extends Adapter>> _adapterMap;
|
||||
protected HashMap<String, ComponentInfo<Manager>> _managerMap;
|
||||
protected LinkedHashMap<String, ComponentInfo<GenericDao<?, ?>>> _daoMap;
|
||||
protected ComponentLocator _parentLocator;
|
||||
protected String _serverName;
|
||||
|
||||
public ComponentLocator(String server) {
|
||||
_parentLocator = null;
|
||||
@ -114,9 +113,9 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<Info<Manager>> itManagers = _managerMap.values().iterator();
|
||||
Iterator<ComponentInfo<Manager>> itManagers = _managerMap.values().iterator();
|
||||
while (itManagers.hasNext()) {
|
||||
Info<Manager> manager = itManagers.next();
|
||||
ComponentInfo<Manager> manager = itManagers.next();
|
||||
itManagers.remove();
|
||||
manager.instance.stop();
|
||||
}
|
||||
@ -130,9 +129,9 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
if (file == null) {
|
||||
s_logger.warn("Unable to find the config file automatically. Now checking properties files.");
|
||||
_parentLocator = null;
|
||||
_managerMap = new HashMap<String, Info<Manager>>();
|
||||
_managerMap = new HashMap<String, ComponentInfo<Manager>>();
|
||||
_adapterMap = new HashMap<String, Adapters<? extends Adapter>>();
|
||||
_daoMap = new LinkedHashMap<String, Info<GenericDao<?, ?>>>();
|
||||
_daoMap = new LinkedHashMap<String, ComponentInfo<GenericDao<?, ?>>>();
|
||||
_parentLocator = null;
|
||||
return;
|
||||
}
|
||||
@ -144,8 +143,19 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
_parentLocator = getLocatorInternal(handler.parent, false, filename, log4jFile);
|
||||
}
|
||||
|
||||
_managerMap = handler.managers;
|
||||
_daoMap = handler.daos;
|
||||
_daoMap = new LinkedHashMap<String, ComponentInfo<GenericDao<?, ? extends Serializable>>>();
|
||||
_managerMap = new LinkedHashMap<String, ComponentInfo<Manager>>();
|
||||
_adapterMap = new HashMap<String, Adapters<? extends Adapter>>();
|
||||
if (handler.library != null) {
|
||||
Class<?> clazz = Class.forName(handler.library);
|
||||
ComponentLibrary library = (ComponentLibrary)clazz.newInstance();
|
||||
_managerMap.putAll(library.getManagers());
|
||||
_daoMap.putAll(library.getDaos());
|
||||
createAdaptersMap(library.getAdapters());
|
||||
}
|
||||
|
||||
_managerMap.putAll(handler.managers);
|
||||
_daoMap.putAll(handler.daos);
|
||||
|
||||
startDaos(); // daos should not be using managers and adapters.
|
||||
createAdaptersMap(handler.adapters);
|
||||
@ -178,10 +188,10 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
* here.
|
||||
*/
|
||||
protected void startDaos() {
|
||||
Set<Map.Entry<String, Info<GenericDao<?, ?>>>> entries = _daoMap.entrySet();
|
||||
Set<Map.Entry<String, ComponentInfo<GenericDao<?, ? extends Serializable>>>> entries = _daoMap.entrySet();
|
||||
|
||||
for (Map.Entry<String, Info<GenericDao<?, ?>>> entry : entries) {
|
||||
Info<GenericDao<?, ?>> info = entry.getValue();
|
||||
for (Map.Entry<String, ComponentInfo<GenericDao<?, ?>>> entry : entries) {
|
||||
ComponentInfo<GenericDao<?, ?>> info = entry.getValue();
|
||||
s_logger.info("Starting DAO: " + info.name);
|
||||
try {
|
||||
info.instance = (GenericDao<?, ?>)createInstance(info.clazz, true, info.singleton);
|
||||
@ -272,8 +282,8 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
}
|
||||
|
||||
|
||||
protected Info<GenericDao<?, ?>> getDao(String name) {
|
||||
Info<GenericDao<?, ?>> info = _daoMap.get(name);
|
||||
protected ComponentInfo<GenericDao<?, ?>> getDao(String name) {
|
||||
ComponentInfo<GenericDao<?, ?>> info = _daoMap.get(name);
|
||||
if (info != null) {
|
||||
return info;
|
||||
}
|
||||
@ -326,15 +336,15 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
return null;
|
||||
}
|
||||
|
||||
public <T> T getDao(Class<T> clazz) {
|
||||
Info<GenericDao<?, ?>> info = getDao(clazz.getName());
|
||||
public <T extends GenericDao<?, ?>> T getDao(Class<T> clazz) {
|
||||
ComponentInfo<GenericDao<?, ?>> info = getDao(clazz.getName());
|
||||
return info != null ? (T)info.instance : null;
|
||||
}
|
||||
|
||||
protected void instantiateManagers() {
|
||||
Set<Map.Entry<String, Info<Manager>>> entries = _managerMap.entrySet();
|
||||
for (Map.Entry<String, Info<Manager>> entry : entries) {
|
||||
Info<Manager> info = entry.getValue();
|
||||
Set<Map.Entry<String, ComponentInfo<Manager>>> entries = _managerMap.entrySet();
|
||||
for (Map.Entry<String, ComponentInfo<Manager>> entry : entries) {
|
||||
ComponentInfo<Manager> info = entry.getValue();
|
||||
if (info.instance == null) {
|
||||
s_logger.info("Instantiating Manager: " + info.name);
|
||||
info.instance = (Manager)createInstance(info.clazz, false, info.singleton);
|
||||
@ -343,14 +353,14 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
}
|
||||
|
||||
protected void configureManagers() {
|
||||
Set<Map.Entry<String, Info<Manager>>> entries = _managerMap.entrySet();
|
||||
for (Map.Entry<String, Info<Manager>> entry : entries) {
|
||||
Info<Manager> info = entry.getValue();
|
||||
Set<Map.Entry<String, ComponentInfo<Manager>>> entries = _managerMap.entrySet();
|
||||
for (Map.Entry<String, ComponentInfo<Manager>> entry : entries) {
|
||||
ComponentInfo<Manager> info = entry.getValue();
|
||||
s_logger.info("Injecting Manager: " + info.name);
|
||||
inject(info.clazz, info.instance);
|
||||
}
|
||||
for (Map.Entry<String, Info<Manager>> entry : entries) {
|
||||
Info<Manager> info = entry.getValue();
|
||||
for (Map.Entry<String, ComponentInfo<Manager>> entry : entries) {
|
||||
ComponentInfo<Manager> info = entry.getValue();
|
||||
s_logger.info("Configuring Manager: " + info.name);
|
||||
try {
|
||||
info.instance.configure(info.name, info.params);
|
||||
@ -376,7 +386,7 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
if (Manager.class.isAssignableFrom(fc)) {
|
||||
instance = locator.getManager(fc);
|
||||
} else if (GenericDao.class.isAssignableFrom(fc)) {
|
||||
instance = locator.getDao(fc);
|
||||
instance = locator.getDao((Class<? extends GenericDao<?, ?>>)fc);
|
||||
} else if (Adapters.class.isAssignableFrom(fc)) {
|
||||
instance = locator.getAdapters(inject.adapter());
|
||||
} else {
|
||||
@ -401,9 +411,9 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
}
|
||||
|
||||
protected void startManagers() {
|
||||
Set<Map.Entry<String, Info<Manager>>> entries = _managerMap.entrySet();
|
||||
for (Map.Entry<String, Info<Manager>> entry : entries) {
|
||||
Info<Manager> info = entry.getValue();
|
||||
Set<Map.Entry<String, ComponentInfo<Manager>>> entries = _managerMap.entrySet();
|
||||
for (Map.Entry<String, ComponentInfo<Manager>> entry : entries) {
|
||||
ComponentInfo<Manager> info = entry.getValue();
|
||||
s_logger.info("Starting Manager: " + info.name);
|
||||
if (!info.instance.start()) {
|
||||
throw new CloudRuntimeException("Incorrect Configuration: " + info.name);
|
||||
@ -430,8 +440,8 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
s_logger.info("Registered MBean: " + mbean.getName());
|
||||
}
|
||||
|
||||
protected Info<Manager> getManager(String name) {
|
||||
Info<Manager> mgr = _managerMap.get(name);
|
||||
protected ComponentInfo<Manager> getManager(String name) {
|
||||
ComponentInfo<Manager> mgr = _managerMap.get(name);
|
||||
if (mgr != null) {
|
||||
return mgr;
|
||||
}
|
||||
@ -449,7 +459,7 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
}
|
||||
|
||||
public <T> T getManager(Class<T> clazz) {
|
||||
Info<Manager> info = getManager(clazz.getName());
|
||||
ComponentInfo<Manager> info = getManager(clazz.getName());
|
||||
if (info == null) {
|
||||
return null;
|
||||
}
|
||||
@ -459,12 +469,12 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
return (T)info.instance;
|
||||
}
|
||||
|
||||
protected void instantiateAdapters(Map<String, List<Info<Adapter>>> map) {
|
||||
Set<Map.Entry<String, List<Info<Adapter>>>> entries = map.entrySet();
|
||||
for (Map.Entry<String, List<Info<Adapter>>> entry : entries) {
|
||||
protected void instantiateAdapters(Map<String, List<ComponentInfo<Adapter>>> map) {
|
||||
Set<Map.Entry<String, List<ComponentInfo<Adapter>>>> entries = map.entrySet();
|
||||
for (Map.Entry<String, List<ComponentInfo<Adapter>>> entry : entries) {
|
||||
Adapters<Adapter> adapters = (Adapters<Adapter>)_adapterMap.get(entry.getKey());
|
||||
List<Adapter> lst = new ArrayList<Adapter>();
|
||||
for (Info<Adapter> info : entry.getValue()) {
|
||||
for (ComponentInfo<Adapter> info : entry.getValue()) {
|
||||
s_logger.info("Instantiating Adapter: " + info.name);
|
||||
info.instance = (Adapter)createInstance(info.clazz, true, info.singleton);
|
||||
try {
|
||||
@ -486,10 +496,9 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
}
|
||||
}
|
||||
|
||||
protected void createAdaptersMap(Map<String, List<Info<Adapter>>> map) {
|
||||
_adapterMap = new HashMap<String, Adapters<? extends Adapter>>(map.size());
|
||||
Set<Map.Entry<String, List<Info<Adapter>>>> entries = map.entrySet();
|
||||
for (Map.Entry<String, List<Info<Adapter>>> entry : entries) {
|
||||
protected void createAdaptersMap(Map<String, List<ComponentInfo<Adapter>>> map) {
|
||||
Set<Map.Entry<String, List<ComponentInfo<Adapter>>>> entries = map.entrySet();
|
||||
for (Map.Entry<String, List<ComponentInfo<Adapter>>> entry : entries) {
|
||||
List<? extends Adapter> lst = new ArrayList<Adapter>(entry.getValue().size());
|
||||
_adapterMap.put(entry.getKey(), new Adapters(entry.getKey(), lst));
|
||||
}
|
||||
@ -550,7 +559,7 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
@Override
|
||||
public Collection<String> getManagers() {
|
||||
Collection<String> names = _parentLocator != null ? _parentLocator.getManagers() : new HashSet<String>();
|
||||
for (Map.Entry<String, Info<Manager>> entry : _managerMap.entrySet()) {
|
||||
for (Map.Entry<String, ComponentInfo<Manager>> entry : _managerMap.entrySet()) {
|
||||
names.add(entry.getValue().name);
|
||||
}
|
||||
return names;
|
||||
@ -559,7 +568,7 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
@Override
|
||||
public Collection<String> getDaos() {
|
||||
Collection<String> names = _parentLocator != null ? _parentLocator.getDaos() : new HashSet<String>();
|
||||
for (Map.Entry<String, Info<GenericDao<?, ?>>> entry : _daoMap.entrySet()) {
|
||||
for (Map.Entry<String, ComponentInfo<GenericDao<?, ?>>> entry : _daoMap.entrySet()) {
|
||||
names.add(entry.getValue().name);
|
||||
}
|
||||
return names;
|
||||
@ -637,13 +646,65 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
return s_tl.get();
|
||||
}
|
||||
|
||||
protected class Info<T> {
|
||||
public static class ComponentInfo<T> {
|
||||
Class<?> clazz;
|
||||
HashMap<String, Object> params = new HashMap<String, Object>();
|
||||
String name;
|
||||
List<String> keys = new ArrayList<String>();
|
||||
T instance;
|
||||
boolean singleton = true;
|
||||
|
||||
protected ComponentInfo() {
|
||||
}
|
||||
|
||||
public List<String> getKeys() {
|
||||
return keys;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ComponentInfo(String name, Class<? extends T> clazz) {
|
||||
this(name, clazz, new ArrayList<Pair<String, Object>>(0));
|
||||
}
|
||||
|
||||
public ComponentInfo(String name, Class<? extends T> clazz, List<Pair<String, Object>> params) {
|
||||
this(name, clazz, params, true);
|
||||
}
|
||||
|
||||
public ComponentInfo(String name, Class<? extends T> clazz, List<Pair<String, Object>> params, boolean singleton) {
|
||||
this.name = name;
|
||||
this.clazz = clazz;
|
||||
this.singleton = singleton;
|
||||
for (Pair<String, Object> param : params) {
|
||||
this.params.put(param.first(), param.second());
|
||||
}
|
||||
fillInfo();
|
||||
}
|
||||
|
||||
protected void fillInfo() {
|
||||
String clazzName = clazz.getName();
|
||||
|
||||
Local local = clazz.getAnnotation(Local.class);
|
||||
if (local == null) {
|
||||
throw new CloudRuntimeException("Unable to find Local annotation for class " + clazzName);
|
||||
}
|
||||
|
||||
// Verify that all interfaces specified in the Local annotation is implemented by the class.
|
||||
Class<?>[] classes = local.value();
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (!classes[i].isInterface()) {
|
||||
throw new CloudRuntimeException(classes[i].getName() + " is not an interface");
|
||||
}
|
||||
if (classes[i].isAssignableFrom(clazz)) {
|
||||
keys.add(classes[i].getName());
|
||||
s_logger.info("Found component: " + classes[i].getName() + " in " + clazzName + " - " + name);
|
||||
} else {
|
||||
throw new CloudRuntimeException(classes[i].getName() + " is not implemented by " + clazzName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -651,29 +712,30 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
* It builds a hash map of lists of adapters and a hash map of managers.
|
||||
**/
|
||||
protected class XmlHandler extends DefaultHandler {
|
||||
public HashMap<String, List<Info<Adapter>>> adapters;
|
||||
public HashMap<String, Info<Manager>> managers;
|
||||
public LinkedHashMap<String, Info<GenericDao<?, ?>>> daos;
|
||||
public HashMap<String, List<ComponentInfo<Adapter>>> adapters;
|
||||
public HashMap<String, ComponentInfo<Manager>> managers;
|
||||
public LinkedHashMap<String, ComponentInfo<GenericDao<?, ?>>> daos;
|
||||
public String parent;
|
||||
public String library;
|
||||
|
||||
List<Info<Adapter>> lst;
|
||||
List<ComponentInfo<Adapter>> lst;
|
||||
String paramName;
|
||||
StringBuilder value;
|
||||
String serverName;
|
||||
boolean parse;
|
||||
Info<?> currentInfo;
|
||||
ComponentInfo<?> currentInfo;
|
||||
|
||||
public XmlHandler(String serverName) {
|
||||
this.serverName = serverName;
|
||||
parse = false;
|
||||
adapters = new HashMap<String, List<Info<Adapter>>>();
|
||||
managers = new HashMap<String, Info<Manager>>();
|
||||
daos = new LinkedHashMap<String, Info<GenericDao<?, ?>>>();
|
||||
adapters = new HashMap<String, List<ComponentInfo<Adapter>>>();
|
||||
managers = new HashMap<String, ComponentInfo<Manager>>();
|
||||
daos = new LinkedHashMap<String, ComponentInfo<GenericDao<?, ?>>>();
|
||||
value = null;
|
||||
parent = null;
|
||||
}
|
||||
|
||||
protected void fillInfo(Attributes atts, Class<?> interphace, Info<?> info) {
|
||||
protected void fillInfo(Attributes atts, Class<?> interphace, ComponentInfo<?> info) {
|
||||
String clazzName = getAttribute(atts, "class");
|
||||
if (clazzName == null) {
|
||||
throw new CloudRuntimeException("Missing class attribute for " + interphace.getName());
|
||||
@ -696,41 +758,7 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
throw new CloudRuntimeException("Class " + info.clazz.toString() + " does not implment " + interphace);
|
||||
}
|
||||
|
||||
Local local = info.clazz.getAnnotation(Local.class);
|
||||
if (local == null) {
|
||||
throw new CloudRuntimeException("Unable to find Local annotation for class " + clazzName);
|
||||
}
|
||||
|
||||
Class<?>[] classes = local.value();
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
if (!classes[i].isInterface()) {
|
||||
throw new CloudRuntimeException(classes[i].getName() + " is not an interface");
|
||||
}
|
||||
if (classes[i].isAssignableFrom(info.clazz)) {
|
||||
info.keys.add(classes[i].getName());
|
||||
s_logger.info("Found component: " + classes[i].getName() + " in " + clazzName + " - " + info.name);
|
||||
} else {
|
||||
throw new CloudRuntimeException(classes[i].getName() + " is not implemented by " + info.clazz.getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (info.keys.size() != classes.length) {
|
||||
throw new CloudRuntimeException("Class " + clazzName + " does not implement " + interphace.getName());
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean findInterfaceInHierarchy(Class<?>[] interphaces, Class<?> interphace) {
|
||||
if (interphaces == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int j = 0; j < interphaces.length; j++) {
|
||||
if (interphaces[j] == interphace || findInterfaceInHierarchy(interphaces[j].getInterfaces(), interphace)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
info.fillInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -745,21 +773,23 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
if (implementationClass != null) {
|
||||
_implementationClassMap.put(_serverName, implementationClass);
|
||||
}
|
||||
|
||||
library = getAttribute(atts, "library");
|
||||
}
|
||||
} else if (qName.equals("adapters")) {
|
||||
lst = new ArrayList<Info<Adapter>>();
|
||||
lst = new ArrayList<ComponentInfo<Adapter>>();
|
||||
String key = getAttribute(atts, "key");
|
||||
if (key == null) {
|
||||
throw new CloudRuntimeException("Missing key attribute for adapters");
|
||||
}
|
||||
adapters.put(key, lst);
|
||||
} else if (qName.equals("adapter")) {
|
||||
Info<Adapter> info = new Info<Adapter>();
|
||||
ComponentInfo<Adapter> info = new ComponentInfo<Adapter>();
|
||||
fillInfo(atts, Adapter.class, info);
|
||||
lst.add(info);
|
||||
currentInfo = info;
|
||||
} else if (qName.equals("manager")) {
|
||||
Info<Manager> info = new Info<Manager>();
|
||||
ComponentInfo<Manager> info = new ComponentInfo<Manager>();
|
||||
fillInfo(atts, Manager.class, info);
|
||||
s_logger.info("Adding Manager: " + info.name);
|
||||
for (String key : info.keys) {
|
||||
@ -771,7 +801,7 @@ public class ComponentLocator extends Thread implements ComponentLocatorMBean {
|
||||
paramName = getAttribute(atts, "name");
|
||||
value = new StringBuilder();
|
||||
} else if (qName.equals("dao")) {
|
||||
Info<GenericDao<?, ?>> info = new Info<GenericDao<?, ?>>();
|
||||
ComponentInfo<GenericDao<?, ?>> info = new ComponentInfo<GenericDao<?, ?>>();
|
||||
fillInfo(atts, GenericDao.class, info);
|
||||
for (String key : info.keys) {
|
||||
daos.put(key, info);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user