incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject [2/2] git commit: Fix a few Spring bootstrap issues
Date Fri, 28 Dec 2012 01:47:02 GMT
Updated Branches:
  refs/heads/javelin 9de3a1fae -> 259e6d5f7


Fix a few Spring bootstrap issues


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/259e6d5f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/259e6d5f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/259e6d5f

Branch: refs/heads/javelin
Commit: 259e6d5f74f97ddc28d66966f3a94ab524b92bb9
Parents: 9de3a1f
Author: Kelven Yang <kelveny@gmail.com>
Authored: Thu Dec 27 17:46:25 2012 -0800
Committer: Kelven Yang <kelveny@gmail.com>
Committed: Thu Dec 27 17:46:52 2012 -0800

----------------------------------------------------------------------
 .../cloudstack/storage/test/volumeServiceTest.java |    4 +-
 .../cloudstack/storage/volume/db/VolumeDao.java    |   82 ---
 .../cloudstack/storage/volume/db/VolumeDao2.java   |   82 +++
 .../storage/volume/db/VolumeDao2Impl.java          |  439 +++++++++++++++
 .../storage/volume/db/VolumeDaoImpl.java           |  439 ---------------
 .../storage/datastore/DefaultPrimaryDataStore.java |    4 +-
 .../storage/volume/VolumeManagerImpl.java          |    4 +-
 .../cloudstack/storage/volume/VolumeObject.java    |    4 +-
 .../storage/volume/VolumeServiceImpl.java          |    4 +-
 .../network/lb/dao/ElasticLbVmMapDaoImpl.java      |    5 +-
 .../com/cloud/capacity/dao/CapacityDaoImpl.java    |    4 +-
 .../configuration/dao/ResourceCountDaoImpl.java    |    8 +-
 server/src/com/cloud/dc/dao/DataCenterDaoImpl.java |   12 +-
 server/src/com/cloud/host/dao/HostDaoImpl.java     |    9 +-
 .../cloud/network/dao/FirewallRulesDaoImpl.java    |    5 +-
 .../com/cloud/network/dao/IPAddressDaoImpl.java    |    5 +-
 .../com/cloud/network/dao/LoadBalancerDaoImpl.java |    3 +-
 .../src/com/cloud/network/dao/NetworkDaoImpl.java  |   13 +-
 .../cloud/network/dao/PhysicalNetworkDaoImpl.java  |    3 +-
 .../network/dao/Site2SiteVpnConnectionDaoImpl.java |    5 +-
 .../network/dao/Site2SiteVpnGatewayDaoImpl.java    |    3 +-
 .../com/cloud/network/rules/FirewallRuleVO.java    |    3 +-
 .../rules/dao/PortForwardingRulesDaoImpl.java      |    3 +-
 .../network/security/dao/SecurityGroupDaoImpl.java |    3 +-
 .../cloud/network/vpc/dao/StaticRouteDaoImpl.java  |    3 +-
 .../src/com/cloud/network/vpc/dao/VpcDaoImpl.java  |    3 +-
 .../src/com/cloud/projects/dao/ProjectDaoImpl.java |    4 +-
 .../src/com/cloud/storage/dao/SnapshotDaoImpl.java |    7 +-
 .../com/cloud/storage/dao/StoragePoolDaoImpl.java  |    4 +-
 .../com/cloud/storage/dao/VMTemplateDaoImpl.java   |    2 +-
 .../src/com/cloud/storage/dao/VolumeDaoImpl.java   |    5 +-
 .../cloud/upgrade/DatabaseIntegrityChecker.java    |    4 +-
 .../com/cloud/upgrade/DatabaseUpgradeChecker.java  |    4 +-
 .../upgrade/PremiumDatabaseUpgradeChecker.java     |    3 +-
 .../src/com/cloud/vm/dao/DomainRouterDaoImpl.java  |    9 +-
 .../dao/RandomlyIncreasingVMInstanceDaoImpl.java   |    2 +
 server/src/com/cloud/vm/dao/UserVmDaoImpl.java     |  190 ++++---
 server/src/com/cloud/vm/dao/VMInstanceDaoImpl.java |    4 +-
 38 files changed, 713 insertions(+), 677 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
index f1610b4..110c328 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
@@ -66,7 +66,7 @@ import org.apache.cloudstack.storage.image.provider.ImageDataStoreProviderManage
 import org.apache.cloudstack.storage.image.store.ImageDataStore;
 import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCycle;
 import org.apache.cloudstack.storage.volume.VolumeService;
-import org.apache.cloudstack.storage.volume.db.VolumeDao;
+import org.apache.cloudstack.storage.volume.db.VolumeDao2;
 import org.apache.cloudstack.storage.volume.db.VolumeVO;
 import org.springframework.test.context.ContextConfiguration;
 import org.mockito.Mockito;
@@ -105,7 +105,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 	@Inject
 	ImageDataDao imageDataDao;
 	@Inject
-	VolumeDao volumeDao;
+	VolumeDao2 volumeDao;
 	@Inject 
 	HostDao hostDao;
 	@Inject

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao.java b/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao.java
deleted file mode 100644
index 8ee6060..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao.java
+++ /dev/null
@@ -1,82 +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 org.apache.cloudstack.storage.volume.db;
-
-import java.util.List;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
-import org.apache.cloudstack.storage.volume.VolumeEvent;
-
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.storage.Storage.ImageFormat;
-import com.cloud.storage.Volume;
-import com.cloud.utils.Pair;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.fsm.StateDao;
-
-public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.State, Volume.Event, VolumeVO> {
-
-    List<VolumeVO> findDetachedByAccount(long accountId);
-
-    List<VolumeVO> findByAccount(long accountId);
-
-    Pair<Long, Long> getCountAndTotalByPool(long poolId);
-
-    Pair<Long, Long> getNonDestroyedCountAndTotalByPool(long poolId);
-
-    List<VolumeVO> findByInstance(long id);
-
-    List<VolumeVO> findByInstanceAndType(long id, VolumeType vType);
-
-    List<VolumeVO> findByInstanceIdDestroyed(long vmId);
-
-    List<VolumeVO> findByAccountAndPod(long accountId, long podId);
-
-    List<VolumeVO> findByTemplateAndZone(long templateId, long zoneId);
-
-    void deleteVolumesByInstance(long instanceId);
-
-    void attachVolume(long volumeId, long vmId, long deviceId);
-
-    void detachVolume(long volumeId);
-
-    boolean isAnyVolumeActivelyUsingTemplateOnPool(long templateId, long poolId);
-
-    List<VolumeVO> findCreatedByInstance(long id);
-
-    List<VolumeVO> findByPoolId(long poolId);
-
-    List<VolumeVO> findByInstanceAndDeviceId(long instanceId, long deviceId);
-
-    List<VolumeVO> findUsableVolumesForInstance(long instanceId);
-
-    Long countAllocatedVolumesForAccount(long accountId);
-
-    HypervisorType getHypervisorType(long volumeId);
-
-    List<VolumeVO> listVolumesToBeDestroyed();
-
-    ImageFormat getImageFormat(Long volumeId);
-
-    List<VolumeVO> findReadyRootVolumesByInstance(long instanceId);
-
-    List<Long> listPoolIdsByVolumeCount(long dcId, Long podId, Long clusterId, long accountId);
-
-    VolumeVO allocVolume(long size, VolumeType type, String volName, Long templateId);
-    
-    VolumeVO findByVolumeIdAndPoolId(long volumeId, long poolId);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao2.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao2.java b/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao2.java
new file mode 100644
index 0000000..b0c8fad
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao2.java
@@ -0,0 +1,82 @@
+// 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 org.apache.cloudstack.storage.volume.db;
+
+import java.util.List;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
+import org.apache.cloudstack.storage.volume.VolumeEvent;
+
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.storage.Storage.ImageFormat;
+import com.cloud.storage.Volume;
+import com.cloud.utils.Pair;
+import com.cloud.utils.db.GenericDao;
+import com.cloud.utils.fsm.StateDao;
+
+public interface VolumeDao2 extends GenericDao<VolumeVO, Long>, StateDao<Volume.State, Volume.Event, VolumeVO> {
+
+    List<VolumeVO> findDetachedByAccount(long accountId);
+
+    List<VolumeVO> findByAccount(long accountId);
+
+    Pair<Long, Long> getCountAndTotalByPool(long poolId);
+
+    Pair<Long, Long> getNonDestroyedCountAndTotalByPool(long poolId);
+
+    List<VolumeVO> findByInstance(long id);
+
+    List<VolumeVO> findByInstanceAndType(long id, VolumeType vType);
+
+    List<VolumeVO> findByInstanceIdDestroyed(long vmId);
+
+    List<VolumeVO> findByAccountAndPod(long accountId, long podId);
+
+    List<VolumeVO> findByTemplateAndZone(long templateId, long zoneId);
+
+    void deleteVolumesByInstance(long instanceId);
+
+    void attachVolume(long volumeId, long vmId, long deviceId);
+
+    void detachVolume(long volumeId);
+
+    boolean isAnyVolumeActivelyUsingTemplateOnPool(long templateId, long poolId);
+
+    List<VolumeVO> findCreatedByInstance(long id);
+
+    List<VolumeVO> findByPoolId(long poolId);
+
+    List<VolumeVO> findByInstanceAndDeviceId(long instanceId, long deviceId);
+
+    List<VolumeVO> findUsableVolumesForInstance(long instanceId);
+
+    Long countAllocatedVolumesForAccount(long accountId);
+
+    HypervisorType getHypervisorType(long volumeId);
+
+    List<VolumeVO> listVolumesToBeDestroyed();
+
+    ImageFormat getImageFormat(Long volumeId);
+
+    List<VolumeVO> findReadyRootVolumesByInstance(long instanceId);
+
+    List<Long> listPoolIdsByVolumeCount(long dcId, Long podId, Long clusterId, long accountId);
+
+    VolumeVO allocVolume(long size, VolumeType type, String volName, Long templateId);
+    
+    VolumeVO findByVolumeIdAndPoolId(long volumeId, long poolId);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao2Impl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao2Impl.java b/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao2Impl.java
new file mode 100644
index 0000000..0eb0ac3
--- /dev/null
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDao2Impl.java
@@ -0,0 +1,439 @@
+// 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 org.apache.cloudstack.storage.volume.db;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.type.RootDisk;
+import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
+import org.apache.cloudstack.storage.volume.VolumeEvent;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.server.ResourceTag.TaggedResourceType;
+import com.cloud.storage.Storage.ImageFormat;
+import com.cloud.storage.Volume;
+import com.cloud.tags.dao.ResourceTagsDaoImpl;
+import com.cloud.utils.Pair;
+import com.cloud.utils.component.ComponentLocator;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.GenericSearchBuilder;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Func;
+import com.cloud.utils.db.SearchCriteria.Op;
+import com.cloud.utils.db.SearchCriteria2;
+import com.cloud.utils.db.SearchCriteriaService;
+import com.cloud.utils.db.Transaction;
+import com.cloud.utils.db.UpdateBuilder;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+@Local(value = VolumeDao2.class)
+@Component
+public class VolumeDao2Impl extends GenericDaoBase<VolumeVO, Long> implements VolumeDao2 {
+    private static final Logger s_logger = Logger.getLogger(VolumeDao2Impl.class);
+    protected final SearchBuilder<VolumeVO> DetachedAccountIdSearch;
+    protected final SearchBuilder<VolumeVO> TemplateZoneSearch;
+    protected final GenericSearchBuilder<VolumeVO, SumCount> TotalSizeByPoolSearch;
+    protected final GenericSearchBuilder<VolumeVO, Long> ActiveTemplateSearch;
+    protected final SearchBuilder<VolumeVO> InstanceStatesSearch;
+    protected final SearchBuilder<VolumeVO> AllFieldsSearch;
+    protected GenericSearchBuilder<VolumeVO, Long> CountByAccount;
+    //ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
+    ResourceTagsDaoImpl _tagsDao = null;
+    protected static final String SELECT_VM_SQL = "SELECT DISTINCT instance_id from volumes v where v.host_id = ? and v.mirror_state = ?";
+    protected static final String SELECT_HYPERTYPE_FROM_VOLUME = "SELECT c.hypervisor_type from volumes v, storage_pool s, cluster c where v.pool_id = s.id and s.cluster_id = c.id and v.id = ?";
+
+    private static final String ORDER_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT = "SELECT pool.id, SUM(IF(vol.state='Ready' AND vol.account_id = ?, 1, 0)) FROM `cloud`.`storage_pool` pool LEFT JOIN `cloud`.`volumes` vol ON pool.id = vol.pool_id WHERE pool.data_center_id = ? "
+            + " AND pool.pod_id = ? AND pool.cluster_id = ? " + " GROUP BY pool.id ORDER BY 2 ASC ";
+
+    @Override
+    public List<VolumeVO> findDetachedByAccount(long accountId) {
+        SearchCriteria<VolumeVO> sc = DetachedAccountIdSearch.create();
+        sc.setParameters("accountId", accountId);
+        sc.setParameters("destroyed", Volume.State.Destroy);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<VolumeVO> findByAccount(long accountId) {
+        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
+        sc.setParameters("accountId", accountId);
+        sc.setParameters("state", Volume.State.Ready);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<VolumeVO> findByInstance(long id) {
+        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
+        sc.setParameters("instanceId", id);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<VolumeVO> findByInstanceAndDeviceId(long instanceId, long deviceId) {
+        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
+        sc.setParameters("instanceId", instanceId);
+        sc.setParameters("deviceId", deviceId);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<VolumeVO> findByPoolId(long poolId) {
+        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
+        sc.setParameters("poolId", poolId);
+        sc.setParameters("notDestroyed", Volume.State.Destroy);
+        sc.setParameters("vType", new RootDisk().toString());
+        return listBy(sc);
+    }
+
+    @Override
+    public List<VolumeVO> findCreatedByInstance(long id) {
+        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
+        sc.setParameters("instanceId", id);
+        sc.setParameters("state", Volume.State.Ready);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<VolumeVO> findUsableVolumesForInstance(long instanceId) {
+        SearchCriteria<VolumeVO> sc = InstanceStatesSearch.create();
+        sc.setParameters("instance", instanceId);
+        sc.setParameters("states", Volume.State.Creating, Volume.State.Ready, Volume.State.Allocated);
+
+        return listBy(sc);
+    }
+
+    @Override
+    public List<VolumeVO> findByInstanceAndType(long id, VolumeType vType) {
+        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
+        sc.setParameters("instanceId", id);
+        sc.setParameters("vType", vType.toString());
+        return listBy(sc);
+    }
+
+    @Override
+    public List<VolumeVO> findByInstanceIdDestroyed(long vmId) {
+        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
+        sc.setParameters("instanceId", vmId);
+        sc.setParameters("destroyed", Volume.State.Destroy);
+        return listBy(sc);
+    }
+
+    @Override
+    public List<VolumeVO> findReadyRootVolumesByInstance(long instanceId) {
+        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
+        sc.setParameters("instanceId", instanceId);
+        sc.setParameters("state", Volume.State.Ready);
+        sc.setParameters("vType", new RootDisk().toString());
+        return listBy(sc);
+    }
+
+    @Override
+    public List<VolumeVO> findByAccountAndPod(long accountId, long podId) {
+        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
+        sc.setParameters("accountId", accountId);
+        sc.setParameters("pod", podId);
+        sc.setParameters("state", Volume.State.Ready);
+
+        return listIncludingRemovedBy(sc);
+    }
+
+    @Override
+    public List<VolumeVO> findByTemplateAndZone(long templateId, long zoneId) {
+        SearchCriteria<VolumeVO> sc = TemplateZoneSearch.create();
+        sc.setParameters("template", templateId);
+        sc.setParameters("zone", zoneId);
+
+        return listIncludingRemovedBy(sc);
+    }
+
+    @Override
+    public boolean isAnyVolumeActivelyUsingTemplateOnPool(long templateId, long poolId) {
+        SearchCriteria<Long> sc = ActiveTemplateSearch.create();
+        sc.setParameters("template", templateId);
+        sc.setParameters("pool", poolId);
+
+        List<Long> results = customSearchIncludingRemoved(sc, null);
+        assert results.size() > 0 : "How can this return a size of " + results.size();
+
+        return results.get(0) > 0;
+    }
+
+    @Override
+    public void deleteVolumesByInstance(long instanceId) {
+        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
+        sc.setParameters("instanceId", instanceId);
+        expunge(sc);
+    }
+
+    @Override
+    public void attachVolume(long volumeId, long vmId, long deviceId) {
+        VolumeVO volume = createForUpdate(volumeId);
+        volume.setInstanceId(vmId);
+        volume.setDeviceId(deviceId);
+        volume.setUpdated(new Date());
+        volume.setAttached(new Date());
+        update(volumeId, volume);
+    }
+
+    @Override
+    public void detachVolume(long volumeId) {
+        VolumeVO volume = createForUpdate(volumeId);
+        volume.setInstanceId(null);
+        volume.setDeviceId(null);
+        volume.setUpdated(new Date());
+        volume.setAttached(null);
+        update(volumeId, volume);
+    }
+
+    @Override
+    @DB
+    public HypervisorType getHypervisorType(long volumeId) {
+        /* lookup from cluster of pool */
+        Transaction txn = Transaction.currentTxn();
+        PreparedStatement pstmt = null;
+
+        try {
+            String sql = SELECT_HYPERTYPE_FROM_VOLUME;
+            pstmt = txn.prepareAutoCloseStatement(sql);
+            pstmt.setLong(1, volumeId);
+            ResultSet rs = pstmt.executeQuery();
+            if (rs.next()) {
+                return HypervisorType.getType(rs.getString(1));
+            }
+            return HypervisorType.None;
+        } catch (SQLException e) {
+            throw new CloudRuntimeException("DB Exception on: " + SELECT_HYPERTYPE_FROM_VOLUME, e);
+        } catch (Throwable e) {
+            throw new CloudRuntimeException("Caught: " + SELECT_HYPERTYPE_FROM_VOLUME, e);
+        }
+    }
+
+    @Override
+    public ImageFormat getImageFormat(Long volumeId) {
+        HypervisorType type = getHypervisorType(volumeId);
+        if (type.equals(HypervisorType.KVM)) {
+            return ImageFormat.QCOW2;
+        } else if (type.equals(HypervisorType.XenServer)) {
+            return ImageFormat.VHD;
+        } else if (type.equals(HypervisorType.VMware)) {
+            return ImageFormat.OVA;
+        } else {
+            s_logger.warn("Do not support hypervisor " + type.toString());
+            return null;
+        }
+    }
+
+    protected VolumeDao2Impl() {
+        AllFieldsSearch = createSearchBuilder();
+        AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
+        AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), Op.EQ);
+        AllFieldsSearch.and("pod", AllFieldsSearch.entity().getPodId(), Op.EQ);
+        AllFieldsSearch.and("instanceId", AllFieldsSearch.entity().getInstanceId(), Op.EQ);
+        AllFieldsSearch.and("deviceId", AllFieldsSearch.entity().getDeviceId(), Op.EQ);
+        AllFieldsSearch.and("poolId", AllFieldsSearch.entity().getPoolId(), Op.EQ);
+        AllFieldsSearch.and("vType", AllFieldsSearch.entity().getVolumeType(), Op.EQ);
+        AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
+        AllFieldsSearch.and("destroyed", AllFieldsSearch.entity().getState(), Op.EQ);
+        AllFieldsSearch.and("notDestroyed", AllFieldsSearch.entity().getState(), Op.NEQ);
+        AllFieldsSearch.and("updatedCount", AllFieldsSearch.entity().getUpdatedCount(), Op.EQ);
+        AllFieldsSearch.done();
+
+        DetachedAccountIdSearch = createSearchBuilder();
+        DetachedAccountIdSearch.and("accountId", DetachedAccountIdSearch.entity().getAccountId(), Op.EQ);
+        DetachedAccountIdSearch.and("destroyed", DetachedAccountIdSearch.entity().getState(), Op.NEQ);
+        DetachedAccountIdSearch.and("instanceId", DetachedAccountIdSearch.entity().getInstanceId(), Op.NULL);
+        DetachedAccountIdSearch.done();
+
+        TemplateZoneSearch = createSearchBuilder();
+        TemplateZoneSearch.and("template", TemplateZoneSearch.entity().getTemplateId(), Op.EQ);
+        TemplateZoneSearch.and("zone", TemplateZoneSearch.entity().getDataCenterId(), Op.EQ);
+        TemplateZoneSearch.done();
+
+        TotalSizeByPoolSearch = createSearchBuilder(SumCount.class);
+        TotalSizeByPoolSearch.select("sum", Func.SUM, TotalSizeByPoolSearch.entity().getSize());
+        TotalSizeByPoolSearch.select("count", Func.COUNT, (Object[]) null);
+        TotalSizeByPoolSearch.and("poolId", TotalSizeByPoolSearch.entity().getPoolId(), Op.EQ);
+        TotalSizeByPoolSearch.and("removed", TotalSizeByPoolSearch.entity().getRemoved(), Op.NULL);
+        TotalSizeByPoolSearch.and("state", TotalSizeByPoolSearch.entity().getState(), Op.NEQ);
+        TotalSizeByPoolSearch.done();
+
+        ActiveTemplateSearch = createSearchBuilder(Long.class);
+        ActiveTemplateSearch.and("pool", ActiveTemplateSearch.entity().getPoolId(), Op.EQ);
+        ActiveTemplateSearch.and("template", ActiveTemplateSearch.entity().getTemplateId(), Op.EQ);
+        ActiveTemplateSearch.and("removed", ActiveTemplateSearch.entity().getRemoved(), Op.NULL);
+        ActiveTemplateSearch.select(null, Func.COUNT, null);
+        ActiveTemplateSearch.done();
+
+        InstanceStatesSearch = createSearchBuilder();
+        InstanceStatesSearch.and("instance", InstanceStatesSearch.entity().getInstanceId(), Op.EQ);
+        InstanceStatesSearch.and("states", InstanceStatesSearch.entity().getState(), Op.IN);
+        InstanceStatesSearch.done();
+
+        CountByAccount = createSearchBuilder(Long.class);
+        CountByAccount.select(null, Func.COUNT, null);
+        CountByAccount.and("account", CountByAccount.entity().getAccountId(), SearchCriteria.Op.EQ);
+        CountByAccount.and("state", CountByAccount.entity().getState(), SearchCriteria.Op.NIN);
+        CountByAccount.done();
+    }
+
+    @Override
+    @DB(txn = false)
+    public Pair<Long, Long> getCountAndTotalByPool(long poolId) {
+        SearchCriteria<SumCount> sc = TotalSizeByPoolSearch.create();
+        sc.setParameters("poolId", poolId);
+        List<SumCount> results = customSearch(sc, null);
+        SumCount sumCount = results.get(0);
+        return new Pair<Long, Long>(sumCount.count, sumCount.sum);
+    }
+
+    @Override
+    public Long countAllocatedVolumesForAccount(long accountId) {
+        SearchCriteria<Long> sc = CountByAccount.create();
+        sc.setParameters("account", accountId);
+        sc.setParameters("state", Volume.State.Destroy);
+        return customSearch(sc, null).get(0);
+    }
+
+    public static class SumCount {
+        public long sum;
+        public long count;
+
+        public SumCount() {
+        }
+    }
+
+    @Override
+    public List<VolumeVO> listVolumesToBeDestroyed() {
+        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
+        sc.setParameters("state", Volume.State.Destroy);
+
+        return listBy(sc);
+    }
+
+    @Override
+    public boolean updateState(Volume.State currentState, Volume.Event event, Volume.State nextState, VolumeVO vo, Object data) {
+
+        Long oldUpdated = vo.getUpdatedCount();
+        Date oldUpdatedTime = vo.getUpdated();
+
+        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
+        sc.setParameters("id", vo.getId());
+        sc.setParameters("state", currentState);
+        sc.setParameters("updatedCount", vo.getUpdatedCount());
+
+        vo.incrUpdatedCount();
+
+        UpdateBuilder builder = getUpdateBuilder(vo);
+        builder.set(vo, "state", nextState);
+        builder.set(vo, "updated", new Date());
+
+        int rows = update((VolumeVO) vo, sc);
+        if (rows == 0 && s_logger.isDebugEnabled()) {
+            VolumeVO dbVol = findByIdIncludingRemoved(vo.getId());
+            if (dbVol != null) {
+                StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
+                str.append(": DB Data={id=").append(dbVol.getId()).append("; state=").append(dbVol.getState()).append("; updatecount=").append(dbVol.getUpdatedCount()).append(";updatedTime=")
+                        .append(dbVol.getUpdated());
+                str.append(": New Data={id=").append(vo.getId()).append("; state=").append(nextState).append("; event=").append(event).append("; updatecount=").append(vo.getUpdatedCount())
+                        .append("; updatedTime=").append(vo.getUpdated());
+                str.append(": stale Data={id=").append(vo.getId()).append("; state=").append(currentState).append("; event=").append(event).append("; updatecount=").append(oldUpdated)
+                        .append("; updatedTime=").append(oldUpdatedTime);
+            } else {
+                s_logger.debug("Unable to update volume: id=" + vo.getId() + ", as there is no such volume exists in the database anymore");
+            }
+        }
+        return rows > 0;
+    }
+
+    @Override
+    public List<Long> listPoolIdsByVolumeCount(long dcId, Long podId, Long clusterId, long accountId) {
+        Transaction txn = Transaction.currentTxn();
+        PreparedStatement pstmt = null;
+        List<Long> result = new ArrayList<Long>();
+        try {
+            String sql = ORDER_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT;
+            pstmt = txn.prepareAutoCloseStatement(sql);
+            pstmt.setLong(1, accountId);
+            pstmt.setLong(2, dcId);
+            pstmt.setLong(3, podId);
+            pstmt.setLong(4, clusterId);
+
+            ResultSet rs = pstmt.executeQuery();
+            while (rs.next()) {
+                result.add(rs.getLong(1));
+            }
+            return result;
+        } catch (SQLException e) {
+            throw new CloudRuntimeException("DB Exception on: " + ORDER_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT, e);
+        } catch (Throwable e) {
+            throw new CloudRuntimeException("Caught: " + ORDER_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT, e);
+        }
+    }
+
+    @Override
+    @DB(txn = false)
+    public Pair<Long, Long> getNonDestroyedCountAndTotalByPool(long poolId) {
+        SearchCriteria<SumCount> sc = TotalSizeByPoolSearch.create();
+        sc.setParameters("poolId", poolId);
+        sc.setParameters("state", Volume.State.Destroy);
+        List<SumCount> results = customSearch(sc, null);
+        SumCount sumCount = results.get(0);
+        return new Pair<Long, Long>(sumCount.count, sumCount.sum);
+    }
+
+    @Override
+    @DB
+    public boolean remove(Long id) {
+        Transaction txn = Transaction.currentTxn();
+        txn.start();
+        VolumeVO entry = findById(id);
+        if (entry != null) {
+            _tagsDao.removeByIdAndType(id, TaggedResourceType.Volume);
+        }
+        boolean result = super.remove(id);
+        txn.commit();
+        return result;
+    }
+
+    @Override
+    @DB
+    public VolumeVO allocVolume(long size, VolumeType type, String volName, Long templateId) {
+        VolumeVO vol = new VolumeVO(size, type.toString(), volName, templateId);
+        vol = this.persist(vol);
+        return vol;
+    }
+
+    @Override
+    public VolumeVO findByVolumeIdAndPoolId(long volumeId, long poolId) {
+        SearchCriteriaService<VolumeVO, VolumeVO> sc = SearchCriteria2.create(VolumeVO.class);
+        sc.addAnd(sc.getEntity().getId(), Op.EQ, volumeId);
+        sc.addAnd(sc.getEntity().getPoolId(), Op.EQ, poolId);
+        return sc.find();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDaoImpl.java b/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDaoImpl.java
deleted file mode 100644
index 766ed91..0000000
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/db/VolumeDaoImpl.java
+++ /dev/null
@@ -1,439 +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 org.apache.cloudstack.storage.volume.db;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.type.RootDisk;
-import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
-import org.apache.cloudstack.storage.volume.VolumeEvent;
-
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.server.ResourceTag.TaggedResourceType;
-import com.cloud.storage.Storage.ImageFormat;
-import com.cloud.storage.Volume;
-import com.cloud.tags.dao.ResourceTagsDaoImpl;
-import com.cloud.utils.Pair;
-import com.cloud.utils.component.ComponentLocator;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.GenericSearchBuilder;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Func;
-import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.SearchCriteria2;
-import com.cloud.utils.db.SearchCriteriaService;
-import com.cloud.utils.db.Transaction;
-import com.cloud.utils.db.UpdateBuilder;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@Local(value = VolumeDao.class)
-@Component
-public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements VolumeDao {
-    private static final Logger s_logger = Logger.getLogger(VolumeDaoImpl.class);
-    protected final SearchBuilder<VolumeVO> DetachedAccountIdSearch;
-    protected final SearchBuilder<VolumeVO> TemplateZoneSearch;
-    protected final GenericSearchBuilder<VolumeVO, SumCount> TotalSizeByPoolSearch;
-    protected final GenericSearchBuilder<VolumeVO, Long> ActiveTemplateSearch;
-    protected final SearchBuilder<VolumeVO> InstanceStatesSearch;
-    protected final SearchBuilder<VolumeVO> AllFieldsSearch;
-    protected GenericSearchBuilder<VolumeVO, Long> CountByAccount;
-    //ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
-    ResourceTagsDaoImpl _tagsDao = null;
-    protected static final String SELECT_VM_SQL = "SELECT DISTINCT instance_id from volumes v where v.host_id = ? and v.mirror_state = ?";
-    protected static final String SELECT_HYPERTYPE_FROM_VOLUME = "SELECT c.hypervisor_type from volumes v, storage_pool s, cluster c where v.pool_id = s.id and s.cluster_id = c.id and v.id = ?";
-
-    private static final String ORDER_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT = "SELECT pool.id, SUM(IF(vol.state='Ready' AND vol.account_id = ?, 1, 0)) FROM `cloud`.`storage_pool` pool LEFT JOIN `cloud`.`volumes` vol ON pool.id = vol.pool_id WHERE pool.data_center_id = ? "
-            + " AND pool.pod_id = ? AND pool.cluster_id = ? " + " GROUP BY pool.id ORDER BY 2 ASC ";
-
-    @Override
-    public List<VolumeVO> findDetachedByAccount(long accountId) {
-        SearchCriteria<VolumeVO> sc = DetachedAccountIdSearch.create();
-        sc.setParameters("accountId", accountId);
-        sc.setParameters("destroyed", Volume.State.Destroy);
-        return listBy(sc);
-    }
-
-    @Override
-    public List<VolumeVO> findByAccount(long accountId) {
-        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
-        sc.setParameters("accountId", accountId);
-        sc.setParameters("state", Volume.State.Ready);
-        return listBy(sc);
-    }
-
-    @Override
-    public List<VolumeVO> findByInstance(long id) {
-        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
-        sc.setParameters("instanceId", id);
-        return listBy(sc);
-    }
-
-    @Override
-    public List<VolumeVO> findByInstanceAndDeviceId(long instanceId, long deviceId) {
-        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
-        sc.setParameters("instanceId", instanceId);
-        sc.setParameters("deviceId", deviceId);
-        return listBy(sc);
-    }
-
-    @Override
-    public List<VolumeVO> findByPoolId(long poolId) {
-        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
-        sc.setParameters("poolId", poolId);
-        sc.setParameters("notDestroyed", Volume.State.Destroy);
-        sc.setParameters("vType", new RootDisk().toString());
-        return listBy(sc);
-    }
-
-    @Override
-    public List<VolumeVO> findCreatedByInstance(long id) {
-        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
-        sc.setParameters("instanceId", id);
-        sc.setParameters("state", Volume.State.Ready);
-        return listBy(sc);
-    }
-
-    @Override
-    public List<VolumeVO> findUsableVolumesForInstance(long instanceId) {
-        SearchCriteria<VolumeVO> sc = InstanceStatesSearch.create();
-        sc.setParameters("instance", instanceId);
-        sc.setParameters("states", Volume.State.Creating, Volume.State.Ready, Volume.State.Allocated);
-
-        return listBy(sc);
-    }
-
-    @Override
-    public List<VolumeVO> findByInstanceAndType(long id, VolumeType vType) {
-        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
-        sc.setParameters("instanceId", id);
-        sc.setParameters("vType", vType.toString());
-        return listBy(sc);
-    }
-
-    @Override
-    public List<VolumeVO> findByInstanceIdDestroyed(long vmId) {
-        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
-        sc.setParameters("instanceId", vmId);
-        sc.setParameters("destroyed", Volume.State.Destroy);
-        return listBy(sc);
-    }
-
-    @Override
-    public List<VolumeVO> findReadyRootVolumesByInstance(long instanceId) {
-        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
-        sc.setParameters("instanceId", instanceId);
-        sc.setParameters("state", Volume.State.Ready);
-        sc.setParameters("vType", new RootDisk().toString());
-        return listBy(sc);
-    }
-
-    @Override
-    public List<VolumeVO> findByAccountAndPod(long accountId, long podId) {
-        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
-        sc.setParameters("accountId", accountId);
-        sc.setParameters("pod", podId);
-        sc.setParameters("state", Volume.State.Ready);
-
-        return listIncludingRemovedBy(sc);
-    }
-
-    @Override
-    public List<VolumeVO> findByTemplateAndZone(long templateId, long zoneId) {
-        SearchCriteria<VolumeVO> sc = TemplateZoneSearch.create();
-        sc.setParameters("template", templateId);
-        sc.setParameters("zone", zoneId);
-
-        return listIncludingRemovedBy(sc);
-    }
-
-    @Override
-    public boolean isAnyVolumeActivelyUsingTemplateOnPool(long templateId, long poolId) {
-        SearchCriteria<Long> sc = ActiveTemplateSearch.create();
-        sc.setParameters("template", templateId);
-        sc.setParameters("pool", poolId);
-
-        List<Long> results = customSearchIncludingRemoved(sc, null);
-        assert results.size() > 0 : "How can this return a size of " + results.size();
-
-        return results.get(0) > 0;
-    }
-
-    @Override
-    public void deleteVolumesByInstance(long instanceId) {
-        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
-        sc.setParameters("instanceId", instanceId);
-        expunge(sc);
-    }
-
-    @Override
-    public void attachVolume(long volumeId, long vmId, long deviceId) {
-        VolumeVO volume = createForUpdate(volumeId);
-        volume.setInstanceId(vmId);
-        volume.setDeviceId(deviceId);
-        volume.setUpdated(new Date());
-        volume.setAttached(new Date());
-        update(volumeId, volume);
-    }
-
-    @Override
-    public void detachVolume(long volumeId) {
-        VolumeVO volume = createForUpdate(volumeId);
-        volume.setInstanceId(null);
-        volume.setDeviceId(null);
-        volume.setUpdated(new Date());
-        volume.setAttached(null);
-        update(volumeId, volume);
-    }
-
-    @Override
-    @DB
-    public HypervisorType getHypervisorType(long volumeId) {
-        /* lookup from cluster of pool */
-        Transaction txn = Transaction.currentTxn();
-        PreparedStatement pstmt = null;
-
-        try {
-            String sql = SELECT_HYPERTYPE_FROM_VOLUME;
-            pstmt = txn.prepareAutoCloseStatement(sql);
-            pstmt.setLong(1, volumeId);
-            ResultSet rs = pstmt.executeQuery();
-            if (rs.next()) {
-                return HypervisorType.getType(rs.getString(1));
-            }
-            return HypervisorType.None;
-        } catch (SQLException e) {
-            throw new CloudRuntimeException("DB Exception on: " + SELECT_HYPERTYPE_FROM_VOLUME, e);
-        } catch (Throwable e) {
-            throw new CloudRuntimeException("Caught: " + SELECT_HYPERTYPE_FROM_VOLUME, e);
-        }
-    }
-
-    @Override
-    public ImageFormat getImageFormat(Long volumeId) {
-        HypervisorType type = getHypervisorType(volumeId);
-        if (type.equals(HypervisorType.KVM)) {
-            return ImageFormat.QCOW2;
-        } else if (type.equals(HypervisorType.XenServer)) {
-            return ImageFormat.VHD;
-        } else if (type.equals(HypervisorType.VMware)) {
-            return ImageFormat.OVA;
-        } else {
-            s_logger.warn("Do not support hypervisor " + type.toString());
-            return null;
-        }
-    }
-
-    protected VolumeDaoImpl() {
-        AllFieldsSearch = createSearchBuilder();
-        AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
-        AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), Op.EQ);
-        AllFieldsSearch.and("pod", AllFieldsSearch.entity().getPodId(), Op.EQ);
-        AllFieldsSearch.and("instanceId", AllFieldsSearch.entity().getInstanceId(), Op.EQ);
-        AllFieldsSearch.and("deviceId", AllFieldsSearch.entity().getDeviceId(), Op.EQ);
-        AllFieldsSearch.and("poolId", AllFieldsSearch.entity().getPoolId(), Op.EQ);
-        AllFieldsSearch.and("vType", AllFieldsSearch.entity().getVolumeType(), Op.EQ);
-        AllFieldsSearch.and("id", AllFieldsSearch.entity().getId(), Op.EQ);
-        AllFieldsSearch.and("destroyed", AllFieldsSearch.entity().getState(), Op.EQ);
-        AllFieldsSearch.and("notDestroyed", AllFieldsSearch.entity().getState(), Op.NEQ);
-        AllFieldsSearch.and("updatedCount", AllFieldsSearch.entity().getUpdatedCount(), Op.EQ);
-        AllFieldsSearch.done();
-
-        DetachedAccountIdSearch = createSearchBuilder();
-        DetachedAccountIdSearch.and("accountId", DetachedAccountIdSearch.entity().getAccountId(), Op.EQ);
-        DetachedAccountIdSearch.and("destroyed", DetachedAccountIdSearch.entity().getState(), Op.NEQ);
-        DetachedAccountIdSearch.and("instanceId", DetachedAccountIdSearch.entity().getInstanceId(), Op.NULL);
-        DetachedAccountIdSearch.done();
-
-        TemplateZoneSearch = createSearchBuilder();
-        TemplateZoneSearch.and("template", TemplateZoneSearch.entity().getTemplateId(), Op.EQ);
-        TemplateZoneSearch.and("zone", TemplateZoneSearch.entity().getDataCenterId(), Op.EQ);
-        TemplateZoneSearch.done();
-
-        TotalSizeByPoolSearch = createSearchBuilder(SumCount.class);
-        TotalSizeByPoolSearch.select("sum", Func.SUM, TotalSizeByPoolSearch.entity().getSize());
-        TotalSizeByPoolSearch.select("count", Func.COUNT, (Object[]) null);
-        TotalSizeByPoolSearch.and("poolId", TotalSizeByPoolSearch.entity().getPoolId(), Op.EQ);
-        TotalSizeByPoolSearch.and("removed", TotalSizeByPoolSearch.entity().getRemoved(), Op.NULL);
-        TotalSizeByPoolSearch.and("state", TotalSizeByPoolSearch.entity().getState(), Op.NEQ);
-        TotalSizeByPoolSearch.done();
-
-        ActiveTemplateSearch = createSearchBuilder(Long.class);
-        ActiveTemplateSearch.and("pool", ActiveTemplateSearch.entity().getPoolId(), Op.EQ);
-        ActiveTemplateSearch.and("template", ActiveTemplateSearch.entity().getTemplateId(), Op.EQ);
-        ActiveTemplateSearch.and("removed", ActiveTemplateSearch.entity().getRemoved(), Op.NULL);
-        ActiveTemplateSearch.select(null, Func.COUNT, null);
-        ActiveTemplateSearch.done();
-
-        InstanceStatesSearch = createSearchBuilder();
-        InstanceStatesSearch.and("instance", InstanceStatesSearch.entity().getInstanceId(), Op.EQ);
-        InstanceStatesSearch.and("states", InstanceStatesSearch.entity().getState(), Op.IN);
-        InstanceStatesSearch.done();
-
-        CountByAccount = createSearchBuilder(Long.class);
-        CountByAccount.select(null, Func.COUNT, null);
-        CountByAccount.and("account", CountByAccount.entity().getAccountId(), SearchCriteria.Op.EQ);
-        CountByAccount.and("state", CountByAccount.entity().getState(), SearchCriteria.Op.NIN);
-        CountByAccount.done();
-    }
-
-    @Override
-    @DB(txn = false)
-    public Pair<Long, Long> getCountAndTotalByPool(long poolId) {
-        SearchCriteria<SumCount> sc = TotalSizeByPoolSearch.create();
-        sc.setParameters("poolId", poolId);
-        List<SumCount> results = customSearch(sc, null);
-        SumCount sumCount = results.get(0);
-        return new Pair<Long, Long>(sumCount.count, sumCount.sum);
-    }
-
-    @Override
-    public Long countAllocatedVolumesForAccount(long accountId) {
-        SearchCriteria<Long> sc = CountByAccount.create();
-        sc.setParameters("account", accountId);
-        sc.setParameters("state", Volume.State.Destroy);
-        return customSearch(sc, null).get(0);
-    }
-
-    public static class SumCount {
-        public long sum;
-        public long count;
-
-        public SumCount() {
-        }
-    }
-
-    @Override
-    public List<VolumeVO> listVolumesToBeDestroyed() {
-        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
-        sc.setParameters("state", Volume.State.Destroy);
-
-        return listBy(sc);
-    }
-
-    @Override
-    public boolean updateState(Volume.State currentState, Volume.Event event, Volume.State nextState, VolumeVO vo, Object data) {
-
-        Long oldUpdated = vo.getUpdatedCount();
-        Date oldUpdatedTime = vo.getUpdated();
-
-        SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
-        sc.setParameters("id", vo.getId());
-        sc.setParameters("state", currentState);
-        sc.setParameters("updatedCount", vo.getUpdatedCount());
-
-        vo.incrUpdatedCount();
-
-        UpdateBuilder builder = getUpdateBuilder(vo);
-        builder.set(vo, "state", nextState);
-        builder.set(vo, "updated", new Date());
-
-        int rows = update((VolumeVO) vo, sc);
-        if (rows == 0 && s_logger.isDebugEnabled()) {
-            VolumeVO dbVol = findByIdIncludingRemoved(vo.getId());
-            if (dbVol != null) {
-                StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
-                str.append(": DB Data={id=").append(dbVol.getId()).append("; state=").append(dbVol.getState()).append("; updatecount=").append(dbVol.getUpdatedCount()).append(";updatedTime=")
-                        .append(dbVol.getUpdated());
-                str.append(": New Data={id=").append(vo.getId()).append("; state=").append(nextState).append("; event=").append(event).append("; updatecount=").append(vo.getUpdatedCount())
-                        .append("; updatedTime=").append(vo.getUpdated());
-                str.append(": stale Data={id=").append(vo.getId()).append("; state=").append(currentState).append("; event=").append(event).append("; updatecount=").append(oldUpdated)
-                        .append("; updatedTime=").append(oldUpdatedTime);
-            } else {
-                s_logger.debug("Unable to update volume: id=" + vo.getId() + ", as there is no such volume exists in the database anymore");
-            }
-        }
-        return rows > 0;
-    }
-
-    @Override
-    public List<Long> listPoolIdsByVolumeCount(long dcId, Long podId, Long clusterId, long accountId) {
-        Transaction txn = Transaction.currentTxn();
-        PreparedStatement pstmt = null;
-        List<Long> result = new ArrayList<Long>();
-        try {
-            String sql = ORDER_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT;
-            pstmt = txn.prepareAutoCloseStatement(sql);
-            pstmt.setLong(1, accountId);
-            pstmt.setLong(2, dcId);
-            pstmt.setLong(3, podId);
-            pstmt.setLong(4, clusterId);
-
-            ResultSet rs = pstmt.executeQuery();
-            while (rs.next()) {
-                result.add(rs.getLong(1));
-            }
-            return result;
-        } catch (SQLException e) {
-            throw new CloudRuntimeException("DB Exception on: " + ORDER_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT, e);
-        } catch (Throwable e) {
-            throw new CloudRuntimeException("Caught: " + ORDER_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT, e);
-        }
-    }
-
-    @Override
-    @DB(txn = false)
-    public Pair<Long, Long> getNonDestroyedCountAndTotalByPool(long poolId) {
-        SearchCriteria<SumCount> sc = TotalSizeByPoolSearch.create();
-        sc.setParameters("poolId", poolId);
-        sc.setParameters("state", Volume.State.Destroy);
-        List<SumCount> results = customSearch(sc, null);
-        SumCount sumCount = results.get(0);
-        return new Pair<Long, Long>(sumCount.count, sumCount.sum);
-    }
-
-    @Override
-    @DB
-    public boolean remove(Long id) {
-        Transaction txn = Transaction.currentTxn();
-        txn.start();
-        VolumeVO entry = findById(id);
-        if (entry != null) {
-            _tagsDao.removeByIdAndType(id, TaggedResourceType.Volume);
-        }
-        boolean result = super.remove(id);
-        txn.commit();
-        return result;
-    }
-
-    @Override
-    @DB
-    public VolumeVO allocVolume(long size, VolumeType type, String volName, Long templateId) {
-        VolumeVO vol = new VolumeVO(size, type.toString(), volName, templateId);
-        vol = this.persist(vol);
-        return vol;
-    }
-
-    @Override
-    public VolumeVO findByVolumeIdAndPoolId(long volumeId, long poolId) {
-        SearchCriteriaService<VolumeVO, VolumeVO> sc = SearchCriteria2.create(VolumeVO.class);
-        sc.addAnd(sc.getEntity().getId(), Op.EQ, volumeId);
-        sc.addAnd(sc.getEntity().getPoolId(), Op.EQ, poolId);
-        return sc.find();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java
index 347817d..13b6f4a 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java
@@ -25,7 +25,7 @@ import org.apache.cloudstack.storage.to.VolumeTO;
 import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
 import org.apache.cloudstack.storage.volume.TemplatePrimaryDataStoreManager;
 import org.apache.cloudstack.storage.volume.VolumeObject;
-import org.apache.cloudstack.storage.volume.db.VolumeDao;
+import org.apache.cloudstack.storage.volume.db.VolumeDao2;
 import org.apache.cloudstack.storage.volume.db.VolumeVO;
 
 import org.apache.log4j.Logger;
@@ -46,7 +46,7 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
     private HypervisorType supportedHypervisor;
     private boolean isLocalStorageSupported = false;
     @Inject
-    private VolumeDao volumeDao;
+    private VolumeDao2 volumeDao;
     @Inject
     private HostDao hostDao;
     @Inject

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeManagerImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeManagerImpl.java
index e6508e6..76f0b03 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeManagerImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeManagerImpl.java
@@ -19,7 +19,7 @@
 package org.apache.cloudstack.storage.volume;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeProfile;
-import org.apache.cloudstack.storage.volume.db.VolumeDao;
+import org.apache.cloudstack.storage.volume.db.VolumeDao2;
 import org.apache.cloudstack.storage.volume.db.VolumeVO;
 import org.springframework.stereotype.Component;
 
@@ -33,7 +33,7 @@ import com.cloud.utils.fsm.StateMachine2;
 @Component
 public class VolumeManagerImpl implements VolumeManager {
     @Inject
-    protected VolumeDao _volumeDao;
+    protected VolumeDao2 _volumeDao;
     private final static StateMachine2<State, Event, VolumeVO> s_fsm = new StateMachine2<State, Event, VolumeVO>();
     public VolumeManagerImpl() {
         initStateMachine();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
index e25dd87..b8c7631 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
@@ -11,7 +11,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskTyp
 import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
 import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeTypeHelper;
 import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
-import org.apache.cloudstack.storage.volume.db.VolumeDao;
+import org.apache.cloudstack.storage.volume.db.VolumeDao2;
 import org.apache.cloudstack.storage.volume.db.VolumeVO;
 
 import org.apache.log4j.Logger;
@@ -34,7 +34,7 @@ public class VolumeObject implements VolumeInfo {
     @Inject
     VolumeTypeHelper volumeTypeHelper;
     @Inject
-    VolumeDao volumeDao;
+    VolumeDao2 volumeDao;
     @Inject
     VolumeManager volumeMgr;
     private VolumeObject(PrimaryDataStore dataStore, VolumeVO volumeVO) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index 712b0ef..df8d80a 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -33,7 +33,7 @@ import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
 import org.apache.cloudstack.storage.datastore.manager.PrimaryDataStoreManager;
 import org.apache.cloudstack.storage.image.TemplateInfo;
 import org.apache.cloudstack.storage.image.motion.ImageMotionService;
-import org.apache.cloudstack.storage.volume.db.VolumeDao;
+import org.apache.cloudstack.storage.volume.db.VolumeDao2;
 import org.apache.cloudstack.storage.volume.db.VolumeVO;
 
 import org.springframework.stereotype.Component;
@@ -48,7 +48,7 @@ import com.cloud.utils.exception.CloudRuntimeException;
 @Component
 public class VolumeServiceImpl implements VolumeService {
     @Inject
-    VolumeDao volDao;
+    VolumeDao2 volDao;
     @Inject
     PrimaryDataStoreManager dataStoreMgr;
     @Inject

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/dao/ElasticLbVmMapDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/dao/ElasticLbVmMapDaoImpl.java b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/dao/ElasticLbVmMapDaoImpl.java
index 7913c97..b8d5533 100644
--- a/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/dao/ElasticLbVmMapDaoImpl.java
+++ b/plugins/network-elements/elastic-loadbalancer/src/com/cloud/network/lb/dao/ElasticLbVmMapDaoImpl.java
@@ -19,6 +19,7 @@ package com.cloud.network.lb.dao;
 import java.util.List;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.springframework.stereotype.Component;
 
@@ -40,8 +41,8 @@ import com.cloud.vm.dao.DomainRouterDaoImpl;
 @Component
 @Local(value={ElasticLbVmMapDao.class})
 public class ElasticLbVmMapDaoImpl extends GenericDaoBase<ElasticLbVmMapVO, Long> implements ElasticLbVmMapDao {
-    protected final DomainRouterDao _routerDao = ComponentLocator.inject(DomainRouterDaoImpl.class);
-    protected final LoadBalancerDao _loadbalancerDao = ComponentLocator.inject(LoadBalancerDaoImpl.class);
+    @Inject protected DomainRouterDao _routerDao;
+    @Inject protected LoadBalancerDao _loadbalancerDao;
 
     
     protected final SearchBuilder<ElasticLbVmMapVO> AllFieldsSearch;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/capacity/dao/CapacityDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/capacity/dao/CapacityDaoImpl.java b/server/src/com/cloud/capacity/dao/CapacityDaoImpl.java
index 620300a..e55bef6 100755
--- a/server/src/com/cloud/capacity/dao/CapacityDaoImpl.java
+++ b/server/src/com/cloud/capacity/dao/CapacityDaoImpl.java
@@ -25,6 +25,7 @@ import java.util.List;
 import java.util.Map;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
@@ -33,6 +34,7 @@ import com.cloud.capacity.Capacity;
 import com.cloud.capacity.CapacityVO;
 import com.cloud.storage.Storage;
 import com.cloud.storage.StoragePoolVO;
+import com.cloud.storage.dao.StoragePoolDao;
 import com.cloud.storage.dao.StoragePoolDaoImpl;
 import com.cloud.utils.Pair;
 import com.cloud.utils.StringUtils;
@@ -65,7 +67,7 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
 	private final SearchBuilder<CapacityVO> _hostOrPoolIdSearch;
     protected GenericSearchBuilder<CapacityVO, SummedCapacity> SummedCapacitySearch;
 	private SearchBuilder<CapacityVO> _allFieldsSearch;
-    protected final StoragePoolDaoImpl _storagePoolDao = ComponentLocator.inject(StoragePoolDaoImpl.class);
+    @Inject protected StoragePoolDao _storagePoolDao;
 
 	
     private static final String LIST_HOSTS_IN_CLUSTER_WITH_ENOUGH_CAPACITY = "SELECT a.host_id FROM (host JOIN op_host_capacity a ON host.id = a.host_id AND host.cluster_id = ? AND host.type = ? " +

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java b/server/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java
index 0f3d56e..2c550ea 100644
--- a/server/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java
+++ b/server/src/com/cloud/configuration/dao/ResourceCountDaoImpl.java
@@ -22,6 +22,7 @@ import java.util.List;
 import java.util.Set;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.springframework.stereotype.Component;
 
@@ -48,8 +49,11 @@ public class ResourceCountDaoImpl extends GenericDaoBase<ResourceCountVO, Long>
 	private SearchBuilder<ResourceCountVO> AccountSearch;
     private SearchBuilder<ResourceCountVO> DomainSearch;
 	
-	protected final DomainDaoImpl _domainDao = ComponentLocator.inject(DomainDaoImpl.class);
-	protected final AccountDaoImpl _accountDao = ComponentLocator.inject(AccountDaoImpl.class);
+	//protected final DomainDaoImpl _domainDao = ComponentLocator.inject(DomainDaoImpl.class);
+	//protected final AccountDaoImpl _accountDao = ComponentLocator.inject(AccountDaoImpl.class);
+
+	@Inject protected DomainDaoImpl _domainDao;
+	@Inject protected AccountDaoImpl _accountDao;
 
 	public ResourceCountDaoImpl() {
 		TypeSearch = createSearchBuilder();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/dc/dao/DataCenterDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/dc/dao/DataCenterDaoImpl.java b/server/src/com/cloud/dc/dao/DataCenterDaoImpl.java
index 9d700be..5ffc2b4 100755
--- a/server/src/com/cloud/dc/dao/DataCenterDaoImpl.java
+++ b/server/src/com/cloud/dc/dao/DataCenterDaoImpl.java
@@ -21,6 +21,7 @@ import java.util.Map;
 import java.util.Random;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 import javax.persistence.TableGenerator;
 
@@ -63,16 +64,15 @@ public class DataCenterDaoImpl extends GenericDaoBase<DataCenterVO, Long> implem
     protected SearchBuilder<DataCenterVO> DisabledZonesSearch;
     protected SearchBuilder<DataCenterVO> TokenSearch;
     
-    protected final DataCenterIpAddressDaoImpl _ipAllocDao = ComponentLocator.inject(DataCenterIpAddressDaoImpl.class);
-    protected final DataCenterLinkLocalIpAddressDaoImpl _LinkLocalIpAllocDao = ComponentLocator.inject(DataCenterLinkLocalIpAddressDaoImpl.class);
-    protected final DataCenterVnetDaoImpl _vnetAllocDao = ComponentLocator.inject(DataCenterVnetDaoImpl.class);
-    protected final PodVlanDaoImpl _podVlanAllocDao = ComponentLocator.inject(PodVlanDaoImpl.class);
+    @Inject protected final DataCenterIpAddressDaoImpl _ipAllocDao;
+    @Inject protected final DataCenterLinkLocalIpAddressDaoImpl _LinkLocalIpAllocDao;
+    @Inject protected final DataCenterVnetDaoImpl _vnetAllocDao;
+    @Inject protected final PodVlanDaoImpl _podVlanAllocDao;
     protected long _prefix;
     protected Random _rand = new Random(System.currentTimeMillis());
     protected TableGenerator _tgMacAddress;
     
-    protected final DcDetailsDaoImpl _detailsDao = ComponentLocator.inject(DcDetailsDaoImpl.class);
-
+    @Inject protected final DcDetailsDaoImpl _detailsDao;
 
     @Override
     public DataCenterVO findByName(String name) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/host/dao/HostDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/host/dao/HostDaoImpl.java b/server/src/com/cloud/host/dao/HostDaoImpl.java
index 8045051..1da6b4c 100755
--- a/server/src/com/cloud/host/dao/HostDaoImpl.java
+++ b/server/src/com/cloud/host/dao/HostDaoImpl.java
@@ -26,6 +26,7 @@ import java.util.Map;
 import java.util.TimeZone;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 import javax.persistence.TableGenerator;
 
 import org.apache.log4j.Logger;
@@ -114,10 +115,10 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
     protected final Attribute _msIdAttr;
     protected final Attribute _pingTimeAttr;
 
-    protected final HostDetailsDaoImpl _detailsDao = ComponentLocator.inject(HostDetailsDaoImpl.class);
-    protected final HostTagsDaoImpl _hostTagsDao = ComponentLocator.inject(HostTagsDaoImpl.class);
-    protected final HostTransferMapDaoImpl _hostTransferDao = ComponentLocator.inject(HostTransferMapDaoImpl.class);
-    protected final ClusterDaoImpl _clusterDao = ComponentLocator.inject(ClusterDaoImpl.class);
+    @Inject protected HostDetailsDaoImpl _detailsDao;
+    @Inject protected HostTagsDaoImpl _hostTagsDao;
+    @Inject protected HostTransferMapDaoImpl _hostTransferDao;
+    @Inject protected ClusterDaoImpl _clusterDao;
     
 
     public HostDaoImpl() {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/network/dao/FirewallRulesDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/FirewallRulesDaoImpl.java b/server/src/com/cloud/network/dao/FirewallRulesDaoImpl.java
index 73fdf22..4b40ab4 100644
--- a/server/src/com/cloud/network/dao/FirewallRulesDaoImpl.java
+++ b/server/src/com/cloud/network/dao/FirewallRulesDaoImpl.java
@@ -19,6 +19,7 @@ package com.cloud.network.dao;
 import java.util.List;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.springframework.stereotype.Component;
 
@@ -54,8 +55,8 @@ public class FirewallRulesDaoImpl extends GenericDaoBase<FirewallRuleVO, Long> i
     protected final SearchBuilder<FirewallRuleVO> SystemRuleSearch;
     protected final GenericSearchBuilder<FirewallRuleVO, Long> RulesByIpCount;
 
-    protected final FirewallRulesCidrsDaoImpl _firewallRulesCidrsDao = ComponentLocator.inject(FirewallRulesCidrsDaoImpl.class);
-    ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
+    @Inject protected FirewallRulesCidrsDaoImpl _firewallRulesCidrsDao;
+    @Inject ResourceTagsDaoImpl _tagsDao;
 
     protected FirewallRulesDaoImpl() {
         super();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/network/dao/IPAddressDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/IPAddressDaoImpl.java b/server/src/com/cloud/network/dao/IPAddressDaoImpl.java
index 28757d2..5b0a8d1 100755
--- a/server/src/com/cloud/network/dao/IPAddressDaoImpl.java
+++ b/server/src/com/cloud/network/dao/IPAddressDaoImpl.java
@@ -22,6 +22,7 @@ import java.util.Date;
 import java.util.List;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
@@ -57,9 +58,9 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, Long> implemen
     protected final GenericSearchBuilder<IPAddressVO, Integer> AllocatedIpCount;
     protected final GenericSearchBuilder<IPAddressVO, Integer> AllIpCountForDashboard;    
     protected final GenericSearchBuilder<IPAddressVO, Long> AllocatedIpCountForAccount;    
-    protected final VlanDaoImpl _vlanDao = ComponentLocator.inject(VlanDaoImpl.class);
+    @Inject protected VlanDaoImpl _vlanDao;
     protected GenericSearchBuilder<IPAddressVO, Long> CountFreePublicIps;
-    ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
+    @Inject ResourceTagsDaoImpl _tagsDao;
     
     
     // make it public for JUnit test

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java b/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
index 35f0692..31180db 100644
--- a/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
+++ b/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
@@ -52,7 +53,7 @@ public class LoadBalancerDaoImpl extends GenericDaoBase<LoadBalancerVO, Long> im
     private final SearchBuilder<LoadBalancerVO> AccountAndNameSearch;
     protected final SearchBuilder<LoadBalancerVO> TransitionStateSearch;
 
-    protected final FirewallRulesCidrsDaoImpl _portForwardingRulesCidrsDao = ComponentLocator.inject(FirewallRulesCidrsDaoImpl.class);
+    @Inject protected FirewallRulesCidrsDaoImpl _portForwardingRulesCidrsDao;
 
     protected LoadBalancerDaoImpl() {
         ListByIp = createSearchBuilder();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/network/dao/NetworkDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/NetworkDaoImpl.java b/server/src/com/cloud/network/dao/NetworkDaoImpl.java
index 71fcac9..bb48e45 100644
--- a/server/src/com/cloud/network/dao/NetworkDaoImpl.java
+++ b/server/src/com/cloud/network/dao/NetworkDaoImpl.java
@@ -21,6 +21,7 @@ import java.util.Map;
 import java.util.Random;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 import javax.persistence.TableGenerator;
 
 import org.springframework.stereotype.Component;
@@ -77,12 +78,12 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
     final GenericSearchBuilder<NetworkVO, Long> VpcNetworksCount;
     
     
-    ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
-    NetworkAccountDaoImpl _accountsDao = ComponentLocator.inject(NetworkAccountDaoImpl.class);
-    NetworkDomainDaoImpl _domainsDao = ComponentLocator.inject(NetworkDomainDaoImpl.class);
-    NetworkOpDaoImpl _opDao = ComponentLocator.inject(NetworkOpDaoImpl.class);
-    NetworkServiceMapDaoImpl _ntwkSvcMap = ComponentLocator.inject(NetworkServiceMapDaoImpl.class);
-    NetworkOfferingDaoImpl _ntwkOffDao = ComponentLocator.inject(NetworkOfferingDaoImpl.class);
+    @Inject ResourceTagsDaoImpl _tagsDao;
+    @Inject NetworkAccountDaoImpl _accountsDao;
+    @Inject NetworkDomainDaoImpl _domainsDao;
+    @Inject NetworkOpDaoImpl _opDao;
+    @Inject NetworkServiceMapDaoImpl _ntwkSvcMap;
+    @Inject NetworkOfferingDaoImpl _ntwkOffDao;
 
 
     final TableGenerator _tgMacAddress;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/network/dao/PhysicalNetworkDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/PhysicalNetworkDaoImpl.java b/server/src/com/cloud/network/dao/PhysicalNetworkDaoImpl.java
index d96da60..e1603db 100644
--- a/server/src/com/cloud/network/dao/PhysicalNetworkDaoImpl.java
+++ b/server/src/com/cloud/network/dao/PhysicalNetworkDaoImpl.java
@@ -19,6 +19,7 @@ package com.cloud.network.dao;
 import java.util.List;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.springframework.stereotype.Component;
 
@@ -39,7 +40,7 @@ import com.cloud.utils.db.SearchCriteria.Op;
 public class PhysicalNetworkDaoImpl extends GenericDaoBase<PhysicalNetworkVO, Long> implements PhysicalNetworkDao {
     final SearchBuilder<PhysicalNetworkVO> ZoneSearch;
     
-    protected final PhysicalNetworkTrafficTypeDaoImpl _trafficTypeDao = ComponentLocator.inject(PhysicalNetworkTrafficTypeDaoImpl.class);
+    @Inject protected PhysicalNetworkTrafficTypeDaoImpl _trafficTypeDao;
     
     protected PhysicalNetworkDaoImpl() {
         super();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/network/dao/Site2SiteVpnConnectionDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/Site2SiteVpnConnectionDaoImpl.java b/server/src/com/cloud/network/dao/Site2SiteVpnConnectionDaoImpl.java
index 5e5e34e..fbed906 100644
--- a/server/src/com/cloud/network/dao/Site2SiteVpnConnectionDaoImpl.java
+++ b/server/src/com/cloud/network/dao/Site2SiteVpnConnectionDaoImpl.java
@@ -19,6 +19,7 @@ package com.cloud.network.dao;
 import java.util.List;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
@@ -37,8 +38,8 @@ import com.cloud.utils.db.SearchCriteria;
 public class Site2SiteVpnConnectionDaoImpl extends GenericDaoBase<Site2SiteVpnConnectionVO, Long> implements Site2SiteVpnConnectionDao {
     private static final Logger s_logger = Logger.getLogger(Site2SiteVpnConnectionDaoImpl.class);
 
-    protected final IPAddressDaoImpl _addrDao = ComponentLocator.inject(IPAddressDaoImpl.class);
-    protected final Site2SiteVpnGatewayDaoImpl _vpnGatewayDao = ComponentLocator.inject(Site2SiteVpnGatewayDaoImpl.class);
+    @Inject protected IPAddressDaoImpl _addrDao;
+    @Inject protected Site2SiteVpnGatewayDaoImpl _vpnGatewayDao;
     
     private final SearchBuilder<Site2SiteVpnConnectionVO> AllFieldsSearch;
     private final SearchBuilder<Site2SiteVpnConnectionVO> VpcSearch;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/network/dao/Site2SiteVpnGatewayDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/Site2SiteVpnGatewayDaoImpl.java b/server/src/com/cloud/network/dao/Site2SiteVpnGatewayDaoImpl.java
index 5bf4b94..b5e0ad5 100644
--- a/server/src/com/cloud/network/dao/Site2SiteVpnGatewayDaoImpl.java
+++ b/server/src/com/cloud/network/dao/Site2SiteVpnGatewayDaoImpl.java
@@ -17,6 +17,7 @@
 package com.cloud.network.dao;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
@@ -30,7 +31,7 @@ import com.cloud.utils.db.SearchCriteria;
 @Component
 @Local(value={Site2SiteVpnGatewayDao.class})
 public class Site2SiteVpnGatewayDaoImpl extends GenericDaoBase<Site2SiteVpnGatewayVO, Long> implements Site2SiteVpnGatewayDao {
-    protected final IPAddressDaoImpl _addrDao = ComponentLocator.inject(IPAddressDaoImpl.class);
+    @Inject protected IPAddressDaoImpl _addrDao;
     
     private static final Logger s_logger = Logger.getLogger(Site2SiteVpnGatewayDaoImpl.class);
     

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/network/rules/FirewallRuleVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/FirewallRuleVO.java b/server/src/com/cloud/network/rules/FirewallRuleVO.java
index c253931..14367a7 100644
--- a/server/src/com/cloud/network/rules/FirewallRuleVO.java
+++ b/server/src/com/cloud/network/rules/FirewallRuleVO.java
@@ -20,6 +20,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.UUID;
 
+import javax.inject.Inject;
 import javax.persistence.Column;
 import javax.persistence.DiscriminatorColumn;
 import javax.persistence.DiscriminatorType;
@@ -45,7 +46,7 @@ import com.cloud.utils.net.NetUtils;
 @Inheritance(strategy=InheritanceType.JOINED)
 @DiscriminatorColumn(name="purpose", discriminatorType=DiscriminatorType.STRING, length=32)
 public class FirewallRuleVO implements Identity, FirewallRule {
-    protected final FirewallRulesCidrsDaoImpl _firewallRulesCidrsDao = ComponentLocator.inject(FirewallRulesCidrsDaoImpl.class);
+    @Inject protected final FirewallRulesCidrsDaoImpl _firewallRulesCidrsDao;
     
     @Id
     @GeneratedValue(strategy=GenerationType.IDENTITY)

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java b/server/src/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java
index 64c3f50..119ab3d 100644
--- a/server/src/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java
+++ b/server/src/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java
@@ -19,6 +19,7 @@ package com.cloud.network.rules.dao;
 import java.util.List;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.springframework.stereotype.Component;
 
@@ -42,7 +43,7 @@ public class PortForwardingRulesDaoImpl extends GenericDaoBase<PortForwardingRul
     protected final SearchBuilder<PortForwardingRuleVO> AllRulesSearchByVM;
     protected final SearchBuilder<PortForwardingRuleVO> ActiveRulesSearchByAccount;
 
-    protected final FirewallRulesCidrsDaoImpl _portForwardingRulesCidrsDao = ComponentLocator.inject(FirewallRulesCidrsDaoImpl.class);
+    @Inject protected FirewallRulesCidrsDaoImpl _portForwardingRulesCidrsDao;
     
     protected PortForwardingRulesDaoImpl() {
         super();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java b/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java
index 27ab309..bd44328 100644
--- a/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java
+++ b/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java
@@ -19,6 +19,7 @@ package com.cloud.network.security.dao;
 import java.util.List;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.springframework.stereotype.Component;
 
@@ -38,7 +39,7 @@ public class SecurityGroupDaoImpl extends GenericDaoBase<SecurityGroupVO, Long>
     private SearchBuilder<SecurityGroupVO> AccountIdSearch;
     private SearchBuilder<SecurityGroupVO> AccountIdNameSearch;
     private SearchBuilder<SecurityGroupVO> AccountIdNamesSearch;
-    ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
+    @Inject ResourceTagsDaoImpl _tagsDao;
 
 
     protected SecurityGroupDaoImpl() {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/network/vpc/dao/StaticRouteDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/dao/StaticRouteDaoImpl.java b/server/src/com/cloud/network/vpc/dao/StaticRouteDaoImpl.java
index 42f0fc4..c5270f8 100644
--- a/server/src/com/cloud/network/vpc/dao/StaticRouteDaoImpl.java
+++ b/server/src/com/cloud/network/vpc/dao/StaticRouteDaoImpl.java
@@ -19,6 +19,7 @@ package com.cloud.network.vpc.dao;
 import java.util.List;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.springframework.stereotype.Component;
 
@@ -43,7 +44,7 @@ public class StaticRouteDaoImpl extends GenericDaoBase<StaticRouteVO, Long> impl
     protected final SearchBuilder<StaticRouteVO> AllFieldsSearch;
     protected final SearchBuilder<StaticRouteVO> NotRevokedSearch;
     protected final GenericSearchBuilder<StaticRouteVO, Long> RoutesByGatewayCount;
-    ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
+    @Inject ResourceTagsDaoImpl _tagsDao;
     
     protected StaticRouteDaoImpl() {
         super();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/network/vpc/dao/VpcDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/dao/VpcDaoImpl.java b/server/src/com/cloud/network/vpc/dao/VpcDaoImpl.java
index a3bb7d5..b7e4d30 100644
--- a/server/src/com/cloud/network/vpc/dao/VpcDaoImpl.java
+++ b/server/src/com/cloud/network/vpc/dao/VpcDaoImpl.java
@@ -19,6 +19,7 @@ package com.cloud.network.vpc.dao;
 import java.util.List;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.springframework.stereotype.Component;
 
@@ -43,7 +44,7 @@ public class VpcDaoImpl extends GenericDaoBase<VpcVO, Long> implements VpcDao{
     final GenericSearchBuilder<VpcVO, Integer> CountByOfferingId;
     final SearchBuilder<VpcVO> AllFieldsSearch;
     final GenericSearchBuilder<VpcVO, Long> CountByAccountId;
-    ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
+    @Inject ResourceTagsDaoImpl _tagsDao;
 
     protected VpcDaoImpl() {
         super();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/projects/dao/ProjectDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/projects/dao/ProjectDaoImpl.java b/server/src/com/cloud/projects/dao/ProjectDaoImpl.java
index 9a4c4f1..52ab141 100644
--- a/server/src/com/cloud/projects/dao/ProjectDaoImpl.java
+++ b/server/src/com/cloud/projects/dao/ProjectDaoImpl.java
@@ -19,6 +19,7 @@ package com.cloud.projects.dao;
 import java.util.List;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
@@ -43,7 +44,8 @@ public class ProjectDaoImpl extends GenericDaoBase<ProjectVO, Long> implements P
     protected final SearchBuilder<ProjectVO> AllFieldsSearch;
     protected GenericSearchBuilder<ProjectVO, Long> CountByDomain;
     protected GenericSearchBuilder<ProjectVO, Long> ProjectAccountSearch;
-    ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
+    // ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
+    @Inject ResourceTagsDaoImpl _tagsDao;
 
     protected ProjectDaoImpl() {
         AllFieldsSearch = createSearchBuilder();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/storage/dao/SnapshotDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/dao/SnapshotDaoImpl.java b/server/src/com/cloud/storage/dao/SnapshotDaoImpl.java
index 30569a0..9a52d4c 100644
--- a/server/src/com/cloud/storage/dao/SnapshotDaoImpl.java
+++ b/server/src/com/cloud/storage/dao/SnapshotDaoImpl.java
@@ -21,6 +21,7 @@ import java.sql.ResultSet;
 import java.util.List;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
@@ -64,10 +65,10 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements
     private final SearchBuilder<SnapshotVO> InstanceIdSearch;
     private final SearchBuilder<SnapshotVO> StatusSearch;
     private final GenericSearchBuilder<SnapshotVO, Long> CountSnapshotsByAccount;
-    ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
+    @Inject ResourceTagsDaoImpl _tagsDao;
     
-    protected final VMInstanceDaoImpl _instanceDao = ComponentLocator.inject(VMInstanceDaoImpl.class);
-    protected final VolumeDaoImpl _volumeDao = ComponentLocator.inject(VolumeDaoImpl.class);
+    @Inject protected VMInstanceDaoImpl _instanceDao;
+    @Inject protected VolumeDaoImpl _volumeDao;
 
     @Override
     public SnapshotVO findNextSnapshot(long snapshotId) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java b/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java
index 3573649..9a50189 100644
--- a/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java
+++ b/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java
@@ -25,6 +25,7 @@ import java.util.List;
 import java.util.Map;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
 import org.springframework.stereotype.Component;
@@ -56,7 +57,7 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long>  imp
 
     
     
-    protected final StoragePoolDetailsDao _detailsDao;
+    @Inject protected StoragePoolDetailsDao _detailsDao;
 	
     private final String DetailsSqlPrefix = "SELECT storage_pool.* from storage_pool LEFT JOIN storage_pool_details ON storage_pool.id = storage_pool_details.pool_id WHERE storage_pool.removed is null and storage_pool.data_center_id = ? and (storage_pool.pod_id = ? or storage_pool.pod_id is null) and (";
 	private final String DetailsSqlSuffix = ") GROUP BY storage_pool_details.pool_id HAVING COUNT(storage_pool_details.name) >= ?";
@@ -105,7 +106,6 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long>  imp
         StatusCountSearch.select(null, Func.COUNT, null);
         StatusCountSearch.done();
 
-        _detailsDao = ComponentLocator.inject(StoragePoolDetailsDaoImpl.class);
     }
     
 	@Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java b/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
index 5f41730..cd597bc 100755
--- a/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
+++ b/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
@@ -109,7 +109,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
     private SearchBuilder<VMTemplateVO> UserIsoSearch;
     private GenericSearchBuilder<VMTemplateVO, Long> CountTemplatesByAccount;
 
-    ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
+    @Inject ResourceTagsDaoImpl _tagsDao;
 
 
     private String routerTmpltName;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/storage/dao/VolumeDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/dao/VolumeDaoImpl.java b/server/src/com/cloud/storage/dao/VolumeDaoImpl.java
index 065f50b..d4cc692 100755
--- a/server/src/com/cloud/storage/dao/VolumeDaoImpl.java
+++ b/server/src/com/cloud/storage/dao/VolumeDaoImpl.java
@@ -24,6 +24,7 @@ import java.util.Date;
 import java.util.List;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
@@ -50,6 +51,7 @@ import com.cloud.utils.db.Transaction;
 import com.cloud.utils.db.UpdateBuilder;
 import com.cloud.utils.exception.CloudRuntimeException;
 
+@Component
 @Local(value=VolumeDao.class)
 public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements VolumeDao {
     private static final Logger s_logger = Logger.getLogger(VolumeDaoImpl.class);
@@ -60,7 +62,8 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
     protected final SearchBuilder<VolumeVO> InstanceStatesSearch;
     protected final SearchBuilder<VolumeVO> AllFieldsSearch;
     protected GenericSearchBuilder<VolumeVO, Long> CountByAccount;
-    ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
+    // ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
+    @Inject ResourceTagsDaoImpl _tagsDao;
     
     protected static final String SELECT_VM_SQL = "SELECT DISTINCT instance_id from volumes v where v.host_id = ? and v.mirror_state = ?";
     protected static final String SELECT_HYPERTYPE_FROM_VOLUME = "SELECT c.hypervisor_type from volumes v, storage_pool s, cluster c where v.pool_id = s.id and s.cluster_id = c.id and v.id = ?";

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/259e6d5f/server/src/com/cloud/upgrade/DatabaseIntegrityChecker.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/upgrade/DatabaseIntegrityChecker.java b/server/src/com/cloud/upgrade/DatabaseIntegrityChecker.java
index e085d93..d6e55a9 100755
--- a/server/src/com/cloud/upgrade/DatabaseIntegrityChecker.java
+++ b/server/src/com/cloud/upgrade/DatabaseIntegrityChecker.java
@@ -22,6 +22,7 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
@@ -40,10 +41,9 @@ import com.cloud.utils.exception.CloudRuntimeException;
 public class DatabaseIntegrityChecker implements SystemIntegrityChecker {
 	private final Logger s_logger = Logger.getLogger(DatabaseIntegrityChecker.class);
 	
-    VersionDao _dao;
+    @Inject VersionDao _dao;
     
     public DatabaseIntegrityChecker() {
-        _dao = ComponentLocator.inject(VersionDaoImpl.class);
     }
 	
 	/*


Mime
View raw message