cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject [3/7] CLOUDSTACK-1339: Using Sping interface injection pattern to avoid using CGLIB proxying mode. Spring with CGLIB proxying will concflict with CGLIB usage in CloudStack DB code, CloudStack CGLIB usage can cause Spring to lose tack of its proxied objec
Date Wed, 06 Mar 2013 01:11:38 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index 4c61aec..8792037 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -113,6 +113,7 @@ import com.cloud.utils.AnnotationHelper;
 import com.cloud.utils.Journal;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
+import com.cloud.utils.component.ComponentContext;
 import com.cloud.utils.component.Manager;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.db.*;
@@ -2978,10 +2979,12 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
 
         PhysicalNetworkServiceProvider nsp = addProviderToPhysicalNetwork(physicalNetworkId, Network.Provider.VirtualRouter.getName(), null, null);
         // add instance of the provider
-        VirtualRouterElement element = (VirtualRouterElement) _networkModel.getElementImplementingProvider(Network.Provider.VirtualRouter.getName());
-        if (element == null) {
+        NetworkElement networkElement = _networkModel.getElementImplementingProvider(Network.Provider.VirtualRouter.getName());
+        if (networkElement == null) {
             throw new CloudRuntimeException("Unable to find the Network Element implementing the VirtualRouter Provider");
         }
+        
+        VirtualRouterElement element = ComponentContext.getTargetObject(networkElement);
         element.addElement(nsp.getId(), VirtualRouterProviderType.VirtualRouter);
 
         return nsp;
@@ -3003,11 +3006,13 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
 
         PhysicalNetworkServiceProvider nsp = addProviderToPhysicalNetwork(physicalNetworkId, 
                 Network.Provider.VPCVirtualRouter.getName(), null, null);
-        // add instance of the provider
-        VpcVirtualRouterElement element = (VpcVirtualRouterElement) _networkModel.getElementImplementingProvider(Network.Provider.VPCVirtualRouter.getName());
-        if (element == null) {
+ 
+        NetworkElement networkElement =  _networkModel.getElementImplementingProvider(Network.Provider.VPCVirtualRouter.getName());
+        if (networkElement == null) {
             throw new CloudRuntimeException("Unable to find the Network Element implementing the VPCVirtualRouter Provider");
         }
+        
+        VpcVirtualRouterElement element = ComponentContext.getTargetObject(networkElement);
         element.addElement(nsp.getId(), VirtualRouterProviderType.VPCVirtualRouter);
 
         return nsp;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/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 57a5f85..45a8068 100644
--- a/server/src/com/cloud/network/dao/FirewallRulesDaoImpl.java
+++ b/server/src/com/cloud/network/dao/FirewallRulesDaoImpl.java
@@ -30,6 +30,7 @@ import com.cloud.network.rules.FirewallRule.State;
 import com.cloud.network.rules.FirewallRule.TrafficType;
 import com.cloud.network.rules.FirewallRuleVO;
 import com.cloud.server.ResourceTag.TaggedResourceType;
+import com.cloud.tags.dao.ResourceTagDao;
 import com.cloud.tags.dao.ResourceTagsDaoImpl;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.GenericDaoBase;
@@ -53,8 +54,8 @@ public class FirewallRulesDaoImpl extends GenericDaoBase<FirewallRuleVO, Long> i
     protected final SearchBuilder<FirewallRuleVO> SystemRuleSearch;
     protected final GenericSearchBuilder<FirewallRuleVO, Long> RulesByIpCount;
 
-    @Inject protected FirewallRulesCidrsDaoImpl _firewallRulesCidrsDao;
-    @Inject ResourceTagsDaoImpl _tagsDao;
+    @Inject protected FirewallRulesCidrsDao _firewallRulesCidrsDao;
+    @Inject ResourceTagDao _tagsDao;
     @Inject IPAddressDao _ipDao;
 
     protected FirewallRulesDaoImpl() {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/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 691e460..b0eef4f 100755
--- a/server/src/com/cloud/network/dao/IPAddressDaoImpl.java
+++ b/server/src/com/cloud/network/dao/IPAddressDaoImpl.java
@@ -30,9 +30,11 @@ import org.springframework.stereotype.Component;
 
 import com.cloud.dc.Vlan.VlanType;
 import com.cloud.dc.VlanVO;
+import com.cloud.dc.dao.VlanDao;
 import com.cloud.dc.dao.VlanDaoImpl;
 import com.cloud.network.IpAddress.State;
 import com.cloud.server.ResourceTag.TaggedResourceType;
+import com.cloud.tags.dao.ResourceTagDao;
 import com.cloud.tags.dao.ResourceTagsDaoImpl;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.GenericDaoBase;
@@ -57,9 +59,9 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, Long> implemen
     protected GenericSearchBuilder<IPAddressVO, Integer> AllocatedIpCount;
     protected GenericSearchBuilder<IPAddressVO, Integer> AllIpCountForDashboard;    
     protected GenericSearchBuilder<IPAddressVO, Long> AllocatedIpCountForAccount;    
-    @Inject protected VlanDaoImpl _vlanDao;
+    @Inject protected VlanDao _vlanDao;
     protected GenericSearchBuilder<IPAddressVO, Long> CountFreePublicIps;
-    @Inject ResourceTagsDaoImpl _tagsDao;
+    @Inject ResourceTagDao _tagsDao;
 
     // make it public for JUnit test
     public IPAddressDaoImpl() {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/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 547dc60..f211a7f 100644
--- a/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
+++ b/server/src/com/cloud/network/dao/LoadBalancerDaoImpl.java
@@ -51,7 +51,7 @@ public class LoadBalancerDaoImpl extends GenericDaoBase<LoadBalancerVO, Long> im
     private final SearchBuilder<LoadBalancerVO> AccountAndNameSearch;
     protected final SearchBuilder<LoadBalancerVO> TransitionStateSearch;
 
-    @Inject protected FirewallRulesCidrsDaoImpl _portForwardingRulesCidrsDao;
+    @Inject protected FirewallRulesCidrsDao _portForwardingRulesCidrsDao;
 
     protected LoadBalancerDaoImpl() {
         ListByIp = createSearchBuilder();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/server/src/com/cloud/network/dao/NetworkAccountDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/NetworkAccountDao.java b/server/src/com/cloud/network/dao/NetworkAccountDao.java
new file mode 100644
index 0000000..c4435c8
--- /dev/null
+++ b/server/src/com/cloud/network/dao/NetworkAccountDao.java
@@ -0,0 +1,22 @@
+// 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.network.dao;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface NetworkAccountDao extends GenericDao<NetworkAccountVO, Long> {
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/server/src/com/cloud/network/dao/NetworkAccountDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/NetworkAccountDaoImpl.java b/server/src/com/cloud/network/dao/NetworkAccountDaoImpl.java
index f0b7156..0947905 100644
--- a/server/src/com/cloud/network/dao/NetworkAccountDaoImpl.java
+++ b/server/src/com/cloud/network/dao/NetworkAccountDaoImpl.java
@@ -22,7 +22,7 @@ import com.cloud.utils.db.GenericDao;
 import com.cloud.utils.db.GenericDaoBase;
 
 @Component
-public class NetworkAccountDaoImpl extends GenericDaoBase<NetworkAccountVO, Long> implements GenericDao<NetworkAccountVO, Long> {
+public class NetworkAccountDaoImpl extends GenericDaoBase<NetworkAccountVO, Long> implements NetworkAccountDao {
     public NetworkAccountDaoImpl() {
         super();
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/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 43c581f..1bc8973 100644
--- a/server/src/com/cloud/network/dao/NetworkDaoImpl.java
+++ b/server/src/com/cloud/network/dao/NetworkDaoImpl.java
@@ -39,13 +39,11 @@ import com.cloud.network.Networks.Mode;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offerings.NetworkOfferingVO;
+import com.cloud.offerings.dao.NetworkOfferingDao;
 import com.cloud.offerings.dao.NetworkOfferingDaoImpl;
 import com.cloud.server.ResourceTag.TaggedResourceType;
+import com.cloud.tags.dao.ResourceTagDao;
 import com.cloud.tags.dao.ResourceTagsDaoImpl;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.GenericSearchBuilder;
-import com.cloud.utils.db.JoinBuilder;
 import com.cloud.utils.db.*;
 import com.cloud.utils.db.JoinBuilder.JoinType;
 import com.cloud.utils.db.SearchCriteria.Func;
@@ -76,13 +74,13 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
     
     
     
-    @Inject ResourceTagsDaoImpl _tagsDao;
-    @Inject NetworkAccountDaoImpl _accountsDao;
-    @Inject NetworkDomainDaoImpl _domainsDao;
-    @Inject NetworkOpDaoImpl _opDao;
-    @Inject NetworkServiceMapDaoImpl _ntwkSvcMap;
-    @Inject NetworkOfferingDaoImpl _ntwkOffDao;
-    @Inject NetworkOpDaoImpl _ntwkOpDao;
+    @Inject ResourceTagDao _tagsDao;
+    @Inject NetworkAccountDao _accountsDao;
+    @Inject NetworkDomainDao _domainsDao;
+    @Inject NetworkOpDao _opDao;
+    @Inject NetworkServiceMapDao _ntwkSvcMap;
+    @Inject NetworkOfferingDao _ntwkOffDao;
+    @Inject NetworkOpDao _ntwkOpDao;
 
     TableGenerator _tgMacAddress;
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/server/src/com/cloud/network/dao/NetworkOpDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/NetworkOpDao.java b/server/src/com/cloud/network/dao/NetworkOpDao.java
new file mode 100644
index 0000000..f492dbd
--- /dev/null
+++ b/server/src/com/cloud/network/dao/NetworkOpDao.java
@@ -0,0 +1,26 @@
+// 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.network.dao;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface NetworkOpDao extends GenericDao<NetworkOpVO, Long> {
+    public int getActiveNics(long networkId);
+    public void changeActiveNicsBy(long networkId, int count);
+    public void setCheckForGc(long networkId);
+    public void clearCheckForGc(long networkId);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/server/src/com/cloud/network/dao/NetworkOpDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/NetworkOpDaoImpl.java b/server/src/com/cloud/network/dao/NetworkOpDaoImpl.java
index bdc9f50..a3f54b7 100644
--- a/server/src/com/cloud/network/dao/NetworkOpDaoImpl.java
+++ b/server/src/com/cloud/network/dao/NetworkOpDaoImpl.java
@@ -30,7 +30,7 @@ import com.cloud.utils.db.SearchCriteria.Op;
 import com.cloud.utils.db.UpdateBuilder;
 
 @Component
-public class NetworkOpDaoImpl extends GenericDaoBase<NetworkOpVO, Long> implements GenericDao<NetworkOpVO, Long> {
+public class NetworkOpDaoImpl extends GenericDaoBase<NetworkOpVO, Long> implements NetworkOpDao {
     protected final SearchBuilder<NetworkOpVO> AllFieldsSearch;
     protected final GenericSearchBuilder<NetworkOpVO, Integer> ActiveNicsSearch;
     protected final Attribute _activeNicsAttribute;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/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 8e67d8b..1e26a51 100644
--- a/server/src/com/cloud/network/dao/PhysicalNetworkDaoImpl.java
+++ b/server/src/com/cloud/network/dao/PhysicalNetworkDaoImpl.java
@@ -36,7 +36,7 @@ import com.cloud.utils.db.SearchCriteria.Op;
 public class PhysicalNetworkDaoImpl extends GenericDaoBase<PhysicalNetworkVO, Long> implements PhysicalNetworkDao {
     final SearchBuilder<PhysicalNetworkVO> ZoneSearch;
 
-    @Inject protected PhysicalNetworkTrafficTypeDaoImpl _trafficTypeDao;
+    @Inject protected PhysicalNetworkTrafficTypeDao _trafficTypeDao;
 
     protected PhysicalNetworkDaoImpl() {
         super();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/server/src/com/cloud/network/dao/RouterNetworkDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/RouterNetworkDao.java b/server/src/com/cloud/network/dao/RouterNetworkDao.java
new file mode 100644
index 0000000..bd275bd
--- /dev/null
+++ b/server/src/com/cloud/network/dao/RouterNetworkDao.java
@@ -0,0 +1,26 @@
+// 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.network.dao;
+
+import java.util.List;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface RouterNetworkDao extends GenericDao<RouterNetworkVO, Long> {
+    public List<Long> getRouterNetworks(long routerId); 
+    public RouterNetworkVO findByRouterAndNetwork (long routerId, long networkId);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/server/src/com/cloud/network/dao/RouterNetworkDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/dao/RouterNetworkDaoImpl.java b/server/src/com/cloud/network/dao/RouterNetworkDaoImpl.java
index e560713..b0b633c 100644
--- a/server/src/com/cloud/network/dao/RouterNetworkDaoImpl.java
+++ b/server/src/com/cloud/network/dao/RouterNetworkDaoImpl.java
@@ -28,7 +28,7 @@ import com.cloud.utils.db.SearchCriteria;
 import com.cloud.utils.db.SearchCriteria.Op;
 
 @Component
-public class RouterNetworkDaoImpl extends GenericDaoBase<RouterNetworkVO, Long> implements GenericDao<RouterNetworkVO, Long>{
+public class RouterNetworkDaoImpl extends GenericDaoBase<RouterNetworkVO, Long> implements RouterNetworkDao {
     protected final GenericSearchBuilder<RouterNetworkVO, Long> RouterNetworksSearch;
     protected final SearchBuilder<RouterNetworkVO> AllFieldsSearch;
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/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 2830abe..4745f9a 100644
--- a/server/src/com/cloud/network/dao/Site2SiteVpnConnectionDaoImpl.java
+++ b/server/src/com/cloud/network/dao/Site2SiteVpnConnectionDaoImpl.java
@@ -35,8 +35,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);
 
-    @Inject protected IPAddressDaoImpl _addrDao;
-    @Inject protected Site2SiteVpnGatewayDaoImpl _vpnGatewayDao;
+    @Inject protected IPAddressDao _addrDao;
+    @Inject protected Site2SiteVpnGatewayDao _vpnGatewayDao;
 
     private SearchBuilder<Site2SiteVpnConnectionVO> AllFieldsSearch;
     private SearchBuilder<Site2SiteVpnConnectionVO> VpcSearch;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/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 8305978..fa4a9fa 100644
--- a/server/src/com/cloud/network/dao/Site2SiteVpnGatewayDaoImpl.java
+++ b/server/src/com/cloud/network/dao/Site2SiteVpnGatewayDaoImpl.java
@@ -29,7 +29,7 @@ import com.cloud.utils.db.SearchCriteria;
 @Component
 @Local(value={Site2SiteVpnGatewayDao.class})
 public class Site2SiteVpnGatewayDaoImpl extends GenericDaoBase<Site2SiteVpnGatewayVO, Long> implements Site2SiteVpnGatewayDao {
-    @Inject protected IPAddressDaoImpl _addrDao;
+    @Inject protected IPAddressDao _addrDao;
 
     private static final Logger s_logger = Logger.getLogger(Site2SiteVpnGatewayDaoImpl.class);
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/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 1d2e991..5d0b01c 100644
--- a/server/src/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java
+++ b/server/src/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java
@@ -23,6 +23,7 @@ import javax.inject.Inject;
 
 import org.springframework.stereotype.Component;
 
+import com.cloud.network.dao.FirewallRulesCidrsDao;
 import com.cloud.network.dao.FirewallRulesCidrsDaoImpl;
 import com.cloud.network.rules.FirewallRule.Purpose;
 import com.cloud.network.rules.FirewallRule.State;
@@ -44,7 +45,7 @@ public class PortForwardingRulesDaoImpl extends GenericDaoBase<PortForwardingRul
     protected final SearchBuilder<PortForwardingRuleVO> AllRulesSearchByVM;
     protected final SearchBuilder<PortForwardingRuleVO> ActiveRulesSearchByAccount;
 
-    @Inject protected FirewallRulesCidrsDaoImpl _portForwardingRulesCidrsDao;
+    @Inject protected FirewallRulesCidrsDao _portForwardingRulesCidrsDao;
     
     protected PortForwardingRulesDaoImpl() {
         super();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/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 68112c0..dfa6a2e 100644
--- a/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java
+++ b/server/src/com/cloud/network/security/dao/SecurityGroupDaoImpl.java
@@ -25,6 +25,7 @@ import org.springframework.stereotype.Component;
 
 import com.cloud.network.security.SecurityGroupVO;
 import com.cloud.server.ResourceTag.TaggedResourceType;
+import com.cloud.tags.dao.ResourceTagDao;
 import com.cloud.tags.dao.ResourceTagsDaoImpl;
 
 import com.cloud.utils.db.DB;
@@ -39,7 +40,7 @@ public class SecurityGroupDaoImpl extends GenericDaoBase<SecurityGroupVO, Long>
     private SearchBuilder<SecurityGroupVO> AccountIdSearch;
     private SearchBuilder<SecurityGroupVO> AccountIdNameSearch;
     private SearchBuilder<SecurityGroupVO> AccountIdNamesSearch;
-    @Inject ResourceTagsDaoImpl _tagsDao;
+    @Inject ResourceTagDao _tagsDao;
 
 
     protected SecurityGroupDaoImpl() {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/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 0ebccab..fac35a9 100644
--- a/server/src/com/cloud/network/vpc/dao/StaticRouteDaoImpl.java
+++ b/server/src/com/cloud/network/vpc/dao/StaticRouteDaoImpl.java
@@ -26,6 +26,7 @@ import org.springframework.stereotype.Component;
 import com.cloud.network.vpc.StaticRoute;
 import com.cloud.network.vpc.StaticRouteVO;
 import com.cloud.server.ResourceTag.TaggedResourceType;
+import com.cloud.tags.dao.ResourceTagDao;
 import com.cloud.tags.dao.ResourceTagsDaoImpl;
 
 import com.cloud.utils.db.DB;
@@ -44,7 +45,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;
-    @Inject ResourceTagsDaoImpl _tagsDao;
+    @Inject ResourceTagDao _tagsDao;
     
     protected StaticRouteDaoImpl() {
         super();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/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 5fdf279..6560b90 100644
--- a/server/src/com/cloud/network/vpc/dao/VpcDaoImpl.java
+++ b/server/src/com/cloud/network/vpc/dao/VpcDaoImpl.java
@@ -29,7 +29,7 @@ import org.springframework.stereotype.Component;
 import com.cloud.network.vpc.Vpc;
 import com.cloud.network.vpc.VpcVO;
 import com.cloud.server.ResourceTag.TaggedResourceType;
-import com.cloud.tags.dao.ResourceTagsDaoImpl;
+import com.cloud.tags.dao.ResourceTagDao;
 
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.GenericDaoBase;
@@ -47,8 +47,9 @@ public class VpcDaoImpl extends GenericDaoBase<VpcVO, Long> implements VpcDao{
     final GenericSearchBuilder<VpcVO, Integer> CountByOfferingId;
     final SearchBuilder<VpcVO> AllFieldsSearch;
     final GenericSearchBuilder<VpcVO, Long> CountByAccountId;
-    @Inject ResourceTagsDaoImpl _tagsDao;
-    @Inject VpcServiceMapDaoImpl _vpcSvcMap;
+
+    @Inject ResourceTagDao _tagsDao;
+    @Inject VpcServiceMapDao _vpcSvcMap;
 
     protected VpcDaoImpl() {
         super();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/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 e07aecc..ecf40da 100644
--- a/server/src/com/cloud/projects/dao/ProjectDaoImpl.java
+++ b/server/src/com/cloud/projects/dao/ProjectDaoImpl.java
@@ -27,6 +27,7 @@ import org.springframework.stereotype.Component;
 import com.cloud.projects.Project;
 import com.cloud.projects.ProjectVO;
 import com.cloud.server.ResourceTag.TaggedResourceType;
+import com.cloud.tags.dao.ResourceTagDao;
 import com.cloud.tags.dao.ResourceTagsDaoImpl;
 
 import com.cloud.utils.db.DB;
@@ -45,7 +46,7 @@ public class ProjectDaoImpl extends GenericDaoBase<ProjectVO, Long> implements P
     protected GenericSearchBuilder<ProjectVO, Long> CountByDomain;
     protected GenericSearchBuilder<ProjectVO, Long> ProjectAccountSearch;
     // ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
-    @Inject ResourceTagsDaoImpl _tagsDao;
+    @Inject ResourceTagDao _tagsDao;
 
     protected ProjectDaoImpl() {
         AllFieldsSearch = createSearchBuilder();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/server/src/com/cloud/servlet/CloudStartupServlet.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/servlet/CloudStartupServlet.java b/server/src/com/cloud/servlet/CloudStartupServlet.java
index 46be093..2cabe15 100755
--- a/server/src/com/cloud/servlet/CloudStartupServlet.java
+++ b/server/src/com/cloud/servlet/CloudStartupServlet.java
@@ -16,6 +16,9 @@
 // under the License.
 package com.cloud.servlet;
 
+import java.util.Timer;
+import java.util.TimerTask;
+
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
@@ -31,10 +34,22 @@ public class CloudStartupServlet extends HttpServlet {
     public static final Logger s_logger = Logger.getLogger(CloudStartupServlet.class.getName());
     static final long serialVersionUID = SerialVersionUID.CloudStartupServlet;
     
+    Timer _timer = new Timer();
+    
     @Override
     public void init(ServletConfig config) throws ServletException {
     	LogUtils.initLog4j("log4j-cloud.xml");
     	SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this, config.getServletContext());       	
-    	ComponentContext.initComponentsLifeCycle();
+    	
+    	// wait when condition is ready for initialization
+    	_timer.scheduleAtFixedRate(new TimerTask() {
+			@Override
+			public void run() {
+				if(ComponentContext.getApplicationContext() != null) {
+					_timer.cancel();
+					ComponentContext.initComponentsLifeCycle();
+				}
+			}
+    	}, 0, 1000);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/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 5b3f273..825b6d5 100644
--- a/server/src/com/cloud/storage/dao/SnapshotDaoImpl.java
+++ b/server/src/com/cloud/storage/dao/SnapshotDaoImpl.java
@@ -35,16 +35,14 @@ import com.cloud.storage.Snapshot.Type;
 import com.cloud.storage.SnapshotVO;
 import com.cloud.storage.Volume;
 import com.cloud.storage.VolumeVO;
+import com.cloud.tags.dao.ResourceTagDao;
 import com.cloud.tags.dao.ResourceTagsDaoImpl;
 
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.Filter;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.GenericSearchBuilder;
 import com.cloud.utils.db.*;
 import com.cloud.utils.db.JoinBuilder.JoinType;
 import com.cloud.utils.db.SearchCriteria.Func;
 import com.cloud.vm.VMInstanceVO;
+import com.cloud.vm.dao.VMInstanceDao;
 import com.cloud.vm.dao.VMInstanceDaoImpl;
 
 @Component
@@ -66,10 +64,10 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements
     private SearchBuilder<SnapshotVO> InstanceIdSearch;
     private SearchBuilder<SnapshotVO> StatusSearch;
     private GenericSearchBuilder<SnapshotVO, Long> CountSnapshotsByAccount;
-    @Inject ResourceTagsDaoImpl _tagsDao;
+    @Inject ResourceTagDao _tagsDao;
     
-    @Inject protected VMInstanceDaoImpl _instanceDao;
-    @Inject protected VolumeDaoImpl _volumeDao;
+    @Inject protected VMInstanceDao _instanceDao;
+    @Inject protected VolumeDao _volumeDao;
 
     @Override
     public SnapshotVO findNextSnapshot(long snapshotId) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/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 ca3b82a..40ed875 100755
--- a/server/src/com/cloud/storage/dao/VolumeDaoImpl.java
+++ b/server/src/com/cloud/storage/dao/VolumeDaoImpl.java
@@ -37,6 +37,7 @@ import com.cloud.storage.Volume.Event;
 import com.cloud.storage.Volume.State;
 import com.cloud.storage.Volume.Type;
 import com.cloud.storage.VolumeVO;
+import com.cloud.tags.dao.ResourceTagDao;
 import com.cloud.tags.dao.ResourceTagsDaoImpl;
 import com.cloud.utils.Pair;
 import com.cloud.utils.db.DB;
@@ -61,8 +62,7 @@ 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);
-    @Inject ResourceTagsDaoImpl _tagsDao;
+    @Inject ResourceTagDao _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/333dd810/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java b/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java
index 5207588..391fa58 100755
--- a/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java
+++ b/server/src/com/cloud/vm/dao/DomainRouterDaoImpl.java
@@ -25,15 +25,19 @@ import javax.inject.Inject;
 import org.springframework.stereotype.Component;
 
 import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
 import com.cloud.host.dao.HostDaoImpl;
 import com.cloud.network.Network;
+import com.cloud.network.dao.RouterNetworkDao;
 import com.cloud.network.dao.RouterNetworkDaoImpl;
 import com.cloud.network.dao.RouterNetworkVO;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.network.router.VirtualRouter.Role;
 import com.cloud.offering.NetworkOffering;
+import com.cloud.offerings.dao.NetworkOfferingDao;
 import com.cloud.offerings.dao.NetworkOfferingDaoImpl;
 import com.cloud.user.UserStatisticsVO;
+import com.cloud.user.dao.UserStatisticsDao;
 import com.cloud.user.dao.UserStatisticsDaoImpl;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.GenericDaoBase;
@@ -57,10 +61,10 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
     protected SearchBuilder<DomainRouterVO> HostUpSearch;
     protected SearchBuilder<DomainRouterVO> StateNetworkTypeSearch;
     protected SearchBuilder<DomainRouterVO> OutsidePodSearch;
-    @Inject HostDaoImpl _hostsDao;
-    @Inject RouterNetworkDaoImpl _routerNetworkDao;
-    @Inject UserStatisticsDaoImpl _userStatsDao;
-    @Inject NetworkOfferingDaoImpl _offDao;
+    @Inject HostDao _hostsDao;
+    @Inject RouterNetworkDao _routerNetworkDao;
+    @Inject UserStatisticsDao _userStatsDao;
+    @Inject NetworkOfferingDao _offDao;
     protected SearchBuilder<DomainRouterVO> VpcSearch;
     
     public DomainRouterDaoImpl() {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/server/src/com/cloud/vm/dao/UserVmDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/dao/UserVmDaoImpl.java b/server/src/com/cloud/vm/dao/UserVmDaoImpl.java
index 02604fe..4922828 100755
--- a/server/src/com/cloud/vm/dao/UserVmDaoImpl.java
+++ b/server/src/com/cloud/vm/dao/UserVmDaoImpl.java
@@ -35,6 +35,7 @@ import org.springframework.stereotype.Component;
 
 import com.cloud.configuration.Resource;
 import com.cloud.server.ResourceTag.TaggedResourceType;
+import com.cloud.tags.dao.ResourceTagDao;
 import com.cloud.tags.dao.ResourceTagsDaoImpl;
 import com.cloud.user.Account;
 
@@ -79,7 +80,7 @@ public class UserVmDaoImpl extends GenericDaoBase<UserVmVO, Long> implements Use
     protected SearchBuilder<UserVmVO> UserVmByIsoSearch;
     protected Attribute _updateTimeAttr;
     // ResourceTagsDaoImpl _tagsDao = ComponentLocator.inject(ResourceTagsDaoImpl.class);
-    @Inject ResourceTagsDaoImpl _tagsDao;
+    @Inject ResourceTagDao _tagsDao;
    
     private static final String LIST_PODS_HAVING_VMS_FOR_ACCOUNT = "SELECT pod_id FROM cloud.vm_instance WHERE data_center_id = ? AND account_id = ? AND pod_id IS NOT NULL AND (state = 'Running' OR state = 'Stopped') " +
     		"GROUP BY pod_id HAVING count(id) > 0 ORDER BY count(id) DESC";

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/server/test/com/cloud/agent/MockAgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/agent/MockAgentManagerImpl.java b/server/test/com/cloud/agent/MockAgentManagerImpl.java
index bdacf68..7e3462d 100755
--- a/server/test/com/cloud/agent/MockAgentManagerImpl.java
+++ b/server/test/com/cloud/agent/MockAgentManagerImpl.java
@@ -188,4 +188,10 @@ public class MockAgentManagerImpl extends ManagerBase implements AgentManager {
         return null;
     }
 
+	@Override
+	public void disconnectWithInvestigation(long hostId, Event event) {
+		// TODO Auto-generated method stub
+		
+	}
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/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 a6affc2..e598b85 100644
--- a/utils/src/com/cloud/utils/component/ComponentContext.java
+++ b/utils/src/com/cloud/utils/component/ComponentContext.java
@@ -55,8 +55,18 @@ public class ComponentContext implements ApplicationContextAware {
 
     private static ApplicationContext s_appContext;  
 
+    private static Advisor s_advisor;
+    private static ProxyFactory s_pf;
+    static {
+        s_advisor = new DefaultPointcutAdvisor(new MatchAnyMethodPointcut(),
+                new TransactionContextBuilder());
+        s_pf = new ProxyFactory();
+        s_pf.addAdvisor(s_advisor);
+    }
+    
     @Override
-    public void setApplicationContext(ApplicationContext applicationContext) {  
+    public void setApplicationContext(ApplicationContext applicationContext) {
+    	s_logger.info("Setup Spring Application context");
         s_appContext = applicationContext;  
     }  
 
@@ -157,27 +167,24 @@ public class ComponentContext implements ApplicationContextAware {
 
     public static <T> T getComponent(Class<T> beanType) {
         assert(s_appContext != null);
-        try {
-            return s_appContext.getBean(beanType);
-        } catch(NoSuchBeanDefinitionException e) {
-            Map<String, T> matchedTypes = getComponentsOfType(beanType);
-            if(matchedTypes.size() > 0) {
-                for(Map.Entry<String, T> entry : matchedTypes.entrySet()) {
-                    Primary primary = getTargetClass(entry.getValue()).getAnnotation(Primary.class);
-                    if(primary != null)
-                        return entry.getValue();
-                }
+        Map<String, T> matchedTypes = getComponentsOfType(beanType);
+        if(matchedTypes.size() > 0) {
+            for(Map.Entry<String, T> entry : matchedTypes.entrySet()) {
+                Primary primary = getTargetClass(entry.getValue()).getAnnotation(Primary.class);
+                if(primary != null)
+                    return entry.getValue();
+            }
 
-                if(matchedTypes.size() > 1) {
-                    s_logger.warn("Unable to uniquely locate bean type " + beanType.getName());
-                    for(Map.Entry<String, T> entry : matchedTypes.entrySet()) {
-                        s_logger.warn("Candidate " + getTargetClass(entry.getValue()).getName());
-                    }
+            if(matchedTypes.size() > 1) {
+                s_logger.warn("Unable to uniquely locate bean type " + beanType.getName());
+                for(Map.Entry<String, T> entry : matchedTypes.entrySet()) {
+                    s_logger.warn("Candidate " + getTargetClass(entry.getValue()).getName());
                 }
-
-                return (T)matchedTypes.values().toArray()[0];
             }
+
+            return (T)matchedTypes.values().toArray()[0];
         }
+        
         throw new NoSuchBeanDefinitionException(beanType.getName());
     }
 
@@ -208,24 +215,19 @@ public class ComponentContext implements ApplicationContextAware {
         return (T)instance;
     }
 
-    @SuppressWarnings("unchecked")
-	public static <T> T inject(Class<T> clz) {
-        Object instance = s_appContext.getAutowireCapableBeanFactory().createBean(clz);
-        return (T)inject(instance);
+    public static <T> T inject(Class<T> clz) {
+        T instance = s_appContext.getAutowireCapableBeanFactory().createBean(clz);
+        return instance;
     }
 
     public static <T> T inject(Object instance) {
         // autowire dynamically loaded object
         AutowireCapableBeanFactory  beanFactory = s_appContext.getAutowireCapableBeanFactory();
         beanFactory.autowireBean(instance);
-
-        Advisor advisor = new DefaultPointcutAdvisor(new MatchAnyMethodPointcut(),
-                new TransactionContextBuilder());
-
-        ProxyFactory pf = new ProxyFactory();
-        pf.setTarget(instance);
-        pf.addAdvisor(advisor);
-
-        return (T)pf.getProxy();        
+        return (T)instance;
+/*
+        s_pf.setTarget(instance);
+        return (T)s_pf.getProxy();        
+*/  
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/utils/src/com/cloud/utils/db/GenericDao.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/GenericDao.java b/utils/src/com/cloud/utils/db/GenericDao.java
index c0a9029..3efc1c5 100755
--- a/utils/src/com/cloud/utils/db/GenericDao.java
+++ b/utils/src/com/cloud/utils/db/GenericDao.java
@@ -277,4 +277,6 @@ public interface GenericDao<T, ID extends Serializable> {
      * @return
      */
     Pair<List<T>, Integer> searchAndCount(SearchCriteria<T> sc, Filter filter);
+
+    Map<String, Attribute> getAllAttributes();
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/utils/src/com/cloud/utils/db/GenericDaoBase.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/GenericDaoBase.java b/utils/src/com/cloud/utils/db/GenericDaoBase.java
index cf30474..afb1247 100755
--- a/utils/src/com/cloud/utils/db/GenericDaoBase.java
+++ b/utils/src/com/cloud/utils/db/GenericDaoBase.java
@@ -68,6 +68,7 @@ import com.cloud.utils.DateUtil;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.utils.Ternary;
+import com.cloud.utils.component.ComponentContext;
 import com.cloud.utils.component.ComponentLifecycle;
 import com.cloud.utils.component.ComponentLifecycleBase;
 import com.cloud.utils.crypt.DBEncryptionUtil;
@@ -118,7 +119,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
 
     protected final static TimeZone s_gmtTimeZone = TimeZone.getTimeZone("GMT");
 
-    protected final static Map<Class<?>, GenericDaoBase<?, ? extends Serializable>> s_daoMaps = new ConcurrentHashMap<Class<?>, GenericDaoBase<?, ? extends Serializable>>(71);
+    protected final static Map<Class<?>, GenericDao<?, ? extends Serializable>> s_daoMaps = new ConcurrentHashMap<Class<?>, GenericDao<?, ? extends Serializable>>(71);
 
     protected Class<T> _entityBeanType;
     protected String _table;
@@ -128,8 +129,8 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
     protected Field[] _embeddedFields;
 
     // This is private on purpose.  Everyone should use createPartialSelectSql()
-    private final Pair<StringBuilder, Attribute[]> _partialSelectSql;
-    private final Pair<StringBuilder, Attribute[]> _partialQueryCacheSelectSql;
+    private Pair<StringBuilder, Attribute[]> _partialSelectSql;
+    private Pair<StringBuilder, Attribute[]> _partialQueryCacheSelectSql;
     protected StringBuilder _discriminatorClause;
     protected Map<String, Object> _discriminatorValues;
     protected String _selectByIdSql;
@@ -141,11 +142,11 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
     protected Pair<String, Attribute> _removed;
     protected Pair<String, Attribute[]> _removeSql;
     protected List<Pair<String, Attribute[]>> _deleteSqls;
-    protected final Map<String, Attribute[]> _idAttributes;
-    protected final Map<String, TableGenerator> _tgs;
-    protected final Map<String, Attribute> _allAttributes;
-    protected final List<Attribute> _ecAttributes;
-    protected final Map<Pair<String, String>, Attribute> _allColumns;
+    protected Map<String, Attribute[]> _idAttributes;
+    protected Map<String, TableGenerator> _tgs;
+    protected Map<String, Attribute> _allAttributes;
+    protected List<Attribute> _ecAttributes;
+    protected Map<Pair<String, String>, Attribute> _allColumns;
     protected Enhancer _enhancer;
     protected Factory _factory;
     protected Enhancer _searchEnhancer;
@@ -159,9 +160,9 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
 
     protected static final SequenceFetcher s_seqFetcher = SequenceFetcher.getInstance();
 
-    public static <J> GenericDaoBase<? extends J, ? extends Serializable> getDao(Class<J> entityType) {
+    public static <J> GenericDao<? extends J, ? extends Serializable> getDao(Class<J> entityType) {
         @SuppressWarnings("unchecked")
-        GenericDaoBase<? extends J, ? extends Serializable> dao = (GenericDaoBase<? extends J, ? extends Serializable>)s_daoMaps.get(entityType);
+        GenericDao<? extends J, ? extends Serializable> dao = (GenericDao<? extends J, ? extends Serializable>)s_daoMaps.get(entityType);
         assert dao != null : "Unable to find DAO for " + entityType + ".  Are you sure you waited for the DAO to be initialized before asking for it?";
         return dao;
     }
@@ -192,13 +193,15 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
                     ( (Class<?>)((Class<?>)t).getGenericSuperclass()).getGenericSuperclass()).getActualTypeArguments()[0];
         }
 
-        s_daoMaps.put(_entityBeanType, this);
+/*        
+        s_daoMaps.put(_entityBeanType, ComponentContext.getComponent(this.getClass()));
         Class<?>[] interphaces = _entityBeanType.getInterfaces();
         if (interphaces != null) {
             for (Class<?> interphace : interphaces) {
-                s_daoMaps.put(interphace, this);
+                s_daoMaps.put(interphace, ComponentContext.getComponent(this.getClass()));
             }
         }
+*/  
         _table = DbUtil.getTableName(_entityBeanType);
 
         final SqlGenerator generator = new SqlGenerator(_entityBeanType);
@@ -1747,6 +1750,25 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
     public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
         _name = name;
 
+        Class<?> daoInterface = null;
+        for(Class<?> intf : this.getClass().getInterfaces()) {
+        	if(GenericDao.class.isAssignableFrom(intf)) {
+        		daoInterface = intf;
+        		break;
+        	}
+        }
+ 
+        if(daoInterface != null) {
+        	s_logger.info("Register dao interface in GenericDaoBase entity-DAO map. " + daoInterface.getName());
+	        s_daoMaps.put(_entityBeanType, (GenericDao<?, ? extends Serializable>) ComponentContext.getComponent(daoInterface));
+	        Class<?>[] interphaces = _entityBeanType.getInterfaces();
+	        if (interphaces != null) {
+	            for (Class<?> interphace : interphaces) {
+	                s_daoMaps.put(interphace,  (GenericDao<?, ? extends Serializable>) ComponentContext.getComponent(daoInterface));
+	            }
+	        }
+	    }
+       
         final String value = (String)params.get("lock.timeout");
         _timeoutSeconds = NumbersUtil.parseInt(value, 300);
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/utils/src/com/cloud/utils/db/QueryBuilder.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/QueryBuilder.java b/utils/src/com/cloud/utils/db/QueryBuilder.java
index 2eb3658..3303fbd 100644
--- a/utils/src/com/cloud/utils/db/QueryBuilder.java
+++ b/utils/src/com/cloud/utils/db/QueryBuilder.java
@@ -56,21 +56,21 @@ public class QueryBuilder<S, T> implements MethodInterceptor, SimpleQueryBuilder
         }
     }
     
-    protected HashMap<Class<?>, Pair<GenericDaoBase<?,?>, Object>> _entities;
+    protected HashMap<Class<?>, Pair<GenericDao<?,?>, Object>> _entities;
     protected ArrayList<Attribute> _specifiedAttrs = new ArrayList<Attribute>();
     protected T _resultSetClass;
     protected ArrayList<Select<S, T>> _selects;
     
     public QueryBuilder(Class<T> resultSetClass, Class<?>... clazzes) {
-        _entities = new HashMap<Class<?>, Pair<GenericDaoBase<?,?>, Object>>(clazzes.length);
+        _entities = new HashMap<Class<?>, Pair<GenericDao<?,?>, Object>>(clazzes.length);
         for (Class<?> clazz : clazzes) {
-            GenericDaoBase<?,?> dao = GenericDaoBase.getDao(clazz);
+            GenericDao<?,?> dao = GenericDaoBase.getDao(clazz);
             Enhancer searchEnhancer = new Enhancer();
             searchEnhancer.setSuperclass(clazz);
             searchEnhancer.setCallback(this);
             Object entity = searchEnhancer.create();
             
-            _entities.put(clazz, new Pair<GenericDaoBase<?, ?>, Object>(dao, entity));
+            _entities.put(clazz, new Pair<GenericDao<?, ?>, Object>(dao, entity));
         }
     }
     
@@ -86,14 +86,14 @@ public class QueryBuilder<S, T> implements MethodInterceptor, SimpleQueryBuilder
      * @param resultSetClass result class to put the result set in.
      */
     public QueryBuilder(Class<S> entityClass, Class<T> resultSetClass) {
-        _entities = new HashMap<Class<?>, Pair<GenericDaoBase<?,?>, Object>>(1);
-        GenericDaoBase<?,?> dao = GenericDaoBase.getDao(entityClass);
+        _entities = new HashMap<Class<?>, Pair<GenericDao<?,?>, Object>>(1);
+        GenericDao<?,?> dao = GenericDaoBase.getDao(entityClass);
         Enhancer searchEnhancer = new Enhancer();
         searchEnhancer.setSuperclass(entityClass);
         searchEnhancer.setCallback(this);
         Object entity = searchEnhancer.create();
         
-        _entities.put(entityClass, new Pair<GenericDaoBase<?, ?>, Object>(dao, entity));
+        _entities.put(entityClass, new Pair<GenericDao<?, ?>, Object>(dao, entity));
     }
     
     @Override
@@ -114,7 +114,7 @@ public class QueryBuilder<S, T> implements MethodInterceptor, SimpleQueryBuilder
         return this;
     }
     
-    protected void set(GenericDaoBase<?, ?> dao , String name) {
+    protected void set(GenericDao<?, ?> dao , String name) {
         Attribute attr = dao.getAllAttributes().get(name);
         assert (attr != null) : "Searching for a field that's not there: " + name;
         _specifiedAttrs.add(attr);
@@ -125,9 +125,9 @@ public class QueryBuilder<S, T> implements MethodInterceptor, SimpleQueryBuilder
     public Object intercept(Object entity, Method method, Object[] args, MethodProxy proxy) throws Throwable {
         Class<?> entityClass = entity.getClass().getSuperclass();
         
-        Pair<GenericDaoBase<?,?>, Object> daoInfo = _entities.get(entityClass);
+        Pair<GenericDao<?,?>, Object> daoInfo = _entities.get(entityClass);
         assert (daoInfo != null) : "You need to specify " + entityClass + " as one of the entities in the Query";
-        GenericDaoBase<?,?> dao = daoInfo.first();
+        GenericDao<?,?> dao = daoInfo.first();
         
         String name = method.getName();
         if (name.startsWith("get")) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/333dd810/utils/src/com/cloud/utils/db/TransactionContextBuilder.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/TransactionContextBuilder.java b/utils/src/com/cloud/utils/db/TransactionContextBuilder.java
index 9b474d5..2cbaa30 100644
--- a/utils/src/com/cloud/utils/db/TransactionContextBuilder.java
+++ b/utils/src/com/cloud/utils/db/TransactionContextBuilder.java
@@ -33,16 +33,8 @@ public class TransactionContextBuilder implements MethodInterceptor {
 	public Object AroundAnyMethod(ProceedingJoinPoint call) throws Throwable {
 		MethodSignature methodSignature = (MethodSignature)call.getSignature();
         Method targetMethod = methodSignature.getMethod();	
-        if(needToIntercept(targetMethod)) {
-        	Transaction txn = null;
-        	try {
-        		Signature s = call.getSignature();
-        		String name = s.getName();
-        		txn = Transaction.open(name);
-        	} catch (Throwable e) {
-        		s_logger.debug("Failed to open transaction: " + e.toString());
-        		throw e;
-        	}
+        if(true) { // TODO ??? needToIntercept(targetMethod)) {
+			Transaction txn = Transaction.open(call.getSignature().getName());
 			Object ret = null;
 			try {
 				 ret = call.proceed();


Mime
View raw message