Added support for component libraries in plugins

This commit is contained in:
Alex Huang 2012-07-09 10:25:14 -07:00
parent 75184d33ea
commit 1d3a443237
2 changed files with 121 additions and 78 deletions

View File

@ -71,15 +71,48 @@ import com.cloud.utils.mgmt.JmxUtil;
import com.cloud.utils.mgmt.ManagementBean; import com.cloud.utils.mgmt.ManagementBean;
/** /**
* ComponentLocator manages all of the adapters within a system. It operates on * ComponentLocator ties together several different concepts. First, it
* top of an components.xml and uses reflection to instantiate all of the * deals with how a system should be put together. It manages different
* adapters. It also supports rereading of all of the adapters. * types of components:
* - Manager: Singleton implementation of a certain process.
* - Adapter: Different singleton implementations for the same functions.
* - SystemIntegrityChecker: Singletons that are called at the load time.
* - Dao: Data Access Objects.
*
* These components can be declared in several ways:
* - ComponentLibrary - A Java class that declares the above components. The
* advantage of declaring components here is they change automatically
* with any refactoring.
* - components specification - An xml file that overrides the
* ComponentLibrary. The advantage of declaring components here is
* they can change by hand on every deployment.
*
* The two are NOT mutually exclusive. ComponentLocator basically locates
* the components specification, which specifies the ComponentLibrary within.
* Components found in the ComponentLibrary are overridden by components
* found in components specification.
*
* Components specification can also be nested. One components specification
* can point to another components specification and, therefore, "inherits"
* those components but still override one or more components. ComponentLocator
* reads the child components specification first and follow the chain up.
* the child's components overrides the ones in the parent.
*
* ComponentLocator looks for the components specification as follows:
* 1. By following the path specified by "cloud-stack-components-specification"
* within the environment.properties file.
* 2. Look for components.xml in the class path.
*
* ComponentLocator also ties in component injection. Components can specify
* an @Inject annotation to components ComponentLocator knows. When
* instantiating components, ComponentLocator attempts to inject these
* components.
* *
**/ **/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class ComponentLocator implements ComponentLocatorMBean { public class ComponentLocator implements ComponentLocatorMBean {
protected static final Logger s_logger = Logger.getLogger(ComponentLocator.class); protected static final Logger s_logger = Logger.getLogger(ComponentLocator.class);
protected static final ThreadLocal<ComponentLocator> s_tl = new ThreadLocal<ComponentLocator>(); protected static final ThreadLocal<ComponentLocator> s_tl = new ThreadLocal<ComponentLocator>();
protected static final ConcurrentHashMap<Class<?>, Singleton> s_singletons = new ConcurrentHashMap<Class<?>, Singleton>(111); protected static final ConcurrentHashMap<Class<?>, Singleton> s_singletons = new ConcurrentHashMap<Class<?>, Singleton>(111);
protected static final HashMap<String, ComponentLocator> s_locators = new HashMap<String, ComponentLocator>(); protected static final HashMap<String, ComponentLocator> s_locators = new HashMap<String, ComponentLocator>();
@ -90,7 +123,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
protected static CallbackFilter s_callbackFilter = new DatabaseCallbackFilter(); protected static CallbackFilter s_callbackFilter = new DatabaseCallbackFilter();
protected static final List<AnnotationInterceptor<?>> s_interceptors = new ArrayList<AnnotationInterceptor<?>>(); protected static final List<AnnotationInterceptor<?>> s_interceptors = new ArrayList<AnnotationInterceptor<?>>();
protected static CleanupThread s_janitor = null; protected static CleanupThread s_janitor = null;
protected HashMap<String, Adapters<? extends Adapter>> _adapterMap; protected HashMap<String, Adapters<? extends Adapter>> _adapterMap;
protected HashMap<String, ComponentInfo<Manager>> _managerMap; protected HashMap<String, ComponentInfo<Manager>> _managerMap;
protected LinkedHashMap<String, ComponentInfo<SystemIntegrityChecker>> _checkerMap; protected LinkedHashMap<String, ComponentInfo<SystemIntegrityChecker>> _checkerMap;
@ -98,8 +131,8 @@ public class ComponentLocator implements ComponentLocatorMBean {
protected String _serverName; protected String _serverName;
protected Object _component; protected Object _component;
protected HashMap<Class<?>, Class<?>> _factories; protected HashMap<Class<?>, Class<?>> _factories;
protected HashMap<String, ComponentInfo<PluggableService>> _pluggableServicesMap; protected HashMap<String, ComponentInfo<PluggableService>> _pluginsMap;
static { static {
if (s_janitor == null) { if (s_janitor == null) {
s_janitor = new CleanupThread(); s_janitor = new CleanupThread();
@ -118,7 +151,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
public String getLocatorName() { public String getLocatorName() {
return _serverName; return _serverName;
} }
@Override @Override
public String getName() { public String getName() {
return getLocatorName(); return getLocatorName();
@ -133,7 +166,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
_checkerMap = new LinkedHashMap<String, ComponentInfo<SystemIntegrityChecker>>(); _checkerMap = new LinkedHashMap<String, ComponentInfo<SystemIntegrityChecker>>();
_adapterMap = new HashMap<String, Adapters<? extends Adapter>>(); _adapterMap = new HashMap<String, Adapters<? extends Adapter>>();
_factories = new HashMap<Class<?>, Class<?>>(); _factories = new HashMap<Class<?>, Class<?>>();
_pluggableServicesMap = new LinkedHashMap<String, ComponentInfo<PluggableService>>(); _pluginsMap = new LinkedHashMap<String, ComponentInfo<PluggableService>>();
File file = PropertiesUtil.findConfigFile(filename); File file = PropertiesUtil.findConfigFile(filename);
if (file == null) { if (file == null) {
s_logger.info("Unable to find " + filename); s_logger.info("Unable to find " + filename);
@ -157,7 +190,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
_daoMap.putAll(parentLocator._daoMap); _daoMap.putAll(parentLocator._daoMap);
_managerMap.putAll(parentLocator._managerMap); _managerMap.putAll(parentLocator._managerMap);
_factories.putAll(parentLocator._factories); _factories.putAll(parentLocator._factories);
_pluggableServicesMap.putAll(parentLocator._pluggableServicesMap); _pluginsMap.putAll(parentLocator._pluginsMap);
} }
ComponentLibrary library = null; ComponentLibrary library = null;
@ -168,15 +201,15 @@ public class ComponentLocator implements ComponentLocatorMBean {
_managerMap.putAll(library.getManagers()); _managerMap.putAll(library.getManagers());
adapters.putAll(library.getAdapters()); adapters.putAll(library.getAdapters());
_factories.putAll(library.getFactories()); _factories.putAll(library.getFactories());
_pluggableServicesMap.putAll(library.getPluggableServices()); _pluginsMap.putAll(library.getPluggableServices());
} }
_daoMap.putAll(handler.daos); _daoMap.putAll(handler.daos);
_managerMap.putAll(handler.managers); _managerMap.putAll(handler.managers);
_checkerMap.putAll(handler.checkers); _checkerMap.putAll(handler.checkers);
adapters.putAll(handler.adapters); adapters.putAll(handler.adapters);
_pluggableServicesMap.putAll(handler.pluggableServices); _pluginsMap.putAll(handler.pluggableServices);
return new Pair<XmlHandler, HashMap<String, List<ComponentInfo<Adapter>>>>(handler, adapters); return new Pair<XmlHandler, HashMap<String, List<ComponentInfo<Adapter>>>>(handler, adapters);
} catch (ParserConfigurationException e) { } catch (ParserConfigurationException e) {
s_logger.error("Unable to load " + _serverName + " due to errors while parsing " + filename, e); s_logger.error("Unable to load " + _serverName + " due to errors while parsing " + filename, e);
@ -203,7 +236,9 @@ public class ComponentLocator implements ComponentLocatorMBean {
s_logger.info("Skipping configuration using " + filename); s_logger.info("Skipping configuration using " + filename);
return; return;
} }
instantiatePluggableServices();
XmlHandler handler = result.first(); XmlHandler handler = result.first();
HashMap<String, List<ComponentInfo<Adapter>>> adapters = result.second(); HashMap<String, List<ComponentInfo<Adapter>>> adapters = result.second();
try { try {
@ -220,13 +255,12 @@ public class ComponentLocator implements ComponentLocatorMBean {
startAdapters(); startAdapters();
//TODO do we need to follow the instantiate -> inject -> configure -> start -> stop flow of singletons like managers/adapters? //TODO do we need to follow the instantiate -> inject -> configure -> start -> stop flow of singletons like managers/adapters?
//TODO do we need to expose pluggableServices to MBean (provide getNames?) //TODO do we need to expose pluggableServices to MBean (provide getNames?)
instantiatePluggableServices();
} catch (CloudRuntimeException e) { } catch (CloudRuntimeException e) {
s_logger.error("Unable to load configuration for " + _serverName + " from " + filename, e); s_logger.error("Unable to load configuration for " + _serverName + " from " + filename, e);
System.exit(1); System.exit(1);
} catch (Exception e) { } catch (Exception e) {
s_logger.error("Unable to load configuration for " + _serverName + " from " + filename, e); s_logger.error("Unable to load configuration for " + _serverName + " from " + filename, e);
System.exit(1); System.exit(1);
} }
} }
@ -288,7 +322,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
} }
} }
} }
private static Object createInstance(Class<?> clazz, boolean inject, boolean singleton, Object... args) { private static Object createInstance(Class<?> clazz, boolean inject, boolean singleton, Object... args) {
Factory factory = null; Factory factory = null;
Singleton entity = null; Singleton entity = null;
@ -313,8 +347,8 @@ public class ComponentLocator implements ComponentLocatorMBean {
factory = info.factory; factory = info.factory;
} }
} }
Class<?>[] argTypes = null; Class<?>[] argTypes = null;
if (args != null && args.length > 0) { if (args != null && args.length > 0) {
Constructor<?>[] constructors = clazz.getConstructors(); Constructor<?>[] constructors = clazz.getConstructors();
@ -334,49 +368,49 @@ public class ComponentLocator implements ComponentLocatorMBean {
} }
} }
} }
if (argTypes == null) { if (argTypes == null) {
throw new CloudRuntimeException("Unable to find constructor to match parameters given: " + clazz.getName()); throw new CloudRuntimeException("Unable to find constructor to match parameters given: " + clazz.getName());
} }
entity = new Singleton(factory.newInstance(argTypes, args, s_callbacks)); entity = new Singleton(factory.newInstance(argTypes, args, s_callbacks));
} else { } else {
entity = new Singleton(factory.newInstance(s_callbacks)); entity = new Singleton(factory.newInstance(s_callbacks));
} }
if (inject) { if (inject) {
inject(clazz, entity.singleton); inject(clazz, entity.singleton);
entity.state = Singleton.State.Injected; entity.state = Singleton.State.Injected;
} }
if (singleton) { if (singleton) {
synchronized(s_factories) { synchronized(s_factories) {
s_singletons.put(clazz, entity); s_singletons.put(clazz, entity);
} }
} }
return entity.singleton; return entity.singleton;
} }
protected ComponentInfo<GenericDao<?, ?>> getDao(String name) { protected ComponentInfo<GenericDao<?, ?>> getDao(String name) {
ComponentInfo<GenericDao<?, ?>> info = _daoMap.get(name); ComponentInfo<GenericDao<?, ?>> info = _daoMap.get(name);
if (info == null) { if (info == null) {
throw new CloudRuntimeException("Unable to find DAO " + name); throw new CloudRuntimeException("Unable to find DAO " + name);
} }
return info; return info;
} }
public static synchronized Object getComponent(String componentName) { public static synchronized Object getComponent(String componentName) {
synchronized(_hasCheckerRun) { synchronized(_hasCheckerRun) {
/* System Integrity checker will run before all components really loaded */ /* System Integrity checker will run before all components really loaded */
if (!_hasCheckerRun && !componentName.equalsIgnoreCase(SystemIntegrityChecker.Name)) { if (!_hasCheckerRun && !componentName.equalsIgnoreCase(SystemIntegrityChecker.Name)) {
ComponentLocator.getComponent(SystemIntegrityChecker.Name); ComponentLocator.getComponent(SystemIntegrityChecker.Name);
_hasCheckerRun = true; _hasCheckerRun = true;
} }
} }
ComponentLocator locator = s_locators.get(componentName); ComponentLocator locator = s_locators.get(componentName);
if (locator == null) { if (locator == null) {
locator = ComponentLocator.getLocator(componentName); locator = ComponentLocator.getLocator(componentName);
@ -441,10 +475,10 @@ public class ComponentLocator implements ComponentLocatorMBean {
} }
} }
} }
protected static void inject(Class<?> clazz, Object entity) { protected static void inject(Class<?> clazz, Object entity) {
ComponentLocator locator = ComponentLocator.getCurrentLocator(); ComponentLocator locator = ComponentLocator.getCurrentLocator();
do { do {
Field[] fields = clazz.getDeclaredFields(); Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) { for (Field field : fields) {
@ -467,11 +501,11 @@ public class ComponentLocator implements ComponentLocatorMBean {
s_logger.trace("Other:" + fc.getName()); s_logger.trace("Other:" + fc.getName());
instance = locator.getManager(fc); instance = locator.getManager(fc);
} }
if (instance == null) { if (instance == null) {
throw new CloudRuntimeException("Unable to inject " + fc.getSimpleName() + " in " + clazz.getSimpleName()); throw new CloudRuntimeException("Unable to inject " + fc.getSimpleName() + " in " + clazz.getSimpleName());
} }
try { try {
field.setAccessible(true); field.setAccessible(true);
field.set(entity, instance); field.set(entity, instance);
@ -545,7 +579,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
} }
return (T)info.instance; return (T)info.instance;
} }
protected void configureAdapters() { protected void configureAdapters() {
for (Adapters<? extends Adapter> adapters : _adapterMap.values()) { for (Adapters<? extends Adapter> adapters : _adapterMap.values()) {
List<ComponentInfo<Adapter>> infos = adapters._infos; List<ComponentInfo<Adapter>> infos = adapters._infos;
@ -597,7 +631,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
_adapterMap.put(entry.getKey(), adapters); _adapterMap.put(entry.getKey(), adapters);
} }
} }
protected void instantiateAdapters(Map<String, List<ComponentInfo<Adapter>>> map) { protected void instantiateAdapters(Map<String, List<ComponentInfo<Adapter>>> map) {
Set<Map.Entry<String, List<ComponentInfo<Adapter>>>> entries = map.entrySet(); Set<Map.Entry<String, List<ComponentInfo<Adapter>>>> entries = map.entrySet();
for (Map.Entry<String, List<ComponentInfo<Adapter>>> entry : entries) { for (Map.Entry<String, List<ComponentInfo<Adapter>>> entry : entries) {
@ -641,18 +675,26 @@ public class ComponentLocator implements ComponentLocatorMBean {
} }
protected void instantiatePluggableServices() { protected void instantiatePluggableServices() {
Set<Map.Entry<String, ComponentInfo<PluggableService>>> entries = _pluggableServicesMap.entrySet(); Set<Map.Entry<String, ComponentInfo<PluggableService>>> entries = _pluginsMap.entrySet();
for (Map.Entry<String, ComponentInfo<PluggableService>> entry : entries) { for (Map.Entry<String, ComponentInfo<PluggableService>> entry : entries) {
ComponentInfo<PluggableService> info = entry.getValue(); ComponentInfo<PluggableService> info = entry.getValue();
if (info.instance == null) { if (info.instance == null) {
s_logger.info("Instantiating PluggableService: " + info.name); s_logger.info("Instantiating PluggableService: " + info.name);
info.instance = (PluggableService)createInstance(info.clazz, false, info.singleton); info.instance = (PluggableService)createInstance(info.clazz, false, info.singleton);
if (info.instance instanceof Plugin) {
Plugin plugin = (Plugin)info.instance;
ComponentLibrary lib = plugin.getComponentLibrary();
_managerMap.putAll(lib.getManagers());
_daoMap.putAll(lib.getDaos());
}
} }
} }
} }
protected ComponentInfo<PluggableService> getPluggableService(String name) { protected ComponentInfo<PluggableService> getPluggableService(String name) {
ComponentInfo<PluggableService> mgr = _pluggableServicesMap.get(name); ComponentInfo<PluggableService> mgr = _pluginsMap.get(name);
return mgr; return mgr;
} }
@ -669,7 +711,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
public <T> List<T> getAllPluggableServices() { public <T> List<T> getAllPluggableServices() {
List<T> services = new ArrayList<T>(); List<T> services = new ArrayList<T>();
Set<Map.Entry<String, ComponentInfo<PluggableService>>> entries = _pluggableServicesMap.entrySet(); Set<Map.Entry<String, ComponentInfo<PluggableService>>> entries = _pluginsMap.entrySet();
for (Map.Entry<String, ComponentInfo<PluggableService>> entry : entries) { for (Map.Entry<String, ComponentInfo<PluggableService>> entry : entries) {
ComponentInfo<PluggableService> info = entry.getValue(); ComponentInfo<PluggableService> info = entry.getValue();
if (info.instance == null) { if (info.instance == null) {
@ -680,11 +722,11 @@ public class ComponentLocator implements ComponentLocatorMBean {
} }
return services; return services;
} }
public static <T> T inject(Class<T> clazz) { public static <T> T inject(Class<T> clazz) {
return (T)createInstance(clazz, true, false); return (T)createInstance(clazz, true, false);
} }
public <T> T createInstance(Class<T> clazz) { public <T> T createInstance(Class<T> clazz) {
Class<? extends T> impl = (Class<? extends T>)_factories.get(clazz); Class<? extends T> impl = (Class<? extends T>)_factories.get(clazz);
if (impl == null) { if (impl == null) {
@ -692,11 +734,11 @@ public class ComponentLocator implements ComponentLocatorMBean {
} }
return inject(impl); return inject(impl);
} }
public static <T> T inject(Class<T> clazz, Object... args) { public static <T> T inject(Class<T> clazz, Object... args) {
return (T)createInstance(clazz, true, false, args); return (T)createInstance(clazz, true, false, args);
} }
@Override @Override
public Map<String, List<String>> getAdapterNames() { public Map<String, List<String>> getAdapterNames() {
HashMap<String, List<String>> result = new HashMap<String, List<String>>(); HashMap<String, List<String>> result = new HashMap<String, List<String>>();
@ -749,7 +791,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
} }
return new Adapters<Adapter>(key, new ArrayList<ComponentInfo<Adapter>>()); return new Adapters<Adapter>(key, new ArrayList<ComponentInfo<Adapter>>());
} }
protected void resetInterceptors(InterceptorLibrary library) { protected void resetInterceptors(InterceptorLibrary library) {
library.addInterceptors(s_interceptors); library.addInterceptors(s_interceptors);
if (s_interceptors.size() > 0) { if (s_interceptors.size() > 0) {
@ -781,7 +823,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
s_once = true; s_once = true;
} }
} }
ComponentLocator locator; ComponentLocator locator;
synchronized (s_locators) { synchronized (s_locators) {
locator = s_locators.get(server); locator = s_locators.get(server);
@ -822,7 +864,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
} catch (IOException e) { } catch (IOException e) {
s_logger.debug("environment.properties could not be loaded:" + e.toString()); s_logger.debug("environment.properties could not be loaded:" + e.toString());
} }
if (configFile == null || PropertiesUtil.findConfigFile(configFile) == null) { if (configFile == null || PropertiesUtil.findConfigFile(configFile) == null) {
configFile = "components.xml"; configFile = "components.xml";
if (PropertiesUtil.findConfigFile(configFile) == null){ if (PropertiesUtil.findConfigFile(configFile) == null){
@ -843,31 +885,31 @@ public class ComponentLocator implements ComponentLocatorMBean {
List<String> keys = new ArrayList<String>(); List<String> keys = new ArrayList<String>();
T instance; T instance;
boolean singleton = true; boolean singleton = true;
protected ComponentInfo() { protected ComponentInfo() {
} }
public List<String> getKeys() { public List<String> getKeys() {
return keys; return keys;
} }
public String getName() { public String getName() {
return name; return name;
} }
public ComponentInfo(String name, Class<? extends T> clazz) { public ComponentInfo(String name, Class<? extends T> clazz) {
this(name, clazz, new ArrayList<Pair<String, Object>>(0)); this(name, clazz, new ArrayList<Pair<String, Object>>(0));
} }
public ComponentInfo(String name, Class<? extends T> clazz, T instance) { public ComponentInfo(String name, Class<? extends T> clazz, T instance) {
this(name, clazz); this(name, clazz);
this.instance = instance; this.instance = instance;
} }
public ComponentInfo(String name, Class<? extends T> clazz, List<Pair<String, Object>> params) { public ComponentInfo(String name, Class<? extends T> clazz, List<Pair<String, Object>> params) {
this(name, clazz, params, true); this(name, clazz, params, true);
} }
public ComponentInfo(String name, Class<? extends T> clazz, List<Pair<String, Object>> params, boolean singleton) { public ComponentInfo(String name, Class<? extends T> clazz, List<Pair<String, Object>> params, boolean singleton) {
this.name = name; this.name = name;
this.clazz = clazz; this.clazz = clazz;
@ -877,10 +919,10 @@ public class ComponentLocator implements ComponentLocatorMBean {
} }
fillInfo(); fillInfo();
} }
protected void fillInfo() { protected void fillInfo() {
String clazzName = clazz.getName(); String clazzName = clazz.getName();
Local local = clazz.getAnnotation(Local.class); Local local = clazz.getAnnotation(Local.class);
if (local == null) { if (local == null) {
throw new CloudRuntimeException("Unable to find Local annotation for class " + clazzName); throw new CloudRuntimeException("Unable to find Local annotation for class " + clazzName);
@ -900,7 +942,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
} }
} }
} }
public void addParameter(String name, String value) { public void addParameter(String name, String value) {
params.put(name, value); params.put(name, value);
} }
@ -964,13 +1006,13 @@ public class ComponentLocator implements ComponentLocatorMBean {
if (singleton != null) { if (singleton != null) {
info.singleton = Boolean.parseBoolean(singleton); info.singleton = Boolean.parseBoolean(singleton);
} }
info.fillInfo(); info.fillInfo();
} }
@Override @Override
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
throws SAXException { throws SAXException {
if (qName.equals("interceptor") && s_interceptors.size() == 0) { if (qName.equals("interceptor") && s_interceptors.size() == 0) {
synchronized(s_interceptors){ synchronized(s_interceptors){
if (s_interceptors.size() == 0) { if (s_interceptors.size() == 0) {
@ -1001,7 +1043,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
throw new CloudRuntimeException("Unable to find " + implementationClass, e); throw new CloudRuntimeException("Unable to find " + implementationClass, e);
} }
} }
library = getAttribute(atts, "library"); library = getAttribute(atts, "library");
} }
} else if (qName.equals("adapters")) { } else if (qName.equals("adapters")) {
@ -1041,7 +1083,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
checkers.put(info.name, info); checkers.put(info.name, info);
s_logger.info("Adding system integrity checker: " + info.name); s_logger.info("Adding system integrity checker: " + info.name);
currentInfo = info; currentInfo = info;
} else if (qName.equals("pluggableservice")) { } else if (qName.equals("pluggableservice") || qName.equals("plugin")) {
ComponentInfo<PluggableService> info = new ComponentInfo<PluggableService>(); ComponentInfo<PluggableService> info = new ComponentInfo<PluggableService>();
fillInfo(atts, PluggableService.class, info); fillInfo(atts, PluggableService.class, info);
s_logger.info("Adding PluggableService: " + info.name); s_logger.info("Adding PluggableService: " + info.name);
@ -1096,17 +1138,17 @@ public class ComponentLocator implements ComponentLocatorMBean {
} }
} }
} }
protected static class InjectInfo { protected static class InjectInfo {
public Factory factory; public Factory factory;
public Enhancer enhancer; public Enhancer enhancer;
public InjectInfo(Enhancer enhancer, Factory factory) { public InjectInfo(Enhancer enhancer, Factory factory) {
this.factory = factory; this.factory = factory;
this.enhancer = enhancer; this.enhancer = enhancer;
} }
} }
protected static class CleanupThread extends Thread { protected static class CleanupThread extends Thread {
@Override @Override
public void run() { public void run() {
@ -1133,7 +1175,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
} }
} }
} }
for (ComponentLocator locator : s_locators.values()) { for (ComponentLocator locator : s_locators.values()) {
Iterator<ComponentInfo<Manager>> itManagers = locator._managerMap.values().iterator(); Iterator<ComponentInfo<Manager>> itManagers = locator._managerMap.values().iterator();
while (itManagers.hasNext()) { while (itManagers.hasNext()) {
@ -1154,7 +1196,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
} }
} }
} }
static class Singleton { static class Singleton {
public enum State { public enum State {
Instantiated, Instantiated,
@ -1163,16 +1205,16 @@ public class ComponentLocator implements ComponentLocatorMBean {
Started, Started,
Stopped Stopped
} }
public Object singleton; public Object singleton;
public State state; public State state;
public Singleton(Object singleton) { public Singleton(Object singleton) {
this.singleton = singleton; this.singleton = singleton;
this.state = State.Instantiated; this.state = State.Instantiated;
} }
} }
protected class InterceptorDispatcher implements MethodInterceptor { protected class InterceptorDispatcher implements MethodInterceptor {
@Override @Override
@ -1200,7 +1242,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
} }
} }
} }
protected static class InterceptorFilter implements CallbackFilter { protected static class InterceptorFilter implements CallbackFilter {
@Override @Override
public int accept(Method method) { public int accept(Method method) {
@ -1215,7 +1257,7 @@ public class ComponentLocator implements ComponentLocatorMBean {
} }
} }
} }
return index; return index;
} }
} }

View File

@ -17,6 +17,7 @@
package com.cloud.utils.component; package com.cloud.utils.component;
/** /**
* This interface defines methods for pluggable code within the Cloud Stack. * This interface defines methods for pluggable code within the Cloud Stack.
*/ */
@ -26,5 +27,5 @@ public interface PluggableService {
* The config file name that lists API commands supported by this pluggable service * The config file name that lists API commands supported by this pluggable service
*/ */
String getPropertiesFile(); String getPropertiesFile();
} }