Return-Path: X-Original-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-cloudstack-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 10831E838 for ; Fri, 8 Mar 2013 19:37:53 +0000 (UTC) Received: (qmail 76527 invoked by uid 500); 8 Mar 2013 19:37:50 -0000 Delivered-To: apmail-incubator-cloudstack-commits-archive@incubator.apache.org Received: (qmail 76450 invoked by uid 500); 8 Mar 2013 19:37:50 -0000 Mailing-List: contact cloudstack-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cloudstack-dev@incubator.apache.org Delivered-To: mailing list cloudstack-commits@incubator.apache.org Received: (qmail 75891 invoked by uid 99); 8 Mar 2013 19:37:49 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Mar 2013 19:37:49 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 8D17B50E2; Fri, 8 Mar 2013 19:37:49 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: bfederle@apache.org To: cloudstack-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [24/38] git commit: refs/heads/ui-multiple-nics - CLOUDSTACK-1562: Replace @DB support to be the formal implementation instead of a temporary hacking one Message-Id: <20130308193749.8D17B50E2@tyr.zones.apache.org> Date: Fri, 8 Mar 2013 19:37:49 +0000 (UTC) CLOUDSTACK-1562: Replace @DB support to be the formal implementation instead of a temporary hacking one Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/89f4ac04 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/89f4ac04 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/89f4ac04 Branch: refs/heads/ui-multiple-nics Commit: 89f4ac0439852be13f2d78b57d8d1d3716d641df Parents: 837f7e1 Author: Kelven Yang Authored: Wed Mar 6 16:43:48 2013 -0800 Committer: Kelven Yang Committed: Thu Mar 7 15:47:01 2013 -0800 ---------------------------------------------------------------------- .../cloud/utils/component/ComponentContext.java | 4 --- .../cloud/utils/db/TransactionContextBuilder.java | 20 ++++++++++++--- 2 files changed, 16 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/89f4ac04/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 407ad7a..ca7ad5c 100644 --- a/utils/src/com/cloud/utils/component/ComponentContext.java +++ b/utils/src/com/cloud/utils/component/ComponentContext.java @@ -28,10 +28,7 @@ import javax.management.NotCompliantMBeanException; import javax.naming.ConfigurationException; import org.apache.log4j.Logger; -import org.springframework.aop.Advisor; import org.springframework.aop.framework.Advised; -import org.springframework.aop.framework.ProxyFactory; -import org.springframework.aop.support.DefaultPointcutAdvisor; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.context.ApplicationContext; @@ -39,7 +36,6 @@ import org.springframework.context.ApplicationContextAware; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Component; -import com.cloud.utils.db.TransactionContextBuilder; import com.cloud.utils.mgmt.JmxUtil; import com.cloud.utils.mgmt.ManagementBean; http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/89f4ac04/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 2cbaa30..e03b25f 100644 --- a/utils/src/com/cloud/utils/db/TransactionContextBuilder.java +++ b/utils/src/com/cloud/utils/db/TransactionContextBuilder.java @@ -32,8 +32,8 @@ public class TransactionContextBuilder implements MethodInterceptor { public Object AroundAnyMethod(ProceedingJoinPoint call) throws Throwable { MethodSignature methodSignature = (MethodSignature)call.getSignature(); - Method targetMethod = methodSignature.getMethod(); - if(true) { // TODO ??? needToIntercept(targetMethod)) { + Method targetMethod = methodSignature.getMethod(); + if(needToIntercept(targetMethod, call.getTarget())) { Transaction txn = Transaction.open(call.getSignature().getName()); Object ret = null; try { @@ -50,7 +50,7 @@ public class TransactionContextBuilder implements MethodInterceptor { public Object invoke(MethodInvocation method) throws Throwable { Method targetMethod = method.getMethod(); - if(needToIntercept(targetMethod)) { + if(needToIntercept(targetMethod, method.getThis())) { Transaction txn = Transaction.open(targetMethod.getName()); Object ret = null; try { @@ -63,13 +63,25 @@ public class TransactionContextBuilder implements MethodInterceptor { return method.proceed(); } - private boolean needToIntercept(Method method) { + private boolean needToIntercept(Method method, Object target) { DB db = method.getAnnotation(DB.class); if (db != null) { return true; } Class clazz = method.getDeclaringClass(); + if(clazz.isInterface()) { + clazz = target.getClass(); + for(Method m : clazz.getMethods()) { + // it is supposed that we need to check against type arguments, + // this can be simplified by just checking method name + if(m.getName().equals(method.getName())) { + if(m.getAnnotation(DB.class) != null) + return true; + } + } + } + do { db = clazz.getAnnotation(DB.class); if (db != null) {