http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/server/test/com/cloud/async/TestSyncQueueManager.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/async/TestSyncQueueManager.java 
b/server/test/com/cloud/async/TestSyncQueueManager.java
index 2bbf7bc..32b7dde 100644
--- a/server/test/com/cloud/async/TestSyncQueueManager.java
+++ b/server/test/com/cloud/async/TestSyncQueueManager.java
@@ -18,194 +18,187 @@ package com.cloud.async;
 
 import java.util.List;
 
+import javax.inject.Inject;
+
+import junit.framework.TestCase;
+
 import org.apache.log4j.Logger;
 import org.junit.Assert;
 
-import com.cloud.utils.component.ComponentLocator;
-import com.cloud.utils.testcase.ComponentSetup;
-import com.cloud.utils.testcase.ComponentTestCase;
 
-@ComponentSetup(managerName="management-server", 
setupXml="sync-queue-component.xml")
-public class TestSyncQueueManager extends ComponentTestCase {
+public class TestSyncQueueManager extends TestCase {
     public static final Logger s_logger = 
Logger.getLogger(TestSyncQueueManager.class.getName());
-    
+
     private volatile int count = 0;
     private volatile long expectingCurrent = 1;
+    @Inject SyncQueueManager mgr;
+
+    public void leftOverItems() {
+
+        List<SyncQueueItemVO> l = mgr.getActiveQueueItems(1L, false);
+        if(l != null && l.size() > 0) {
+            for(SyncQueueItemVO item : l) {
+                s_logger.info("Left over item: " + item.toString());
+                mgr.purgeItem(item.getId());
+            }
+        }
+    }
+
+    public void dequeueFromOneQueue() {
+        final int totalRuns = 5000;
+        final SyncQueueVO queue = mgr.queue("vm_instance", 1L, "Async-job", 1, 
1);
+        for(int i = 1; i < totalRuns; i++)
+            mgr.queue("vm_instance", 1L, "Async-job", i+1, 1);
+
+        count = 0;
+        expectingCurrent = 1;
+        Thread thread1 = new Thread(new Runnable() {
+            @Override
+            public void run() {
+                while(count < totalRuns) {
+                    SyncQueueItemVO item = mgr.dequeueFromOne(queue.getId(), 
1L);
+                    if(item != null) {
+                        s_logger.info("Thread 1 process item: " + 
item.toString());
+
+                        Assert.assertEquals(expectingCurrent, 
item.getContentId().longValue());
+                        expectingCurrent++;
+                        count++;
+
+                        mgr.purgeItem(item.getId());
+                    }
+                    try {
+                        Thread.sleep(getRandomMilliseconds(1, 10));
+                    } catch (InterruptedException e) {
+                    }
+                }
+            }
+        }
+                );
+
+        Thread thread2 = new Thread(new Runnable() {
+            @Override
+            public void run() {
+                while(count < totalRuns) {
+                    SyncQueueItemVO item = mgr.dequeueFromOne(queue.getId(), 
1L);
+                    if(item != null) {
+                        s_logger.info("Thread 2 process item: " + 
item.toString());
+
+                        Assert.assertEquals(expectingCurrent, 
item.getContentId().longValue());
+                        expectingCurrent++;
+                        count++;
+                        mgr.purgeItem(item.getId());
+                    }
+
+                    try {
+                        Thread.sleep(getRandomMilliseconds(1, 10));
+                    } catch (InterruptedException e) {
+                    }
+                }
+            }
+        }
+                ); 
+
+        thread1.start();
+        thread2.start();
+        try {
+            thread1.join();
+        } catch (InterruptedException e) {
+        }
+        try {
+            thread2.join();
+        } catch (InterruptedException e) {
+        }
+
+        Assert.assertEquals(totalRuns, count);
+    }
+
+    public void dequeueFromAnyQueue() {
+        // simulate 30 queues
+        final int queues = 30;
+        final int totalRuns = 100;
+        final int itemsPerRun = 20;
+        for(int q = 1; q <= queues; q++)
+            for(int i = 0; i < totalRuns; i++)
+                mgr.queue("vm_instance", q, "Async-job", i+1, 1);
+
+        count = 0;
+        Thread thread1 = new Thread(new Runnable() {
+            @Override
+            public void run() {
+                while(count < totalRuns*queues) {
+                    List<SyncQueueItemVO> l = mgr.dequeueFromAny(1L, 
itemsPerRun);
+                    if(l != null && l.size() > 0) {
+                        s_logger.info("Thread 1 get " + l.size() + " dequeued 
items");
+
+                        for(SyncQueueItemVO item : l) {
+                            s_logger.info("Thread 1 process item: " + 
item.toString());
+                            count++;
+
+                            mgr.purgeItem(item.getId());
+                        }
+                    }
+                    try {
+                        Thread.sleep(getRandomMilliseconds(1, 10));
+                    } catch (InterruptedException e) {
+                    }
+                }
+            }
+        }
+                );
+
+        Thread thread2 = new Thread(new Runnable() {
+            @Override
+            public void run() {
+                while(count < totalRuns*queues) {
+                    List<SyncQueueItemVO> l = mgr.dequeueFromAny(1L, 
itemsPerRun);
+                    if(l != null && l.size() > 0) {
+                        s_logger.info("Thread 2 get " + l.size() + " dequeued 
items");
+
+                        for(SyncQueueItemVO item : l) {
+                            s_logger.info("Thread 2 process item: " + 
item.toString());
+                            count++;
+                            mgr.purgeItem(item.getId());
+                        }
+                    }
+
+                    try {
+                        Thread.sleep(getRandomMilliseconds(1, 10));
+                    } catch (InterruptedException e) {
+                    }
+                }
+            }
+        }
+                ); 
+
+        thread1.start();
+        thread2.start();
+        try {
+            thread1.join();
+        } catch (InterruptedException e) {
+        }
+        try {
+            thread2.join();
+        } catch (InterruptedException e) {
+        }
+        Assert.assertEquals(queues*totalRuns, count);
+    }
+
+    public void testPopulateQueueData() {
+        final int queues = 30000;
+        final int totalRuns = 100;
+
+        for(int q = 1; q <= queues; q++)
+            for(int i = 0; i < totalRuns; i++)
+                mgr.queue("vm_instance", q, "Async-job", i+1, 1);
+    }
 
-       public void leftOverItems() {
-               SyncQueueManager mgr = 
ComponentLocator.getCurrentLocator().getManager(
-                       SyncQueueManager.class);
-
-               List<SyncQueueItemVO> l = mgr.getActiveQueueItems(1L, false);
-               if(l != null && l.size() > 0) {
-                       for(SyncQueueItemVO item : l) {
-                               s_logger.info("Left over item: " + 
item.toString());
-                               mgr.purgeItem(item.getId());
-                       }
-               }
-       }
-
-       public void dequeueFromOneQueue() {
-               final SyncQueueManager mgr = 
ComponentLocator.getCurrentLocator().getManager(
-                       SyncQueueManager.class);
-               
-               final int totalRuns = 5000;
-               final SyncQueueVO queue = mgr.queue("vm_instance", 1L, 
"Async-job", 1, 1);
-               for(int i = 1; i < totalRuns; i++)
-                       mgr.queue("vm_instance", 1L, "Async-job", i+1, 1);
-               
-               count = 0;
-               expectingCurrent = 1;
-               Thread thread1 = new Thread(new Runnable() {
-                               public void run() {
-                                       while(count < totalRuns) {
-                                               SyncQueueItemVO item = 
mgr.dequeueFromOne(queue.getId(), 1L);
-                                               if(item != null) {
-                                                       s_logger.info("Thread 1 
process item: " + item.toString());
-                                                       
-                                                       
Assert.assertEquals(expectingCurrent, item.getContentId().longValue());
-                                                       expectingCurrent++;
-                                                       count++;
-                                                       
-                                                       
mgr.purgeItem(item.getId());
-                                               }
-                                               try {
-                                                       
Thread.sleep(getRandomMilliseconds(1, 10));
-                                               } catch (InterruptedException 
e) {
-                                               }
-                                       }
-                               }
-                       }
-               );
-               
-               Thread thread2 = new Thread(new Runnable() {
-                       public void run() {
-                                       while(count < totalRuns) {
-                                               SyncQueueItemVO item = 
mgr.dequeueFromOne(queue.getId(), 1L);
-                                               if(item != null) {
-                                                       s_logger.info("Thread 2 
process item: " + item.toString());
-                                                       
-                                                       
Assert.assertEquals(expectingCurrent, item.getContentId().longValue());
-                                                       expectingCurrent++;
-                                                       count++;
-                                                       
mgr.purgeItem(item.getId());
-                                               }
-                                               
-                                               try {
-                                                       
Thread.sleep(getRandomMilliseconds(1, 10));
-                                               } catch (InterruptedException 
e) {
-                                               }
-                                       }
-                               }
-                       }
-               ); 
-               
-               thread1.start();
-               thread2.start();
-               try {
-                       thread1.join();
-               } catch (InterruptedException e) {
-               }
-               try {
-                       thread2.join();
-               } catch (InterruptedException e) {
-               }
-               
-               Assert.assertEquals(totalRuns, count);
-       }
-       
-       public void dequeueFromAnyQueue() {
-               final SyncQueueManager mgr = 
ComponentLocator.getCurrentLocator().getManager(
-                       SyncQueueManager.class);
-
-               // simulate 30 queues
-               final int queues = 30;
-               final int totalRuns = 100;
-               final int itemsPerRun = 20;
-               for(int q = 1; q <= queues; q++)
-                       for(int i = 0; i < totalRuns; i++)
-                               mgr.queue("vm_instance", q, "Async-job", i+1, 
1);
-               
-               count = 0;
-               Thread thread1 = new Thread(new Runnable() {
-                               public void run() {
-                                       while(count < totalRuns*queues) {
-                                               List<SyncQueueItemVO> l = 
mgr.dequeueFromAny(1L, itemsPerRun);
-                                               if(l != null && l.size() > 0) {
-                                                       s_logger.info("Thread 1 
get " + l.size() + " dequeued items");
-                                                       
-                                                       for(SyncQueueItemVO 
item : l) {
-                                                               
s_logger.info("Thread 1 process item: " + item.toString());
-                                                               count++;
-                                                               
-                                                               
mgr.purgeItem(item.getId());
-                                                       }
-                                               }
-                                               try {
-                                                       
Thread.sleep(getRandomMilliseconds(1, 10));
-                                               } catch (InterruptedException 
e) {
-                                               }
-                                       }
-                               }
-                       }
-               );
-               
-               Thread thread2 = new Thread(new Runnable() {
-                       public void run() {
-                                       while(count < totalRuns*queues) {
-                                               List<SyncQueueItemVO> l = 
mgr.dequeueFromAny(1L, itemsPerRun);
-                                               if(l != null && l.size() > 0) {
-                                                       s_logger.info("Thread 2 
get " + l.size() + " dequeued items");
-                                                       
-                                                       for(SyncQueueItemVO 
item : l) {
-                                                               
s_logger.info("Thread 2 process item: " + item.toString());
-                                                               count++;
-                                                               
mgr.purgeItem(item.getId());
-                                                       }
-                                               }
-                                               
-                                               try {
-                                                       
Thread.sleep(getRandomMilliseconds(1, 10));
-                                               } catch (InterruptedException 
e) {
-                                               }
-                                       }
-                               }
-                       }
-               ); 
-               
-               thread1.start();
-               thread2.start();
-               try {
-                       thread1.join();
-               } catch (InterruptedException e) {
-               }
-               try {
-                       thread2.join();
-               } catch (InterruptedException e) {
-               }
-               Assert.assertEquals(queues*totalRuns, count);
-       }
-       
-       public void testPopulateQueueData() {
-               final int queues = 30000;
-               final int totalRuns = 100;
-               
-               final SyncQueueManager mgr = 
ComponentLocator.getCurrentLocator().getManager(
-                               SyncQueueManager.class);
-               for(int q = 1; q <= queues; q++)
-                       for(int i = 0; i < totalRuns; i++)
-                               mgr.queue("vm_instance", q, "Async-job", i+1, 
1);
-       }
-    
     public void testSyncQueue() {
-        final SyncQueueManager mgr = 
ComponentLocator.getCurrentLocator().getManager(
-                SyncQueueManager.class);
 
         mgr.queue("vm_instance", 1, "Async-job", 1, 1);
         mgr.queue("vm_instance", 1, "Async-job", 2, 1);
         mgr.queue("vm_instance", 1, "Async-job", 3, 1);
         mgr.dequeueFromAny(100L, 1);
-        
+
         List<SyncQueueItemVO> l = mgr.getBlockedQueueItems(100000, false);
         for(SyncQueueItemVO item : l) {
             System.out.println("Blocked item. " + item.getContentType() + "-" 
+ item.getContentId());

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/server/test/com/cloud/cluster/CheckPointManagerTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/cluster/CheckPointManagerTest.java 
b/server/test/com/cloud/cluster/CheckPointManagerTest.java
deleted file mode 100755
index 74b0698..0000000
--- a/server/test/com/cloud/cluster/CheckPointManagerTest.java
+++ /dev/null
@@ -1,390 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.cluster;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.ejb.Local;
-import javax.naming.ConfigurationException;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.junit.After;
-import org.junit.Before;
-
-import com.cloud.agent.Listener;
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-import com.cloud.cluster.dao.StackMaidDao;
-import com.cloud.cluster.dao.StackMaidDaoImpl;
-import com.cloud.configuration.Config;
-import com.cloud.configuration.DefaultInterceptorLibrary;
-import com.cloud.configuration.dao.ConfigurationDaoImpl;
-import com.cloud.exception.AgentUnavailableException;
-import com.cloud.exception.OperationTimedoutException;
-import com.cloud.host.Status.Event;
-import com.cloud.serializer.SerializerHelper;
-import com.cloud.utils.component.ComponentLocator;
-import com.cloud.utils.component.MockComponentLocator;
-import com.cloud.utils.db.Transaction;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-public class CheckPointManagerTest extends TestCase {
-    private final static Logger s_logger = 
Logger.getLogger(CheckPointManagerTest.class);
-    
-    @Override
-    @Before
-    public void setUp() {
-        MockComponentLocator locator = new 
MockComponentLocator("management-server");
-        locator.addDao("StackMaidDao", StackMaidDaoImpl.class);
-        locator.addDao("ConfigurationDao", ConfigurationDaoImpl.class);
-        locator.addManager("ClusterManager", MockClusterManager.class);
-        locator.makeActive(new DefaultInterceptorLibrary());
-        MockMaid.map.clear();
-        s_logger.info("Cleaning up the database");
-        Connection conn = Transaction.getStandaloneConnection();
-        try {
-            conn.setAutoCommit(true);
-            PreparedStatement stmt = conn.prepareStatement("DELETE FROM 
stack_maid");
-            stmt.executeUpdate();
-            stmt.close();
-            conn.close();
-        } catch (SQLException e) {
-            throw new CloudRuntimeException("Unable to setup database", e);
-        }
-    }
-    
-    @Override
-    @After
-    public void tearDown() throws Exception {
-    }
-    
-    public void testCompleteCase() throws Exception {
-        ComponentLocator locator = ComponentLocator.getCurrentLocator();
-        
-        CheckPointManagerImpl taskMgr = 
ComponentLocator.inject(CheckPointManagerImpl.class);
-        assertTrue(taskMgr.configure("TaskManager", new HashMap<String, 
Object>()));
-        assertTrue(taskMgr.start());
-        
-        MockMaid delegate = new MockMaid();
-        delegate.setValue("first");
-        long taskId = taskMgr.pushCheckPoint(delegate);
-        
-        StackMaidDao maidDao = locator.getDao(StackMaidDao.class);
-        CheckPointVO task = maidDao.findById(taskId);
-        
-        assertEquals(task.getDelegate(), MockMaid.class.getName());
-        MockMaid retrieved = 
(MockMaid)SerializerHelper.fromSerializedString(task.getContext()); 
-        assertEquals(retrieved.getValue(), delegate.getValue());
-        
-        delegate.setValue("second");
-        taskMgr.updateCheckPointState(taskId, delegate);
-
-        task = maidDao.findById(taskId);
-        assertEquals(task.getDelegate(), MockMaid.class.getName());
-        retrieved = 
(MockMaid)SerializerHelper.fromSerializedString(task.getContext()); 
-        assertEquals(retrieved.getValue(), delegate.getValue());
-        
-        taskMgr.popCheckPoint(taskId);
-        assertNull(maidDao.findById(taskId));
-    }
-    
-    public void testSimulatedReboot() throws Exception {
-        ComponentLocator locator = ComponentLocator.getCurrentLocator();
-        
-        CheckPointManagerImpl taskMgr = 
ComponentLocator.inject(CheckPointManagerImpl.class);
-        assertTrue(taskMgr.configure("TaskManager", new HashMap<String, 
Object>()));
-        assertTrue(taskMgr.start());
-        
-        MockMaid maid = new MockMaid();
-        maid.setValue("first");
-        long taskId = taskMgr.pushCheckPoint(maid);
-        
-        StackMaidDao maidDao = locator.getDao(StackMaidDao.class);
-        CheckPointVO task = maidDao.findById(taskId);
-        
-        assertEquals(task.getDelegate(), MockMaid.class.getName());
-        MockMaid retrieved = 
(MockMaid)SerializerHelper.fromSerializedString(task.getContext()); 
-        assertEquals(retrieved.getValue(), maid.getValue());
-
-        taskMgr.stop();
-        
-        assertNotNull(MockMaid.map.get(maid.getSeq()));
-        
-        taskMgr = ComponentLocator.inject(CheckPointManagerImpl.class);
-        HashMap<String, Object> params = new HashMap<String, Object>();
-        params.put(Config.TaskCleanupRetryInterval.key(), "1");
-        taskMgr.configure("TaskManager", params);
-        taskMgr.start();
-        
-        int i = 0;
-        while (MockMaid.map.get(maid.getSeq()) != null && i++ < 5) {
-            Thread.sleep(1000);
-        }
-        
-        assertNull(MockMaid.map.get(maid.getSeq()));
-    }
-    
-    public void testTakeover() throws Exception {
-        ComponentLocator locator = ComponentLocator.getCurrentLocator();
-        
-        CheckPointManagerImpl taskMgr = 
ComponentLocator.inject(CheckPointManagerImpl.class);
-        assertTrue(taskMgr.configure("TaskManager", new HashMap<String, 
Object>()));
-        assertTrue(taskMgr.start());
-        
-        MockMaid delegate = new MockMaid();
-        delegate.setValue("first");
-        long taskId = taskMgr.pushCheckPoint(delegate);
-        
-        StackMaidDao maidDao = locator.getDao(StackMaidDao.class);
-        CheckPointVO task = maidDao.findById(taskId);
-        
-        assertEquals(task.getDelegate(), MockMaid.class.getName());
-        MockMaid retrieved = 
(MockMaid)SerializerHelper.fromSerializedString(task.getContext()); 
-        assertEquals(retrieved.getValue(), delegate.getValue());
-
-        Connection conn = Transaction.getStandaloneConnection();
-        try {
-            conn.setAutoCommit(true);
-            PreparedStatement stmt = conn.prepareStatement("update stack_maid 
set msid=? where msid=?");
-            stmt.setLong(1, 1234);
-            stmt.setLong(2, ManagementServerNode.getManagementServerId());
-            stmt.executeUpdate();
-            stmt.close();
-        } finally {
-            conn.close();
-        }
-        
-        MockClusterManager clusterMgr = 
(MockClusterManager)locator.getManager(ClusterManager.class);
-        clusterMgr.triggerTakeover(1234);
-        
-        int i = 0;
-        while (MockMaid.map.get(delegate.getSeq()) != null && i++ < 500) {
-            Thread.sleep(1000);
-        }
-        
-        assertNull(MockMaid.map.get(delegate.getSeq()));
-    }
-    
-    public static class MockMaid implements CleanupMaid {
-        private static int s_seq = 1;
-        public static Map<Integer, MockMaid> map = new 
ConcurrentHashMap<Integer, MockMaid>();
-        
-        int seq;
-        boolean canBeCleanup;
-        String value;
-        
-        protected MockMaid() {
-            canBeCleanup = true;
-            seq = s_seq++;
-            map.put(seq, this);
-        }
-        
-        public int getSeq() {
-            return seq;
-        }
-        
-        public String getValue() {
-            return value;
-        }
-        
-        public void setCanBeCleanup(boolean canBeCleanup) {
-            this.canBeCleanup = canBeCleanup;
-        }
-
-        @Override
-        public int cleanup(CheckPointManager checkPointMgr) {
-            s_logger.debug("Cleanup called for " + seq);
-            map.remove(seq);
-            return canBeCleanup ? 0 : -1;
-        }
-        
-        public void setValue(String value) {
-            this.value = value;
-        }
-        
-        @Override
-        public String getCleanupProcedure() {
-            return "No cleanup necessary";
-        }
-    }
-    
-    @Local(value=ClusterManager.class)
-    public static class MockClusterManager implements ClusterManager {
-        String _name;
-        ClusterManagerListener _listener;
-
-        @Override
-        public boolean configure(String name, Map<String, Object> params) 
throws ConfigurationException {
-            _name = name;
-            return true;
-        }
-
-        @Override
-        public boolean start() {
-            return true;
-        }
-
-        @Override
-        public boolean stop() {
-            return true;
-        }
-
-        @Override
-        public String getName() {
-            return _name;
-        }
-
-        @Override
-        public void OnReceiveClusterServicePdu(ClusterServicePdu pdu) {
-            throw new CloudRuntimeException("Not implemented");
-        }
-        
-        @Override
-        public Answer[] execute(String strPeer, long agentId, Command[] cmds, 
boolean stopOnError) {
-            throw new UnsupportedOperationException("Not implemented");
-        }
-
-        @Override
-        public Answer[] sendToAgent(Long hostId, Command[] cmds, boolean 
stopOnError) throws AgentUnavailableException, OperationTimedoutException {
-            throw new UnsupportedOperationException("Not implemented");
-        }
-
-        @Override
-        public boolean executeAgentUserRequest(long agentId, Event event) 
throws AgentUnavailableException {
-            throw new UnsupportedOperationException("Not implemented");
-        }
-
-        @Override
-        public Boolean propagateAgentEvent(long agentId, Event event) throws 
AgentUnavailableException {
-            throw new UnsupportedOperationException("Not implemented");
-        }
-
-        @Override
-        public int getHeartbeatThreshold() {
-            throw new UnsupportedOperationException("Not implemented");
-        }
-
-        @Override
-        public long getManagementNodeId() {
-            return ManagementServerNode.getManagementServerId();
-        }
-
-        @Override
-        public boolean isManagementNodeAlive(long msid) {
-            throw new UnsupportedOperationException("Not implemented");
-        }
-
-        @Override
-        public boolean pingManagementNode(long msid) {
-            throw new UnsupportedOperationException("Not implemented");
-        }
-
-        @Override
-        public long getCurrentRunId() {
-            throw new UnsupportedOperationException("Not implemented");
-        }
-
-        @Override
-        public String getSelfPeerName() {
-            throw new UnsupportedOperationException("Not implemented");
-        }
-
-        @Override
-        public String getSelfNodeIP() {
-            throw new UnsupportedOperationException("Not implemented");
-        }
-
-        @Override
-        public String getPeerName(long agentHostId) {
-            throw new UnsupportedOperationException("Not implemented");
-        }
-
-        @Override
-        public void registerListener(ClusterManagerListener listener) {
-            _listener = listener;
-        }
-
-        @Override
-        public void unregisterListener(ClusterManagerListener listener) {
-            throw new UnsupportedOperationException("Not implemented");
-        }
-
-        @Override
-        public ManagementServerHostVO getPeer(String peerName) {
-            throw new UnsupportedOperationException("Not implemented");
-        }
-
-        @Override
-        public void broadcast(long agentId, Command[] cmds) {
-            throw new UnsupportedOperationException("Not implemented");
-        }
-        
-        public void triggerTakeover(long msId) {
-            ManagementServerHostVO node = new ManagementServerHostVO();
-            node.setMsid(msId);
-            
-            List<ManagementServerHostVO> lst = new 
ArrayList<ManagementServerHostVO>();
-            lst.add(node);
-            
-            _listener.onManagementNodeLeft(lst, 
ManagementServerNode.getManagementServerId());
-        }
-        
-        protected MockClusterManager() {
-        }
-        
-        @Override
-        public boolean rebalanceAgent(long agentId, Event event, long 
currentOwnerId, long futureOwnerId) throws AgentUnavailableException, 
OperationTimedoutException {
-            return false;
-        }
-        
-        @Override
-        public boolean isAgentRebalanceEnabled() {
-            return false;
-        }
-
-               @Override
-        public Boolean propagateResourceEvent(long agentId, 
com.cloud.resource.ResourceState.Event event) throws AgentUnavailableException {
-               // TODO Auto-generated method stub
-               return null;
-        }
-
-               @Override
-        public boolean executeResourceUserRequest(long hostId, 
com.cloud.resource.ResourceState.Event event) throws AgentUnavailableException {
-               // TODO Auto-generated method stub
-               return false;
-        }
-
-        /* (non-Javadoc)
-         * @see 
com.cloud.cluster.ClusterManager#executeAsync(java.lang.String, long, 
com.cloud.agent.api.Command[], boolean)
-         */
-        @Override
-        public void executeAsync(String strPeer, long agentId, Command[] cmds, 
boolean stopOnError) {
-            // TODO Auto-generated method stub
-            
-        }
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/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 e7be829..7b75993 100644
--- a/utils/src/com/cloud/utils/component/AdapterBase.java
+++ b/utils/src/com/cloud/utils/component/AdapterBase.java
@@ -16,6 +16,7 @@
 // under the License.
 package com.cloud.utils.component;
 
+import java.util.List;
 import java.util.Map;
 
 import javax.naming.ConfigurationException;
@@ -45,4 +46,12 @@ public class AdapterBase implements Adapter {
         return true;
     }
 
+    public static <T extends Adapter> T getAdapterByName(List<T> adapters, 
String name) {
+       for(T adapter : adapters) {
+               if(adapter.getName().equals(name))
+                       return adapter;
+       }
+       return null;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/utils/src/com/cloud/utils/component/Adapters.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/Adapters.java 
b/utils/src/com/cloud/utils/component/Adapters.java
deleted file mode 100755
index 2a2203f..0000000
--- a/utils/src/com/cloud/utils/component/Adapters.java
+++ /dev/null
@@ -1,93 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// the License.  You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.utils.component;
-
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.cloud.utils.EnumerationImpl;
-import com.cloud.utils.component.LegacyComponentLocator.ComponentInfo;
-
-/**
- * the iterator even during dynamic reloading.
- * 
- **/
-public class Adapters<T> implements Iterable<T> {
-    protected Map<String, T> _map; 
-    protected List<ComponentInfo<Adapter>> _infos;
-    
-    protected String      _name;
-
-    public Adapters(String name, List<ComponentInfo<Adapter>> adapters) {
-        _name = name;
-        set(adapters);
-    }
-
-    /**
-     * Get the adapter list name.
-     * 
-     * @return the name of the list of adapters.
-     */
-    public String getName() {
-        return _name;
-    }
-
-    public Enumeration<T> enumeration() {
-        return new EnumerationImpl<T>(_map.values().iterator());
-    }
-    
-    @Override
-    public Iterator<T> iterator() {
-        return new EnumerationImpl<T>(_map.values().iterator());
-    }
-
-    protected Collection<T> get() {
-        return _map.values();
-    }
-    
-    protected void set(List<ComponentInfo<Adapter>> adapters) {
-        HashMap<String, T> map = new LinkedHashMap<String, T>(adapters.size());
-        for (ComponentInfo<Adapter> adapter : adapters) {
-            @SuppressWarnings("unchecked")
-            T t = (T)adapter.instance;
-            map.put(adapter.getName(), t);
-        }
-        this._map = map;
-        this._infos = adapters;
-    }
-    
-    public T get(String name) {
-        return _map.get(name);
-    }
-
-    public boolean isSet() {
-        return _map.size() != 0;
-    }
-    
-    public static <T extends Adapter> T getAdapterByName(List<T> adapters, 
String name) {
-       for(T adapter : adapters) {
-               if(adapter.getName().equals(name))
-                       return adapter;
-       }
-       return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/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 ce46423..3fffd17 100644
--- a/utils/src/com/cloud/utils/component/ComponentContext.java
+++ b/utils/src/com/cloud/utils/component/ComponentContext.java
@@ -54,12 +54,12 @@ public class ComponentContext implements 
ApplicationContextAware {
         return s_appContext;  
     }  
     
-    public static <T> T getCompanent(String name) {
+    public static <T> T getComponent(String name) {
        assert(s_appContext != null);
        return (T)s_appContext.getBean(name);
     }
     
-    public static <T> T getCompanent(Class<T> beanType) {
+    public static <T> T getComponent(Class<T> beanType) {
        assert(s_appContext != null);
        try {
                return (T)s_appContext.getBean(beanType);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/utils/src/com/cloud/utils/component/ComponentInject.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/ComponentInject.java 
b/utils/src/com/cloud/utils/component/ComponentInject.java
deleted file mode 100644
index c88cd3f..0000000
--- a/utils/src/com/cloud/utils/component/ComponentInject.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.cloud.utils.component;
-
-import javax.inject.Inject;
-
-import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ComponentInject {
-       
-       private static AutowireCapableBeanFactory beanFactory;
-       @SuppressWarnings("unused")
-       @Inject
-       private void setbeanFactory(AutowireCapableBeanFactory bf) {
-               ComponentInject.beanFactory = bf;
-       }
-       
-       public static <T> T inject(Class<T> clazz) {
-               return beanFactory.createBean(clazz);
-       }
-       
-       public static <T> T inject(T obj) {
-               beanFactory.autowireBean(obj);
-               beanFactory.initializeBean(obj, null);
-               return obj;
-       }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/utils/src/com/cloud/utils/component/ComponentLibrary.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/ComponentLibrary.java 
b/utils/src/com/cloud/utils/component/ComponentLibrary.java
deleted file mode 100755
index 52c4703..0000000
--- a/utils/src/com/cloud/utils/component/ComponentLibrary.java
+++ /dev/null
@@ -1,56 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// the License.  You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.utils.component;
-
-import java.util.List;
-import java.util.Map;
-
-import com.cloud.utils.component.LegacyComponentLocator.ComponentInfo;
-import com.cloud.utils.db.GenericDao;
-
-/**
- * ComponentLibrary specifies the implementation classes that a server needs
- * attribute of the server element within components.xml.  ComponentLocator
- * first loads the implementations specified here, then, it loads the 
- * implementations from components.xml.  If an interface is specified in both
- * within the components.xml overrides the one within ComponentLibrary.
- *
- */
-public interface ComponentLibrary {    
-    /**
-     * @return all of the daos
-     */
-    Map<String, ComponentInfo<GenericDao<?,?>>> getDaos();
-    
-    /**
-     * @return all of the Managers
-     */
-    Map<String, ComponentInfo<Manager>> getManagers();
-    
-    /**
-     * @return all of the adapters
-     */
-    Map<String, List<ComponentInfo<Adapter>>> getAdapters();
-    
-    Map<Class<?>, Class<?>> getFactories();
-    
-    /**
-     * @return all the services
-     * 
-     */
-    Map<String, ComponentInfo<PluggableService>> getPluggableServices();
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/utils/src/com/cloud/utils/component/ComponentLibraryBase.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/ComponentLibraryBase.java 
b/utils/src/com/cloud/utils/component/ComponentLibraryBase.java
deleted file mode 100644
index 58649e4..0000000
--- a/utils/src/com/cloud/utils/component/ComponentLibraryBase.java
+++ /dev/null
@@ -1,99 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// the License.  You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.utils.component;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.cloud.utils.Pair;
-import com.cloud.utils.component.LegacyComponentLocator.ComponentInfo;
-import com.cloud.utils.db.GenericDao;
-
-public abstract class ComponentLibraryBase implements ComponentLibrary {
-    
-    protected final Map<String, ComponentInfo<GenericDao<?, ? extends 
Serializable>>> _daos = new LinkedHashMap<String, ComponentInfo<GenericDao<?, ? 
extends Serializable>>>();
-
-    protected ComponentInfo<? extends GenericDao<?, ? extends Serializable>> 
addDao(String name, Class<? extends GenericDao<?, ? extends Serializable>> 
clazz) {
-        return addDao(name, clazz, new ArrayList<Pair<String, Object>>(), 
true);
-    }
-
-    protected ComponentInfo<? extends GenericDao<?, ? extends Serializable>> 
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);
-        }
-        return componentInfo;
-    }
-
-    protected Map<String, ComponentInfo<Manager>> _managers = new 
LinkedHashMap<String, ComponentInfo<Manager>>();
-    protected Map<String, List<ComponentInfo<Adapter>>> _adapters = new 
LinkedHashMap<String, List<ComponentInfo<Adapter>>>();
-    protected Map<String, ComponentInfo<PluggableService>> _pluggableServices 
= new LinkedHashMap<String, ComponentInfo<PluggableService>>();
-
-    protected ComponentInfo<Manager> addManager(String name, Class<? extends 
Manager> clazz, List<Pair<String, Object>> params, boolean singleton) {
-        ComponentInfo<Manager> info = new ComponentInfo<Manager>(name, clazz, 
params, singleton);
-        for (String key : info.getKeys()) {
-            _managers.put(key, info);
-        }
-        return info;
-    }
-    
-    protected ComponentInfo<Manager> addManager(String name, Class<? extends 
Manager> clazz) {
-        return addManager(name, clazz, new ArrayList<Pair<String, Object>>(), 
true);
-    }
-    
-    protected <T> List<ComponentInfo<Adapter>> 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);
-        return lst;
-    }
-    
-    protected <T> void addAdapter(Class<T> interphace, String name, Class<? 
extends T> adapterClass) {
-       List<ComponentInfo<Adapter>> lst = _adapters.get(interphace.getName());
-       if (lst == null) {
-               addOneAdapter(interphace, name, adapterClass);
-       } else {
-               @SuppressWarnings("unchecked")
-               Class<? extends Adapter> clazz = (Class<? extends 
Adapter>)adapterClass;
-               lst.add(new ComponentInfo<Adapter>(name, clazz));
-       }
-    }
-    
-    protected <T> ComponentInfo<Adapter> addOneAdapter(Class<T> interphace, 
String name, Class<? extends T> adapterClass) {
-        List<Pair<String, Class<? extends T>>> adapters = new 
ArrayList<Pair<String, Class<? extends T>>>();
-        adapters.add(new Pair<String, Class<? extends T>>(name, adapterClass));
-        return addAdapterChain(interphace, adapters).get(0);
-    }
-    
-
-    protected <T> ComponentInfo<PluggableService> addService(String name, 
Class<T> serviceInterphace, Class<? extends PluggableService> clazz, 
List<Pair<String, Object>> params, boolean singleton) {
-        ComponentInfo<PluggableService> info = new 
ComponentInfo<PluggableService>(name, clazz, params, singleton);
-        _pluggableServices.put(serviceInterphace.getName(), info);
-        return info;
-    }
-    
-    protected <T> ComponentInfo<PluggableService> addService(String name, 
Class<T> serviceInterphace, Class<? extends PluggableService> clazz) {
-        return addService(name, serviceInterphace, clazz, new 
ArrayList<Pair<String, Object>>(), true);
-    }
- }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/utils/src/com/cloud/utils/component/ComponentLocator.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/ComponentLocator.java 
b/utils/src/com/cloud/utils/component/ComponentLocator.java
deleted file mode 100644
index d8d6e63..0000000
--- a/utils/src/com/cloud/utils/component/ComponentLocator.java
+++ /dev/null
@@ -1,58 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// the License.  You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.utils.component;
-
-import java.io.Serializable;
-
-import org.springframework.stereotype.Component;
-
-import com.cloud.utils.db.GenericDao;
-
-@Component
-public class ComponentLocator {
-    public static ComponentLocator getCurrentLocator() {
-       return ComponentContext.getCompanent(ComponentLocator.class);
-    }
-    
-    public static ComponentLocator getLocator(String server) {
-       return ComponentContext.getCompanent(ComponentLocator.class);
-    }
-    
-    public static ComponentLocator getLocator(String server, String 
configFileName, String log4jFilename) {
-        return ComponentContext.getCompanent(ComponentLocator.class);
-    }
-    
-    public static Object getComponent(String componentName) {
-       return ComponentContext.getCompanent(componentName);
-    }
-    
-    public <T extends GenericDao<?, ? extends Serializable>> T getDao(Class<T> 
clazz) {
-        return ComponentContext.getCompanent(clazz);
-    }
-    
-    public <T> T getManager(Class<T> clazz) {
-        return ComponentContext.getCompanent(clazz);
-    }
-    
-    public <T> T getPluggableService(Class<T> clazz) {
-        return ComponentContext.getCompanent(clazz);
-    }
-    
-    public static <T> T inject(Class<T> clazz) {
-       return ComponentContext.inject(clazz);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/utils/src/com/cloud/utils/component/ComponentLocatorMBean.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/ComponentLocatorMBean.java 
b/utils/src/com/cloud/utils/component/ComponentLocatorMBean.java
deleted file mode 100755
index 125e92a..0000000
--- a/utils/src/com/cloud/utils/component/ComponentLocatorMBean.java
+++ /dev/null
@@ -1,43 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// the License.  You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.utils.component;
-
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import com.cloud.utils.mgmt.ManagementBean;
-
-public interface ComponentLocatorMBean extends ManagementBean {
-
-    /**
-     * @return the list of adapters accessible by this component locator.
-     **/
-    Map<String, List<String>> getAdapterNames();
-
-    /**
-     * @return the list of managers accessible by this component locator.
-     **/
-    Collection<String> getManagerNames();
-    
-    /**
-     * @return the list of DAOs accessible by this component locator.
-     */
-    Collection<String> getDaoNames();
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f40e7b75/utils/src/com/cloud/utils/component/Inject.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/component/Inject.java 
b/utils/src/com/cloud/utils/component/Inject.java
deleted file mode 100644
index 50c890d..0000000
--- a/utils/src/com/cloud/utils/component/Inject.java
+++ /dev/null
@@ -1,30 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// the License.  You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.utils.component;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-@Target(FIELD)
-@Retention(RUNTIME)
-public @interface Inject {
-    Class<? extends Adapter> adapter() default Adapter.class;
-}
-

Reply via email to