cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject git commit: Fix issues with @DB support in Spring environment
Date Tue, 15 Jan 2013 20:35:13 GMT
Updated Branches:
  refs/heads/javelin 8af85b04d -> af67d8766


Fix issues with @DB support in Spring environment


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

Branch: refs/heads/javelin
Commit: af67d876625bdb7f41a43d4dc1417e17d48bbcef
Parents: 8af85b0
Author: Kelven Yang <kelveny@gmail.com>
Authored: Tue Jan 15 12:34:11 2013 -0800
Committer: Kelven Yang <kelveny@gmail.com>
Committed: Tue Jan 15 12:35:03 2013 -0800

----------------------------------------------------------------------
 client/tomcatconf/applicationContext.xml.in        |   20 ++++++++++++--
 .../src/com/cloud/agent/manager/AgentMonitor.java  |    1 +
 server/src/com/cloud/api/ApiDispatcher.java        |    3 --
 server/src/com/cloud/api/ApiServlet.java           |    4 +-
 .../com/cloud/event/ActionEventInterceptor.java    |    9 ------
 .../com/cloud/servlet/RegisterCompleteServlet.java |    6 ++--
 server/src/com/cloud/user/dao/UserDaoImpl.java     |    2 +
 .../cloud/utils/db/TransactionContextBuilder.java  |    4 +-
 8 files changed, 27 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af67d876/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index 95913b1..c2f2743 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -39,13 +39,25 @@
   -->
   <aop:config proxy-target-class="true">
     <aop:aspect id="dbContextBuilder" ref="transactionContextBuilder">
-    <aop:pointcut id="captureAnyMethod"
-      expression="execution(* *(..))" />
-      <aop:around pointcut-ref="captureAnyMethod" method="AroundAnyMethod"/> 
+        <aop:pointcut id="captureAnyMethod"
+            expression="execution(* *(..))" 
+        />
+        
+        <aop:around pointcut-ref="captureAnyMethod" method="AroundAnyMethod"/> 
     </aop:aspect>
+
+    <aop:aspect id="actionEventInterceptorAspect" ref="actionEventInterceptor">
+        <aop:pointcut id="captureEventMethod"
+            expression="execution(* *(..)) and @annotation(com.cloud.event.ActionEvent)"

+        />
+        <aop:around pointcut-ref="captureEventMethod" method="AroundAnyMethod"/> 
+    </aop:aspect>
+
   </aop:config>
   
   <bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder"
/>
+  <bean id="actionEventInterceptor" class="com.cloud.event.ActionEventInterceptor" />
+
 
   <!--
     RPC/Async/EventBus
@@ -77,4 +89,6 @@
 
   <bean id="eventBus" class = "org.apache.cloudstack.framework.eventbus.EventBusBase"
/>
 
+  <bean id="apiServlet" class = "com.cloud.api.ApiServlet" />
+
 </beans>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af67d876/server/src/com/cloud/agent/manager/AgentMonitor.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/AgentMonitor.java b/server/src/com/cloud/agent/manager/AgentMonitor.java
index ca8bde9..97c0411 100755
--- a/server/src/com/cloud/agent/manager/AgentMonitor.java
+++ b/server/src/com/cloud/agent/manager/AgentMonitor.java
@@ -76,6 +76,7 @@ public class AgentMonitor extends Thread implements Listener {
     private Map<Long, Long> _pingMap;
 
     public AgentMonitor() {
+        _pingMap = new ConcurrentHashMap<Long, Long>(10007);
     }
 
     public AgentMonitor(long msId, HostDao hostDao, VMInstanceDao vmDao, DataCenterDao dcDao,
HostPodDao podDao, AgentManagerImpl agentMgr, AlertManager alertMgr, long pingTimeout) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af67d876/server/src/com/cloud/api/ApiDispatcher.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java
index 0df37f1..e82e028 100755
--- a/server/src/com/cloud/api/ApiDispatcher.java
+++ b/server/src/com/cloud/api/ApiDispatcher.java
@@ -53,8 +53,6 @@ import org.springframework.stereotype.Component;
 
 import com.cloud.async.AsyncCommandQueued;
 import com.cloud.async.AsyncJobManager;
-import com.cloud.configuration.Config;
-import com.cloud.configuration.dao.ConfigurationDao;
 import com.cloud.dao.EntityManager;
 import com.cloud.exception.AccountLimitException;
 import com.cloud.exception.InsufficientCapacityException;
@@ -67,7 +65,6 @@ import com.cloud.user.AccountManager;
 import com.cloud.user.UserContext;
 import com.cloud.utils.DateUtil;
 import com.cloud.utils.ReflectUtil;
-import com.cloud.utils.component.ComponentContext;
 import com.cloud.utils.exception.CSExceptionErrorCode;
 import com.cloud.utils.exception.CloudRuntimeException;
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af67d876/server/src/com/cloud/api/ApiServlet.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServlet.java b/server/src/com/cloud/api/ApiServlet.java
index e535030..35bb7cc 100755
--- a/server/src/com/cloud/api/ApiServlet.java
+++ b/server/src/com/cloud/api/ApiServlet.java
@@ -48,8 +48,8 @@ public class ApiServlet extends HttpServlet {
     public static final Logger s_logger = Logger.getLogger(ApiServlet.class.getName());
     private static final Logger s_accessLogger = Logger.getLogger("apiserver." + ApiServer.class.getName());
 
-    ApiServer _apiServer;
-    AccountService _accountMgr;
+    @Inject ApiServer _apiServer;
+    @Inject AccountService _accountMgr;
 
     public ApiServlet() {
         super();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af67d876/server/src/com/cloud/event/ActionEventInterceptor.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/event/ActionEventInterceptor.java b/server/src/com/cloud/event/ActionEventInterceptor.java
index 7bacfa4..fb89498 100644
--- a/server/src/com/cloud/event/ActionEventInterceptor.java
+++ b/server/src/com/cloud/event/ActionEventInterceptor.java
@@ -20,24 +20,15 @@ import java.lang.reflect.AnnotatedElement;
 import java.lang.reflect.Method;
 
 import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Pointcut;
 import org.aspectj.lang.reflect.MethodSignature;
 
 import com.cloud.user.UserContext;
 
-@Aspect
 public class ActionEventInterceptor {
 
 	public ActionEventInterceptor() {
 	}
 
-	@Pointcut(value="execution( * *(..))")
-	public void anyMethod() {
-	}
-
-	@Around("anyMethod() && @annotation(ActionEvent)")
 	public Object AroundAnyMethod(ProceedingJoinPoint call) throws Throwable {
 		MethodSignature methodSignature = (MethodSignature)call.getSignature();
         Method targetMethod = methodSignature.getMethod();	

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af67d876/server/src/com/cloud/servlet/RegisterCompleteServlet.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/servlet/RegisterCompleteServlet.java b/server/src/com/cloud/servlet/RegisterCompleteServlet.java
index 5922455..779e3a3 100644
--- a/server/src/com/cloud/servlet/RegisterCompleteServlet.java
+++ b/server/src/com/cloud/servlet/RegisterCompleteServlet.java
@@ -44,9 +44,9 @@ public class RegisterCompleteServlet extends HttpServlet implements ServletConte
 
     static final long serialVersionUID = SerialVersionUID.CloudStartupServlet;
 
-    @Inject AccountService _accountSvc = null;
-    @Inject ConfigurationDao _configDao = null;
-    @Inject UserDao _userDao = null;
+    @Inject AccountService _accountSvc;
+    @Inject ConfigurationDao _configDao;
+    @Inject UserDao _userDao;
 
     @Override
     public void contextInitialized(ServletContextEvent sce) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af67d876/server/src/com/cloud/user/dao/UserDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/dao/UserDaoImpl.java b/server/src/com/cloud/user/dao/UserDaoImpl.java
index 2f318a3..bbef07e 100644
--- a/server/src/com/cloud/user/dao/UserDaoImpl.java
+++ b/server/src/com/cloud/user/dao/UserDaoImpl.java
@@ -23,12 +23,14 @@ import javax.ejb.Local;
 import org.springframework.stereotype.Component;
 
 import com.cloud.user.UserVO;
+import com.cloud.utils.db.DB;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
 
 @Component
 @Local(value={UserDao.class})
+@DB
 public class UserDaoImpl extends GenericDaoBase<UserVO, Long> implements UserDao {
     protected SearchBuilder<UserVO> UsernamePasswordSearch;
     protected SearchBuilder<UserVO> UsernameSearch;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/af67d876/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 8f70087..c8a7f7a 100644
--- a/utils/src/com/cloud/utils/db/TransactionContextBuilder.java
+++ b/utils/src/com/cloud/utils/db/TransactionContextBuilder.java
@@ -63,14 +63,14 @@ public class TransactionContextBuilder implements MethodInterceptor {
 	private boolean needToIntercept(Method method) {
         DB db = method.getAnnotation(DB.class);
         if (db != null) {
-            return db.txn();
+            return true;
         }
         
         Class<?> clazz = method.getDeclaringClass();
         do {
             db = clazz.getAnnotation(DB.class);
             if (db != null) {
-                return db.txn();
+                return true;
             }
             clazz = clazz.getSuperclass();
         } while (clazz != Object.class && clazz != null);


Mime
View raw message