cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [30/36] Compile complete
Date Fri, 06 Sep 2013 22:39:00 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8e79c30/server/test/com/cloud/alert/AlertControlsUnitTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/alert/AlertControlsUnitTest.java b/server/test/com/cloud/alert/AlertControlsUnitTest.java
index 2b30246..5941a91 100644
--- a/server/test/com/cloud/alert/AlertControlsUnitTest.java
+++ b/server/test/com/cloud/alert/AlertControlsUnitTest.java
@@ -48,6 +48,7 @@ public class AlertControlsUnitTest extends TestCase {
     @Mock AlertDao _alertDao;
     @Override
     @Before
+    @SuppressWarnings("unchecked")
     protected void setUp() {
         MockitoAnnotations.initMocks(this);
         _mgmtServer._alertDao = _alertDao;
@@ -57,6 +58,7 @@ public class AlertControlsUnitTest extends TestCase {
         when(_alertDao.deleteAlert(anyList(), anyString(), any(Date.class), any(Date.class),
anyLong())).thenReturn(true);
     }
 
+    @Override
     @After
     public void tearDown() throws Exception {
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8e79c30/server/test/com/cloud/vpc/dao/MockConfigurationDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/dao/MockConfigurationDaoImpl.java b/server/test/com/cloud/vpc/dao/MockConfigurationDaoImpl.java
index 1ca5e93..a0110b5 100644
--- a/server/test/com/cloud/vpc/dao/MockConfigurationDaoImpl.java
+++ b/server/test/com/cloud/vpc/dao/MockConfigurationDaoImpl.java
@@ -21,8 +21,8 @@ import java.util.Map;
 
 import javax.ejb.Local;
 
-import org.apache.cloudstack.framework.config.ConfigurationVO;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.cloudstack.framework.config.impl.ConfigurationVO;
 
 import com.cloud.utils.db.GenericDaoBase;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8e79c30/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java
----------------------------------------------------------------------
diff --git a/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java
b/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java
index 122cf79..1f1fb75 100644
--- a/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java
+++ b/server/test/org/apache/cloudstack/networkoffering/CreateNetworkOfferingTest.java
@@ -35,8 +35,8 @@ import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
 import org.apache.cloudstack.context.CallContext;
-import org.apache.cloudstack.framework.config.ConfigurationVO;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.cloudstack.framework.config.impl.ConfigurationVO;
 
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.exception.InvalidParameterValueException;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8e79c30/utils/src/com/cloud/utils/ReflectUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/ReflectUtil.java b/utils/src/com/cloud/utils/ReflectUtil.java
index c123d29..08a780a 100755
--- a/utils/src/com/cloud/utils/ReflectUtil.java
+++ b/utils/src/com/cloud/utils/ReflectUtil.java
@@ -16,10 +16,9 @@
 // under the License.
 package com.cloud.utils;
 
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.google.common.collect.ImmutableSet;
-import org.apache.log4j.Logger;
-import org.reflections.Reflections;
+import static java.beans.Introspector.getBeanInfo;
+import static java.util.Collections.emptyList;
+import static java.util.Collections.unmodifiableList;
 
 import java.beans.BeanInfo;
 import java.beans.IntrospectionException;
@@ -34,9 +33,12 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import static java.beans.Introspector.getBeanInfo;
-import static java.util.Collections.emptyList;
-import static java.util.Collections.unmodifiableList;
+import org.apache.log4j.Logger;
+import org.reflections.Reflections;
+
+import com.google.common.collect.ImmutableSet;
+
+import com.cloud.utils.exception.CloudRuntimeException;
 
 public class ReflectUtil {
     
@@ -109,7 +111,7 @@ public class ReflectUtil {
         List<Field> fields = new ArrayList<Field>();
         Collections.addAll(fields, cmdClass.getDeclaredFields());
         Class<?> superClass = cmdClass.getSuperclass();
-        while (baseClass.isAssignableFrom(superClass)) {
+        while (baseClass.isAssignableFrom(superClass) && baseClass != superClass)
{
             Field[] superClassFields = superClass.getDeclaredFields();
             if (superClassFields != null)
                 Collections.addAll(fields, superClassFields);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8e79c30/utils/src/com/cloud/utils/component/AdapterBase.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/AdapterBase.java b/utils/src/com/cloud/utils/component/AdapterBase.java
index 8353cee..0dcb968 100644
--- a/utils/src/com/cloud/utils/component/AdapterBase.java
+++ b/utils/src/com/cloud/utils/component/AdapterBase.java
@@ -21,16 +21,17 @@ import java.util.List;
 // Typical Adapter implementation.
 public class AdapterBase extends ComponentLifecycleBase implements Adapter, ComponentMethodInterceptable
{
 
-	public AdapterBase() {
+    public AdapterBase() {
+        super();
         // set default run level for adapter components
         setRunLevel(ComponentLifecycle.RUN_LEVEL_COMPONENT);
 	}
 
-	public static <T extends Adapter> T getAdapterByName(List<T> adapters, String
name) {
-    	for(T adapter : adapters) {
-    		if(adapter.getName() != null && adapter.getName().equalsIgnoreCase(name))
-    			return adapter;
-    	}
-    	return null;
+    public static <T extends Adapter> T getAdapterByName(List<T> adapters, String
name) {
+        for (T adapter : adapters) {
+            if (adapter.getName() != null && adapter.getName().equalsIgnoreCase(name))
+                return adapter;
+        }
+        return null;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8e79c30/utils/src/com/cloud/utils/component/ComponentContext.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/ComponentContext.java b/utils/src/com/cloud/utils/component/ComponentContext.java
index 6fc25b2..065fd3b 100644
--- a/utils/src/com/cloud/utils/component/ComponentContext.java
+++ b/utils/src/com/cloud/utils/component/ComponentContext.java
@@ -34,7 +34,6 @@ import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 import org.springframework.context.annotation.Primary;
-import org.springframework.stereotype.Component;
 
 import com.cloud.utils.mgmt.JmxUtil;
 import com.cloud.utils.mgmt.ManagementBean;
@@ -45,7 +44,7 @@ import com.cloud.utils.mgmt.ManagementBean;
  * are not recommended to be used outside, they exist to help wire Spring Framework
  *
  */
-@Component
+@SuppressWarnings("unchecked")
 public class ComponentContext implements ApplicationContextAware {
     private static final Logger s_logger = Logger.getLogger(ComponentContext.class);
 
@@ -53,99 +52,98 @@ public class ComponentContext implements ApplicationContextAware {
 
     @Override
     public void setApplicationContext(ApplicationContext applicationContext) {
-    	s_logger.info("Setup Spring Application context");
+        s_logger.info("Setup Spring Application context");
         s_appContext = applicationContext;
     }
 
     public static ApplicationContext getApplicationContext() {
         return s_appContext;
     }
-    
+
     public static void initComponentsLifeCycle() {
-        AutowireCapableBeanFactory  beanFactory = s_appContext.getAutowireCapableBeanFactory();
-
-    	Map<String, ComponentMethodInterceptable> interceptableComponents = getApplicationContext().getBeansOfType(
-    		ComponentMethodInterceptable.class);
-    	for(Map.Entry<String, ComponentMethodInterceptable> entry : interceptableComponents.entrySet())
{
-    		Object bean = getTargetObject(entry.getValue());
-    		beanFactory.configureBean(bean, entry.getKey());
-    	}
-    	
-    	Map<String, ComponentLifecycle> lifecycleComponents = getApplicationContext().getBeansOfType(ComponentLifecycle.class);
- 
-    	Map[] classifiedComponents = new Map[ComponentLifecycle.MAX_RUN_LEVELS];
-    	for(int i = 0; i < ComponentLifecycle.MAX_RUN_LEVELS; i++) {
-    		classifiedComponents[i] = new HashMap<String, ComponentLifecycle>();
-    	}
-    	
-    	for(Map.Entry<String, ComponentLifecycle> entry : lifecycleComponents.entrySet())
{
-    		classifiedComponents[entry.getValue().getRunLevel()].put(entry.getKey(), entry.getValue());
-    	}
+        AutowireCapableBeanFactory beanFactory = s_appContext.getAutowireCapableBeanFactory();
+
+        Map<String, ComponentMethodInterceptable> interceptableComponents = getApplicationContext().getBeansOfType(ComponentMethodInterceptable.class);
+        for (Map.Entry<String, ComponentMethodInterceptable> entry : interceptableComponents.entrySet())
{
+            Object bean = getTargetObject(entry.getValue());
+            beanFactory.configureBean(bean, entry.getKey());
+        }
+
+        Map<String, ComponentLifecycle> lifecycleComponents = getApplicationContext().getBeansOfType(ComponentLifecycle.class);
+
+        Map<String, ComponentLifecycle>[] classifiedComponents = new Map[ComponentLifecycle.MAX_RUN_LEVELS];
+        for (int i = 0; i < ComponentLifecycle.MAX_RUN_LEVELS; i++) {
+            classifiedComponents[i] = new HashMap<String, ComponentLifecycle>();
+        }
+
+        for (Map.Entry<String, ComponentLifecycle> entry : lifecycleComponents.entrySet())
{
+            classifiedComponents[entry.getValue().getRunLevel()].put(entry.getKey(), entry.getValue());
+        }
 
         // Run the SystemIntegrityCheckers first
         Map<String, SystemIntegrityChecker> integrityCheckers = getApplicationContext().getBeansOfType(SystemIntegrityChecker.class);
-        for (Entry<String,SystemIntegrityChecker> entry : integrityCheckers.entrySet()
){
-            s_logger.info ("Running SystemIntegrityChecker " + entry.getKey());
+        for (Entry<String, SystemIntegrityChecker> entry : integrityCheckers.entrySet())
{
+            s_logger.info("Running SystemIntegrityChecker " + entry.getKey());
             try {
-            	entry.getValue().check();
-            } catch(Throwable e) {
+                entry.getValue().check();
+            } catch (Throwable e) {
                 s_logger.error("System integrity check failed. Refuse to startup", e);
-            	System.exit(1);
+                System.exit(1);
             }
         }
-    	
-    	// configuration phase
+
+        // configuration phase
         Map<String, String> avoidMap = new HashMap<String, String>();
-    	for(int i = 0; i < ComponentLifecycle.MAX_RUN_LEVELS; i++) {
-    		for(Map.Entry<String, ComponentLifecycle> entry : ((Map<String, ComponentLifecycle>)classifiedComponents[i]).entrySet())
{
-    			ComponentLifecycle component = entry.getValue();
-    			String implClassName = ComponentContext.getTargetClass(component).getName();
+        for (int i = 0; i < ComponentLifecycle.MAX_RUN_LEVELS; i++) {
+            for (Map.Entry<String, ComponentLifecycle> entry : classifiedComponents[i].entrySet())
{
+                ComponentLifecycle component = entry.getValue();
+                String implClassName = ComponentContext.getTargetClass(component).getName();
                 s_logger.info("Configuring " + implClassName);
-                
-                if(avoidMap.containsKey(implClassName)) {
+
+                if (avoidMap.containsKey(implClassName)) {
                     s_logger.info("Skip configuration of " + implClassName + " as it is already
configured");
-                	continue;
+                    continue;
                 }
-                
+
                 try {
-					component.configure(component.getName(), component.getConfigParams());
-				} catch (ConfigurationException e) {
-					s_logger.error("Unhandled exception", e);
-					throw new RuntimeException("Unable to configure " + implClassName, e);
-				}
-                
+                    component.configure(component.getName(), component.getConfigParams());
+                } catch (ConfigurationException e) {
+                    s_logger.error("Unhandled exception", e);
+                    throw new RuntimeException("Unable to configure " + implClassName, e);
+                }
+
                 avoidMap.put(implClassName, implClassName);
-    		}
-    	}
- 
-    	// starting phase
-    	avoidMap.clear();
-    	for(int i = 0; i < ComponentLifecycle.MAX_RUN_LEVELS; i++) {
-    		for(Map.Entry<String, ComponentLifecycle> entry : ((Map<String, ComponentLifecycle>)classifiedComponents[i]).entrySet())
{
-    			ComponentLifecycle component = entry.getValue();
-    			String implClassName = ComponentContext.getTargetClass(component).getName();
+            }
+        }
+
+        // starting phase
+        avoidMap.clear();
+        for (int i = 0; i < ComponentLifecycle.MAX_RUN_LEVELS; i++) {
+            for (Map.Entry<String, ComponentLifecycle> entry : classifiedComponents[i].entrySet())
{
+                ComponentLifecycle component = entry.getValue();
+                String implClassName = ComponentContext.getTargetClass(component).getName();
                 s_logger.info("Starting " + implClassName);
-                
-                if(avoidMap.containsKey(implClassName)) {
+
+                if (avoidMap.containsKey(implClassName)) {
                     s_logger.info("Skip configuration of " + implClassName + " as it is already
configured");
-                	continue;
+                    continue;
                 }
-                
+
                 try {
-					component.start();
-					
-					if(getTargetObject(component) instanceof ManagementBean)
-						registerMBean((ManagementBean)getTargetObject(component));
-				} catch (Exception e) {
-					s_logger.error("Unhandled exception", e);
-					throw new RuntimeException("Unable to start " + implClassName, e);
-				}
-                
+                    component.start();
+
+                    if (getTargetObject(component) instanceof ManagementBean)
+                        registerMBean((ManagementBean)getTargetObject(component));
+                } catch (Exception e) {
+                    s_logger.error("Unhandled exception", e);
+                    throw new RuntimeException("Unable to start " + implClassName, e);
+                }
+
                 avoidMap.put(implClassName, implClassName);
-    		}
-    	}
+            }
+        }
     }
-    
+
     static void registerMBean(ManagementBean mbean) {
         try {
             JmxUtil.registerMBean(mbean);
@@ -160,32 +158,32 @@ public class ComponentContext implements ApplicationContextAware {
         }
         s_logger.info("Registered MBean: " + mbean.getName());
     }
-    
+
     public static <T> T getComponent(String name) {
-        assert(s_appContext != null);
+        assert (s_appContext != null);
         return (T)s_appContext.getBean(name);
     }
 
     public static <T> T getComponent(Class<T> beanType) {
-        assert(s_appContext != null);
+        assert (s_appContext != null);
         Map<String, T> matchedTypes = getComponentsOfType(beanType);
-        if(matchedTypes.size() > 0) {
-            for(Map.Entry<String, T> entry : matchedTypes.entrySet()) {
+        if (matchedTypes.size() > 0) {
+            for (Map.Entry<String, T> entry : matchedTypes.entrySet()) {
                 Primary primary = getTargetClass(entry.getValue()).getAnnotation(Primary.class);
-                if(primary != null)
+                if (primary != null)
                     return entry.getValue();
             }
 
-            if(matchedTypes.size() > 1) {
+            if (matchedTypes.size() > 1) {
                 s_logger.warn("Unable to uniquely locate bean type " + beanType.getName());
-                for(Map.Entry<String, T> entry : matchedTypes.entrySet()) {
+                for (Map.Entry<String, T> entry : matchedTypes.entrySet()) {
                     s_logger.warn("Candidate " + getTargetClass(entry.getValue()).getName());
                 }
             }
 
             return (T)matchedTypes.values().toArray()[0];
         }
-        
+
         throw new NoSuchBeanDefinitionException(beanType.getName());
     }
 
@@ -194,10 +192,10 @@ public class ComponentContext implements ApplicationContextAware {
     }
 
     public static Class<?> getTargetClass(Object instance) {
-        while(instance instanceof Advised) {
+        while (instance instanceof Advised) {
             try {
                 instance = ((Advised)instance).getTargetSource().getTarget();
-            } catch(Exception e) {
+            } catch (Exception e) {
                 return instance.getClass();
             }
         }
@@ -205,7 +203,7 @@ public class ComponentContext implements ApplicationContextAware {
     }
 
     public static <T> T getTargetObject(Object instance) {
-        while(instance instanceof Advised) {
+        while (instance instanceof Advised) {
             try {
                 instance = ((Advised)instance).getTargetSource().getTarget();
             } catch (Exception e) {
@@ -215,24 +213,24 @@ public class ComponentContext implements ApplicationContextAware {
 
         return (T)instance;
     }
-    
+
     public static <T> T inject(Class<T> clz) {
         T instance;
-		try {
-			instance = clz.newInstance();
-	        return inject(instance);
-		} catch (InstantiationException e) {
-			s_logger.error("Unhandled InstantiationException", e);
-			throw new RuntimeException("Unable to instantiate object of class " + clz.getName() +
", make sure it has public constructor");
-		} catch (IllegalAccessException e) {
-			s_logger.error("Unhandled IllegalAccessException", e);
-			throw new RuntimeException("Unable to instantiate object of class " + clz.getName() +
", make sure it has public constructor");
-		}
+        try {
+            instance = clz.newInstance();
+            return inject(instance);
+        } catch (InstantiationException e) {
+            s_logger.error("Unhandled InstantiationException", e);
+            throw new RuntimeException("Unable to instantiate object of class " + clz.getName()
+ ", make sure it has public constructor");
+        } catch (IllegalAccessException e) {
+            s_logger.error("Unhandled IllegalAccessException", e);
+            throw new RuntimeException("Unable to instantiate object of class " + clz.getName()
+ ", make sure it has public constructor");
+        }
     }
 
     public static <T> T inject(Object instance) {
         // autowire dynamically loaded object
-        AutowireCapableBeanFactory  beanFactory = s_appContext.getAutowireCapableBeanFactory();
+        AutowireCapableBeanFactory beanFactory = s_appContext.getAutowireCapableBeanFactory();
         beanFactory.autowireBean(instance);
         return (T)instance;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8e79c30/utils/src/com/cloud/utils/component/ComponentLifecycleBase.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/ComponentLifecycleBase.java b/utils/src/com/cloud/utils/component/ComponentLifecycleBase.java
index 9ce64fa..2a4325f 100644
--- a/utils/src/com/cloud/utils/component/ComponentLifecycleBase.java
+++ b/utils/src/com/cloud/utils/component/ComponentLifecycleBase.java
@@ -20,6 +20,7 @@ import java.lang.reflect.Field;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.annotation.PostConstruct;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
@@ -27,70 +28,74 @@ import com.cloud.utils.ReflectUtil;
 
 public class ComponentLifecycleBase implements ComponentLifecycle {
 
-	protected String _name;
-	protected int _runLevel;
+    protected String _name;
+    protected int _runLevel;
     protected Map<String, Object> _configParams = new HashMap<String, Object>();
     @Inject
     protected ConfigInjector _configInjector;
-	
-	public ComponentLifecycleBase() {
-		_name = this.getClass().getSimpleName();
-		_runLevel = RUN_LEVEL_COMPONENT;
-
-        for (Field field : ReflectUtil.getAllFieldsForClass(this.getClass(), Object.class))
{
-            InjectConfig config = field.getAnnotation(InjectConfig.class);
-            if (config != null) {
-                field.setAccessible(true);
-                _configInjector.inject(field, this, config.key());
+
+    public ComponentLifecycleBase() {
+        _name = this.getClass().getSimpleName();
+        _runLevel = RUN_LEVEL_COMPONENT;
+    }
+
+    @PostConstruct
+    protected void injectConfigs() {
+        if (_configInjector != null) {
+            for (Field field : ReflectUtil.getAllFieldsForClass(this.getClass(), Object.class))
{
+                InjectConfig config = field.getAnnotation(InjectConfig.class);
+                if (config != null) {
+                    field.setAccessible(true);
+                    _configInjector.inject(field, this, config.key());
+                }
             }
         }
-	}
-	
-	@Override
-	public String getName() {
-		return _name;
-	}
-
-	@Override
-	public void setName(String name) {
-		_name = name;
-	}
-
-	@Override
-	public void setConfigParams(Map<String, Object> params) {
-		_configParams = params;
-	}
-
-	@Override
-	public Map<String, Object> getConfigParams() {
-		return _configParams;
-	}
-
-	@Override
-	public int getRunLevel() {
-		return _runLevel;
-	}
-
-	@Override
-	public void setRunLevel(int level) {
-		_runLevel = level;
-	}
-
-	@Override
-	public boolean configure(String name, Map<String, Object> params)
-			throws ConfigurationException {
+    }
+
+    @Override
+    public String getName() {
+        return _name;
+    }
+
+    @Override
+    public void setName(String name) {
         _name = name;
+    }
+
+    @Override
+    public void setConfigParams(Map<String, Object> params) {
         _configParams = params;
-		return true;
-	}
-
-	@Override
-	public boolean start() {
-		return true;
-	}
-
-	@Override
-	public boolean stop() {
-		return true;
-	}
+    }
+
+    @Override
+    public Map<String, Object> getConfigParams() {
+        return _configParams;
+    }
+
+    @Override
+    public int getRunLevel() {
+        return _runLevel;
+    }
+
+    @Override
+    public void setRunLevel(int level) {
+        _runLevel = level;
+    }
+
+    @Override
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException
{
+        _name = name;
+        _configParams = params;
+        return true;
+    }
+
+    @Override
+    public boolean start() {
+        return true;
+    }
+
+    @Override
+    public boolean stop() {
+        return true;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b8e79c30/utils/src/com/cloud/utils/component/ManagerBase.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/ManagerBase.java b/utils/src/com/cloud/utils/component/ManagerBase.java
index 1908f4e..2e471ae 100644
--- a/utils/src/com/cloud/utils/component/ManagerBase.java
+++ b/utils/src/com/cloud/utils/component/ManagerBase.java
@@ -17,8 +17,9 @@
 package com.cloud.utils.component;
 
 public class ManagerBase extends ComponentLifecycleBase implements ComponentMethodInterceptable
{
-	public ManagerBase() {
-		// set default run level for manager components
-		setRunLevel(ComponentLifecycle.RUN_LEVEL_COMPONENT_BOOTSTRAP);
-	}
+    public ManagerBase() {
+        super();
+        // set default run level for manager components
+        setRunLevel(ComponentLifecycle.RUN_LEVEL_COMPONENT_BOOTSTRAP);
+    }
 }


Mime
View raw message