mirror of https://github.com/apache/cloudstack.git
Refactor ComponentLocator to be based on Spring so that legacy way of loading component can coexist with Spring
This commit is contained in:
parent
0e9924fcee
commit
453b31f3f4
|
|
@ -53,7 +53,7 @@ import com.cloud.utils.PropertiesUtil;
|
|||
import com.cloud.utils.backoff.BackoffAlgorithm;
|
||||
import com.cloud.utils.backoff.impl.ConstantTimeBackoff;
|
||||
import com.cloud.utils.component.Adapters;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.LegacyComponentLocator;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.MacAddress;
|
||||
import com.cloud.utils.script.Script;
|
||||
|
|
@ -374,7 +374,7 @@ public class AgentShell implements IAgentShell {
|
|||
|
||||
public void init(String[] args) throws ConfigurationException {
|
||||
|
||||
final ComponentLocator locator = ComponentLocator.getLocator("agent");
|
||||
final LegacyComponentLocator locator = LegacyComponentLocator.getLocator("agent");
|
||||
|
||||
final Class<?> c = this.getClass();
|
||||
_version = c.getPackage().getImplementationVersion();
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ import com.cloud.utils.PropertiesUtil;
|
|||
import com.cloud.utils.backoff.BackoffAlgorithm;
|
||||
import com.cloud.utils.backoff.impl.ConstantTimeBackoff;
|
||||
import com.cloud.utils.component.Adapters;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.LegacyComponentLocator;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.MacAddress;
|
||||
import com.cloud.utils.nio.HandlerFactory;
|
||||
|
|
@ -317,7 +317,7 @@ public class VmmAgentShell implements IAgentShell, HandlerFactory {
|
|||
|
||||
private void init(String[] args) throws ConfigurationException{
|
||||
|
||||
final ComponentLocator locator = ComponentLocator.getLocator("agent");
|
||||
final LegacyComponentLocator locator = LegacyComponentLocator.getLocator("agent");
|
||||
|
||||
final Class<?> c = this.getClass();
|
||||
_version = c.getPackage().getImplementationVersion();
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.Map;
|
|||
|
||||
import com.cloud.utils.component.Adapter;
|
||||
import com.cloud.utils.component.ComponentLibraryBase;
|
||||
import com.cloud.utils.component.ComponentLocator.ComponentInfo;
|
||||
import com.cloud.utils.component.LegacyComponentLocator.ComponentInfo;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ import com.cloud.service.dao.ServiceOfferingDaoImpl;
|
|||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.dao.DiskOfferingDaoImpl;
|
||||
import com.cloud.utils.PropertiesUtil;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.LegacyComponentLocator;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.net.NfsUtils;
|
||||
|
|
@ -76,10 +76,10 @@ public class DatabaseConfig {
|
|||
private static HashSet<String> fieldNames = new HashSet<String>();
|
||||
|
||||
// Maintain an IPRangeConfig object to handle IP related logic
|
||||
private final IPRangeConfig iprc = ComponentLocator.inject(IPRangeConfig.class);
|
||||
private final IPRangeConfig iprc = LegacyComponentLocator.inject(IPRangeConfig.class);
|
||||
|
||||
// Maintain a PodZoneConfig object to handle Pod/Zone related logic
|
||||
private final PodZoneConfig pzc = ComponentLocator.inject(PodZoneConfig.class);
|
||||
private final PodZoneConfig pzc = LegacyComponentLocator.inject(PodZoneConfig.class);
|
||||
|
||||
// Global variables to store network.throttling.rate and multicast.throttling.rate from the configuration table
|
||||
// Will be changed from null to a non-null value if the value existed in the configuration table
|
||||
|
|
@ -359,7 +359,7 @@ public class DatabaseConfig {
|
|||
s_logger.error("error starting database config, missing initial data file");
|
||||
} else {
|
||||
try {
|
||||
DatabaseConfig config = ComponentLocator.inject(DatabaseConfig.class, args[0]);
|
||||
DatabaseConfig config = LegacyComponentLocator.inject(DatabaseConfig.class, args[0]);
|
||||
config.doVersionCheck();
|
||||
config.doConfig();
|
||||
System.exit(0);
|
||||
|
|
@ -918,7 +918,7 @@ public class DatabaseConfig {
|
|||
}
|
||||
|
||||
ServiceOfferingVO serviceOffering = new ServiceOfferingVO(name, cpu, ramSize, speed, null, null, ha, displayText, useLocalStorage, false, null, false, null, false);
|
||||
ServiceOfferingDaoImpl dao = ComponentLocator.inject(ServiceOfferingDaoImpl.class);
|
||||
ServiceOfferingDaoImpl dao = LegacyComponentLocator.inject(ServiceOfferingDaoImpl.class);
|
||||
try {
|
||||
dao.persist(serviceOffering);
|
||||
} catch (Exception e) {
|
||||
|
|
@ -967,7 +967,7 @@ public class DatabaseConfig {
|
|||
}
|
||||
DiskOfferingVO diskOffering = new DiskOfferingVO(domainId, name, displayText, diskSpace , tags, false);
|
||||
diskOffering.setUseLocalStorage(local);
|
||||
DiskOfferingDaoImpl offering = ComponentLocator.inject(DiskOfferingDaoImpl.class);
|
||||
DiskOfferingDaoImpl offering = LegacyComponentLocator.inject(DiskOfferingDaoImpl.class);
|
||||
try {
|
||||
offering.persist(diskOffering);
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager{
|
|||
NetworkServiceMapDao _ntwkSrvcDao;
|
||||
@Inject
|
||||
NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao;
|
||||
|
||||
@com.cloud.utils.component.Inject(adapter = NetworkElement.class)
|
||||
Adapters<NetworkElement> _networkElements;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import com.cloud.utils.EnumerationImpl;
|
||||
import com.cloud.utils.component.ComponentLocator.ComponentInfo;
|
||||
import com.cloud.utils.component.LegacyComponentLocator.ComponentInfo;
|
||||
|
||||
/**
|
||||
* the iterator even during dynamic reloading.
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class ComponentContext implements ApplicationContextAware {
|
|||
return s_appContext;
|
||||
}
|
||||
|
||||
public static <T> T getCompanent(String name) {
|
||||
public static <T> T getCompanent(String name) {
|
||||
assert(s_appContext != null);
|
||||
return (T)s_appContext.getBean(name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package com.cloud.utils.component;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.utils.component.ComponentLocator.ComponentInfo;
|
||||
import com.cloud.utils.component.LegacyComponentLocator.ComponentInfo;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.ComponentLocator.ComponentInfo;
|
||||
import com.cloud.utils.component.LegacyComponentLocator.ComponentInfo;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
public abstract class ComponentLibraryBase implements ComponentLibrary {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -27,3 +27,4 @@ import java.lang.annotation.Target;
|
|||
public @interface Inject {
|
||||
Class<? extends Adapter> adapter() default Adapter.class;
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -33,7 +33,7 @@ import com.cloud.utils.db.GenericDao;
|
|||
/**
|
||||
* defining mock components.
|
||||
*/
|
||||
public class MockComponentLocator extends ComponentLocator {
|
||||
public class MockComponentLocator extends LegacyComponentLocator {
|
||||
MockComponentLibrary _library = new MockComponentLibrary();
|
||||
|
||||
public MockComponentLocator(String server) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package com.cloud.utils.testcase;
|
|||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.LegacyComponentLocator;
|
||||
|
||||
public class ComponentTestCase extends Log4jEnabledTestCase {
|
||||
@Override
|
||||
|
|
@ -29,7 +29,7 @@ public class ComponentTestCase extends Log4jEnabledTestCase {
|
|||
if(annotations != null) {
|
||||
for(Annotation annotation : annotations) {
|
||||
if(annotation instanceof ComponentSetup) {
|
||||
ComponentLocator.getLocator(
|
||||
LegacyComponentLocator.getLocator(
|
||||
((ComponentSetup)annotation).managerName(),
|
||||
((ComponentSetup)annotation).setupXml(),
|
||||
((ComponentSetup)annotation).log4j()
|
||||
|
|
|
|||
Loading…
Reference in New Issue